cfg.h: pull stdlib.h for exit()
[0verkill.git] / data.h
blob7831d53e86470bcbdc8baf228b18558a8d69cc1b
1 #ifndef __DATA_H
2 #define __DATA_H
4 #ifndef WIN32
5 #include "config.h"
6 #else
7 /* rezim kompatibility s woknama ... */
8 #include <direct.h>
9 #define snprintf(t, s, ...) _snprintf_s(t, s, s, __VA_ARGS__)
10 #define close(...) while(0);
11 #define chdir(...) _chdir(__VA_ARGS__)
12 #define random rand
13 #define srandom(x) srand((unsigned int)x)
14 #define sleep(x) Sleep(x)
15 #define strcat(d, s) strcat_s(d, sizeof(s), s)
16 #endif
17 #include "cfg.h"
18 #include "sprite.h"
19 #include "math.h"
21 #define TYPE_BACKGROUND 0
22 #define TYPE_WALL 16
23 #define TYPE_JUMP 32 /* proskakovatko */
24 #define TYPE_FOREGROUND 48 /* pred maniakem */
25 #define TYPE_JUMP_FOREGROUND 64 /* proskakovatko pred maniakem */
27 #define TYPE_BIRTHPLACE 666
29 /* object types */
30 #define N_TYPES 32
32 #define T_PLAYER 0
33 #define T_BULLET 1
34 #define T_CORPSE 2
35 #define T_MEDIKIT 3
36 #define T_SHOTGUN 4
37 #define T_UZI 5
38 #define T_RIFLE 6
39 #define T_SHELL 7
40 #define T_AMMO_GUN 8
41 #define T_AMMO_SHOTGUN 9
42 #define T_AMMO_UZI 10
43 #define T_AMMO_RIFLE 11
44 #define T_NOTHING 12
45 #define T_MESS 13
46 #define T_GRENADE 14
47 #define T_AMMO_GRENADE 15
48 #define T_SHRAPNEL 16
49 #define T_ARMOR 17
50 #define T_INVISIBILITY 18
51 #define T_NOISE 19
52 #define T_NOTHING_FORE 20
53 #define T_KILL 21
54 #define T_TELEPORT 22
55 #define T_BFG 23
56 #define T_BFGCELL 24
57 #define T_CHAIN 25
58 #define T_BIOSKULL 26
59 #define T_BIOMED 27
60 #define T_BLOODRAIN 28
61 #define T_JETPACK 29
62 #define T_JETFIRE 30
63 #define T_PS 31
65 #define E_INCOMPATIBLE_VERSION 0
66 #define E_PLAYER_REFUSED 1
67 #define E_NAME_IN_USE 2
69 #define WEAPON_BLOODRAIN 7
70 #define WEAPON_CHAINSAW 6
71 #define WEAPON_BFG 5
72 #define WEAPON_GRENADE 4
73 #define WEAPON_RIFLE 3
74 #define WEAPON_UZI 2
75 #define WEAPON_SHOTGUN 1
76 #define WEAPON_GUN 0
78 #define WEAPON_MASK_BLOODRAIN 128
79 #define WEAPON_MASK_CHAINSAW 64
80 #define WEAPON_MASK_BFG 32
81 #define WEAPON_MASK_GRENADE 16
82 #define WEAPON_MASK_RIFLE 8
83 #define WEAPON_MASK_UZI 4
84 #define WEAPON_MASK_SHOTGUN 2
85 #define WEAPON_MASK_GUN 1
87 #define S_WALKING 0x0001
88 #define S_LOOKLEFT 0x0002
89 #define S_LOOKRIGHT 0x0004
90 #define S_FALLING 0x0008
91 #define S_SHOOTING 0x0010
92 #define S_HOLDING 0x0020
93 #define S_INVISIBLE 0x0040
94 #define S_HIT 0x0080
95 #define S_CREEP 0x0100
96 #define S_GRENADE 0x0200
97 #define S_DEAD 0x0400
98 #define S_CLIMB_DOWN 0x0800
99 #define S_NOISE 0x1000
100 #define S_CHAINSAW 0x2000
101 #define S_ILL 0x4000
102 #define S_BLOODRAIN 0x8000
103 #define S_JETPACK 0x10000
104 #define S_JETPACK_ON 0x20000
105 #define S_ONFIRE 0x40000
106 #define S_CHAIN 0x80000
108 #define M_DEFAULT 0x00
109 #define M_CHAT 0x01
110 #define M_INFO 0x02
111 #define M_ENTER 0x04
112 #define M_LEAVE 0x08
113 #define M_AMMO 0x10
114 #define M_WEAPON 0x20
115 #define M_ITEM 0x40
116 #define M_DEATH 0x80
118 #define C_BLACK 0x00
119 #define C_D_RED 0x01
120 #define C_D_GREEN 0x02
121 #define C_BROWN 0x03
122 #define C_D_BLUE 0x04
123 #define C_D_MAGENTA 0x05
124 #define C_D_CYAN 0x06
125 #define C_GREY 0x07
126 #define C_D_GREY 0x08
127 #define C_RED 0x09
128 #define C_GREEN 0x0a
129 #define C_YELLOW 0x0b
130 #define C_BLUE 0x0c
131 #define C_MAGENTA 0x0d
132 #define C_CYAN 0x0e
133 #define C_WHITE 0x0f
135 #define E_NONE 0x00
136 #define E_DEFAULTS 0x01
137 #define E_CONN 0x02
138 #define E_CONN_SUCC 0x04
140 #define ARMS 8
142 unsigned char *weapon_name[ARMS];
144 /* STATUS
145 0: walk
146 1,2: left(01), right(10), center (00)
147 3: fall
148 4: shoot
149 5: holding gun
150 6: hidden
151 7: hit
152 8: creep
153 9: throwing grenade
154 10: dead
158 /* object attribute table */
159 struct obj_attr_type
161 unsigned char fall; /* 1=can fall, 0=can't */
162 int bounce_x,bounce_y; /* slow down during horizontal/vertical bouncing */
163 int slow_down_x; /* slow down when not falling, speed is multiplied with this constant */
164 unsigned char maintainer;
165 unsigned char foreground; /* is this object in foreground? */
166 /* who computes the object:
167 bit 0=clients update
168 bit 1=server updates
169 bit 2=server sends updates to clients
171 }obj_attr[N_TYPES];
174 /* weapon attribut table */
175 struct weapon_type
177 char *name;
178 unsigned char cadence;
179 int ttl:16;
180 int speed,impact;
181 unsigned char lethalness;
182 unsigned char armor_damage;
183 unsigned char basic_ammo;
184 unsigned char add_ammo;
185 unsigned char max_ammo;
186 int shell_xspeed,shell_yspeed;
187 }weapon[ARMS];
190 /* object in the game */
191 struct it
193 int x,y,xspeed,yspeed; /* position and velocity */
194 unsigned char type; /* one of T_...... constants */
195 unsigned int id:24; /* unique ID */
196 int ttl:16; /* time to live */
197 unsigned int sprite:16; /* sprite number */
198 unsigned int anim_pos:16; /* animating position */
199 /* 16b hole in the structure */
200 unsigned int status; /* status - especially for hero objects */
201 void * data; /* object's own data, this is individual filled */
202 unsigned char update_counter; /* increased with each update of the object */
203 unsigned long_long last_updated; /* last time object was updated */
207 /* object list */
208 struct object_list
210 struct object_list *next,*prev;
211 struct it member;
215 extern struct object_list *last_obj;
217 extern struct sprite *sprites;
218 extern char **sprite_names;
219 extern int n_sprites;
221 /* static map */
222 extern unsigned char *area;
223 extern unsigned char *area_a;
225 extern void load_sprites(char *);
226 extern void load_data(char *);
227 extern int find_sprite(char *,int *);
228 extern void init_area(void);
229 extern void reinit_area(void);
230 extern void free_area(void);
231 extern char *md5_level(int);
232 extern struct it* new_obj(
233 unsigned int id,
234 unsigned char type,
235 int ttl,
236 int sprite,
237 unsigned char pos,
238 int status,
239 int x,
240 int y,
241 int xspeed,
242 int yspeed,
243 void * data);
244 void delete_obj(unsigned long id);
245 extern void put_int(char *p,int num, int *offset);
246 extern int get_int(char *p);
247 extern void put_int16(char *p,short num, int *offset);
248 extern int get_int16(char *p);
249 extern void put_long_long(char *p,unsigned long_long num, int *offset);
250 extern unsigned long_long get_long_long(char *p);
251 extern void free_sprites(int);
253 #ifdef HAVE_INLINE
254 extern inline void
255 #else
256 extern void
257 #endif
258 get_dimensions(int type,int status,struct pos *s,int *w,int *h);
260 void update_position(
261 struct it* obj,
262 int new_x,
263 int new_y,
264 int width,
265 int height,
266 unsigned char *fx,
267 unsigned char *fy
270 extern void _skip_ws(char**txt);
271 extern int _convert_type(unsigned char c);
272 extern char * load_level(int);
273 extern void chdir_to_data_files(void);
274 #endif