Fix chainsaw
[0verkill.git] / data.h
blob2b545f8d6b1ea5936c3abc4af7a5fe0e62c63b69
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 31
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
64 #define E_INCOMPATIBLE_VERSION 0
65 #define E_PLAYER_REFUSED 1
67 #define WEAPON_BLOODRAIN 7
68 #define WEAPON_CHAINSAW 6
69 #define WEAPON_BFG 5
70 #define WEAPON_GRENADE 4
71 #define WEAPON_RIFLE 3
72 #define WEAPON_UZI 2
73 #define WEAPON_SHOTGUN 1
74 #define WEAPON_GUN 0
76 #define WEAPON_MASK_BLOODRAIN 128
77 #define WEAPON_MASK_CHAINSAW 64
78 #define WEAPON_MASK_BFG 32
79 #define WEAPON_MASK_GRENADE 16
80 #define WEAPON_MASK_RIFLE 8
81 #define WEAPON_MASK_UZI 4
82 #define WEAPON_MASK_SHOTGUN 2
83 #define WEAPON_MASK_GUN 1
85 #define S_WALKING 0x0001
86 #define S_LOOKLEFT 0x0002
87 #define S_LOOKRIGHT 0x0004
88 #define S_FALLING 0x0008
89 #define S_SHOOTING 0x0010
90 #define S_HOLDING 0x0020
91 #define S_INVISIBLE 0x0040
92 #define S_HIT 0x0080
93 #define S_CREEP 0x0100
94 #define S_GRENADE 0x0200
95 #define S_DEAD 0x0400
96 #define S_CLIMB_DOWN 0x0800
97 #define S_NOISE 0x1000
98 #define S_CHAINSAW 0x2000
99 #define S_ILL 0x4000
100 #define S_BLOODRAIN 0x8000
101 #define S_JETPACK 0x10000
102 #define S_JETPACK_ON 0x20000
103 #define S_ONFIRE 0x40000
104 #define S_CHAIN 0x80000
106 #define M_DEFAULT 0x00
107 #define M_CHAT 0x01
108 #define M_INFO 0x02
109 #define M_ENTER 0x04
110 #define M_LEAVE 0x08
111 #define M_AMMO 0x10
112 #define M_WEAPON 0x20
113 #define M_ITEM 0x40
114 #define M_DEATH 0x80
116 #define C_BLACK 0x00
117 #define C_D_RED 0x01
118 #define C_D_GREEN 0x02
119 #define C_BROWN 0x03
120 #define C_D_BLUE 0x04
121 #define C_D_MAGENTA 0x05
122 #define C_D_CYAN 0x06
123 #define C_GREY 0x07
124 #define C_D_GREY 0x08
125 #define C_RED 0x09
126 #define C_GREEN 0x0a
127 #define C_YELLOW 0x0b
128 #define C_BLUE 0x0c
129 #define C_MAGENTA 0x0d
130 #define C_CYAN 0x0e
131 #define C_WHITE 0x0f
133 #define E_NONE 0x00
134 #define E_DEFAULTS 0x01
135 #define E_CONN 0x02
136 #define E_CONN_SUCC 0x04
138 #define ARMS 8
140 unsigned char *weapon_name[ARMS];
142 /* STATUS
143 0: walk
144 1,2: left(01), right(10), center (00)
145 3: fall
146 4: shoot
147 5: holding gun
148 6: hidden
149 7: hit
150 8: creep
151 9: throwing grenade
152 10: dead
156 /* object attribute table */
157 struct obj_attr_type
159 unsigned char fall; /* 1=can fall, 0=can't */
160 int bounce_x,bounce_y; /* slow down during horizontal/vertical bouncing */
161 int slow_down_x; /* slow down when not falling, speed is multiplied with this constant */
162 unsigned char maintainer;
163 unsigned char foreground; /* is this object in foreground? */
164 /* who computes the object:
165 bit 0=clients update
166 bit 1=server updates
167 bit 2=server sends updates to clients
169 }obj_attr[N_TYPES];
172 /* weapon attribut table */
173 struct weapon_type
175 char *name;
176 unsigned char cadence;
177 int ttl:16;
178 int speed,impact;
179 unsigned char lethalness;
180 unsigned char armor_damage;
181 unsigned char basic_ammo;
182 unsigned char add_ammo;
183 unsigned char max_ammo;
184 int shell_xspeed,shell_yspeed;
185 }weapon[ARMS];
188 /* object in the game */
189 struct it
191 int x,y,xspeed,yspeed; /* position and velocity */
192 unsigned char type; /* one of T_...... constants */
193 unsigned int id:24; /* unique ID */
194 int ttl:16; /* time to live */
195 unsigned int sprite:16; /* sprite number */
196 unsigned int anim_pos:16; /* animating position */
197 /* 16b hole in the structure */
198 unsigned int status; /* status - especially for hero objects */
199 void * data; /* object's own data, this is individual filled */
200 unsigned char update_counter; /* increased with each update of the object */
201 unsigned long_long last_updated; /* last time object was updated */
205 /* object list */
206 struct object_list
208 struct object_list *next,*prev;
209 struct it member;
213 extern struct object_list *last_obj;
215 extern struct sprite *sprites;
216 extern char **sprite_names;
217 extern int n_sprites;
219 /* static map */
220 extern unsigned char *area;
221 extern unsigned char *area_a;
223 extern void load_sprites(char *);
224 extern void load_data(char *);
225 extern int find_sprite(char *,int *);
226 extern void init_area(void);
227 extern void reinit_area(void);
228 extern void free_area(void);
229 extern char *md5_level(int);
230 extern struct it* new_obj(
231 unsigned int id,
232 unsigned char type,
233 int ttl,
234 int sprite,
235 unsigned char pos,
236 int status,
237 int x,
238 int y,
239 int xspeed,
240 int yspeed,
241 void * data);
242 void delete_obj(unsigned long id);
243 extern void put_int(char *p,int num, int *offset);
244 extern int get_int(char *p);
245 extern void put_int16(char *p,short num, int *offset);
246 extern int get_int16(char *p);
247 extern void put_long_long(char *p,unsigned long_long num, int *offset);
248 extern unsigned long_long get_long_long(char *p);
249 extern void free_sprites(int);
251 #ifdef HAVE_INLINE
252 extern inline void
253 #else
254 extern void
255 #endif
256 get_dimensions(int type,int status,struct pos *s,int *w,int *h);
258 void update_position(
259 struct it* obj,
260 int new_x,
261 int new_y,
262 int width,
263 int height,
264 unsigned char *fx,
265 unsigned char *fy
268 extern void _skip_ws(char**txt);
269 extern int _convert_type(unsigned char c);
270 extern char * load_level(int);
271 extern void chdir_to_data_files(void);
272 #endif