added worldarea -> will be responsible for world map rendering
[dboe.git] / global.c
blobb69a5f933613d7370e706829e1600dc0e499a1e2
1 #include <gtk/gtk.h>
2 #include <stdlib.h>
3 #include "global.h"
4 #include "math.h"
6 extern short give_delays;
8 void alter_rect(RECT *r)
10 short a;
12 a = r->top;
13 r->top = r->left;
14 r->left = a;
15 a = r->bottom;
16 r->bottom = r->right;
17 r->right = a;
19 short get_ran (short times,short min,short max)
21 short store;
22 short i, to_ret = 0;
24 if ((max - min + 1) == 0)
25 return 0;
26 for (i = 1; i < times + 1; i++) {
27 store = rand() % (max - min + 1);
28 to_ret = to_ret + min + store;
30 return to_ret;
33 Boolean same_point(location p1,location p2)
35 if ((p1.x == p2.x) & (p1.y == p2.y))
36 return TRUE;
37 else return FALSE;
40 short move_to_zero(short val)
42 if (val < 0)
43 return val + 1;
44 if (val > 0)
45 return val - 1;
46 return val;
49 short max(short a,short b)
51 if (a > b)
52 return a;
53 else return b;
56 short min(short a,short b)
58 if (a < b)
59 return a;
60 else return b;
63 short minmax(short min,short max,short k)
65 if (k < min)
66 return min;
67 if (k > max)
68 return max;
69 return k;
72 short s_pow(short x,short y)
74 if (y == 0)
75 return 1;
76 return (short) pow((double) x, (double) y);
79 short a_v(short x)
81 if (x < 0)
82 return (-1 * x);
83 else return x;
85 short ex_abs(short x)
87 if (x < 0)
88 return (-1 * x);
89 else return x;
92 void Delay(short val,long *dummy)
94 /* FIX
95 long then,now,wait_val;
97 wait_val = (long) val;
98 wait_val = wait_val * 16;
99 then = (long)GetCurrentTime();
100 now = then;
101 while (now - then < wait_val) {
102 now = (long) GetCurrentTime();
107 // stuff done legit, i.e. flags are within proper ranges for stuff done flag
108 Boolean sd_legit(short a, short b)
110 if ((minmax(0,299,a) == a) && (minmax(0,9,b) == b))
111 return TRUE;
112 return FALSE;