1 /////////////////////////////////////////
2 //
3 //             OpenLieroX
4 //
5 // code under LGPL, based on JasonBs work,
6 // enhanced by Dark Charlie and Albert Zeyer
7 //
8 //
9 /////////////////////////////////////////
10 
11 
12 // Misclelaneous functions
13 // Created 18/8/02
14 // Jason Boettcher
15 
16 
17 #include <cstdarg>
18 #include <cassert>
19 
20 #include "LieroX.h"
21 #include "Debug.h"
22 #include "GfxPrimitives.h"
23 #include "InputEvents.h"
24 #include "StringUtils.h"
25 
26 
27 // Random Number list
28 #include "RandomNumberList.h"
29 
30 
31 
32 
33 
34 
35 
36 /*
37 ===========================
38 
39          Misc crap
40 
41 ===========================
42 */
43 
44 
45 ///////////////////
46 // Convert a float time into it's hours, minutes & seconds
ConvertTime(TimeDiff time,int * hours,int * minutes,int * seconds)47 void ConvertTime(TimeDiff time, int *hours, int *minutes, int *seconds)
48 {
49 	*seconds = (int)time.seconds();
50 	*minutes = *seconds / 60;
51 	if(*minutes)
52 	{
53 		*seconds -= (*minutes * 60);
54 		*hours = *minutes / 60;
55 		if(*hours)
56 			*minutes -= (*hours * 60);
57 	}
58 	else
59 		*hours = 0;
60 }
61 
62 
63 
64 
65 ///////////////////
66 // Returns true if the mouse is inside a rectangle
MouseInRect(int x,int y,int w,int h)67 bool MouseInRect(int x, int y, int w, int h)
68 {
69     mouse_t *m = GetMouse();
70 	return ((m->X >= x) && (m->X <= x+w))  &&
71 		   ((m->Y >= y) && (m->Y <= y+h));
72 }
73 
74 
75 
76 
printf(const std::string & txt)77 void printf(const std::string& txt) {
78 	notes << txt << flush;
79 }
80 
81 
82 ///////////////////
83 // Return a fixed random number
GetFixedRandomNum(uchar index)84 float GetFixedRandomNum(uchar index)
85 {
86 	return RandomNumbers[index];
87 }
88 
89 
90