1 #ifndef __DATA_H 2 #define __DATA_H 3 4 #ifndef WIN32 5 #include "config.h" 6 #endif 7 #include "cfg.h" 8 #include "sprite.h" 9 #include "math.h" 10 11 #define TYPE_BACKGROUND 0 12 #define TYPE_WALL 16 13 #define TYPE_JUMP 32 /* proskakovatko */ 14 #define TYPE_FOREGROUND 48 /* pred maniakem */ 15 #define TYPE_JUMP_FOREGROUND 64 /* proskakovatko pred maniakem */ 16 17 #define TYPE_BIRTHPLACE 666 18 19 /* object types */ 20 #define N_TYPES 22 21 22 #define T_PLAYER 0 23 #define T_BULLET 1 24 #define T_CORPSE 2 25 #define T_MEDIKIT 3 26 #define T_SHOTGUN 4 27 #define T_UZI 5 28 #define T_RIFLE 6 29 #define T_SHELL 7 30 #define T_AMMO_GUN 8 31 #define T_AMMO_SHOTGUN 9 32 #define T_AMMO_UZI 10 33 #define T_AMMO_RIFLE 11 34 #define T_NOTHING 12 35 #define T_MESS 13 36 #define T_GRENADE 14 37 #define T_AMMO_GRENADE 15 38 #define T_SHRAPNEL 16 39 #define T_ARMOR 17 40 #define T_INVISIBILITY 18 41 #define T_NOISE 19 42 #define T_NOTHING_FORE 20 43 #define T_KILL 21 44 45 46 #define E_INCOMPATIBLE_VERSION 0 47 #define E_PLAYER_REFUSED 1 48 49 50 #define WEAPON_GRENADE 4 51 #define WEAPON_RIFLE 3 52 #define WEAPON_UZI 2 53 #define WEAPON_SHOTGUN 1 54 #define WEAPON_GUN 0 55 56 #define WEAPON_MASK_GRENADE 16 57 #define WEAPON_MASK_RIFLE 8 58 #define WEAPON_MASK_UZI 4 59 #define WEAPON_MASK_SHOTGUN 2 60 #define WEAPON_MASK_GUN 1 61 62 63 #define ARMS 5 64 65 unsigned char *weapon_name[ARMS]; 66 67 /* STATUS 68 0: walk 69 1,2: left(01), right(10), center (00) 70 3: fall 71 4: shoot 72 5: holding gun 73 6: hidden 74 7: hit 75 8: creep 76 9: throwing grenade 77 10: dead 78 */ 79 80 81 /* object attribute table */ 82 struct obj_attr_type 83 { 84 unsigned char fall; /* 1=can fall, 0=can't */ 85 my_double bounce_x,bounce_y; /* slow down during horizontal/vertical bouncing */ 86 my_double slow_down_x; /* slow down when not falling, speed is multiplied with this constant */ 87 unsigned char maintainer; 88 unsigned char foreground; /* is this object in foreground? */ 89 /* who computes the object: 90 bit 0=clients update 91 bit 1=server updates 92 bit 2=server sends updates to clients 93 */ 94 }obj_attr[N_TYPES]; 95 96 97 /* weapon attribut table */ 98 struct weapon_type 99 { 100 unsigned char *name; 101 unsigned char cadence; 102 int ttl:16; 103 my_double speed,impact; 104 unsigned char lethalness; 105 unsigned char armor_damage; 106 unsigned char basic_ammo; 107 unsigned char add_ammo; 108 unsigned char max_ammo; 109 my_double shell_xspeed,shell_yspeed; 110 }weapon[ARMS]; 111 112 113 /* object in the game */ 114 struct it 115 { 116 my_double x,y,xspeed,yspeed; /* position and velocity */ 117 unsigned char type; /* one of T_...... constants */ 118 unsigned int id:24; /* unique ID */ 119 int ttl:16; /* time to live */ 120 unsigned int sprite:16; /* sprite number */ 121 unsigned int anim_pos:16; /* animating position */ 122 unsigned int status:16; /* status - especially for hero objects */ 123 void * data; /* object's own data, this is individual filled */ 124 unsigned char update_counter; /* increased with each update of the object */ 125 unsigned long_long last_updated; /* last time object was updated */ 126 }; 127 128 129 /* object list */ 130 struct object_list 131 { 132 struct object_list *next,*prev; 133 struct it member; 134 }; 135 136 137 extern struct object_list *last_obj; 138 139 extern struct sprite *sprites; 140 extern unsigned char **sprite_names; 141 extern int n_sprites; 142 143 /* static map */ 144 extern unsigned char *area; 145 extern unsigned char *area_a; 146 147 extern void load_sprites(unsigned char *); 148 extern void load_data(unsigned char *); 149 extern int find_sprite(unsigned char *,int *); 150 extern void init_area(void); 151 extern void reinit_area(void); 152 extern void free_area(void); 153 extern unsigned char *md5_level(int); 154 extern struct it* new_obj( 155 unsigned int id, 156 unsigned char type, 157 int ttl, 158 int sprite, 159 unsigned char pos, 160 int status, 161 my_double x, 162 my_double y, 163 my_double xspeed, 164 my_double yspeed, 165 void * data); 166 void delete_obj(unsigned long id); 167 extern void put_int(unsigned char *p,int num); 168 extern int get_int(unsigned char *p); 169 extern void put_int16(unsigned char *p,int num); 170 extern int get_int16(unsigned char *p); 171 extern void put_int(unsigned char *p,int num); 172 extern int get_int(unsigned char *p); 173 extern void put_float(unsigned char *p,my_double num); 174 extern my_double get_float(unsigned char *p); 175 extern void put_long_long(unsigned char *p,unsigned long_long num); 176 extern unsigned long_long get_long_long(unsigned char *p); 177 extern void free_sprites(int); 178 179 #ifdef HAVE_INLINE 180 extern inline void 181 #else 182 extern void 183 #endif 184 get_dimensions(int type,int status,struct pos *s,int *w,int *h); 185 186 void update_position( 187 struct it* obj, 188 my_double new_x, 189 my_double new_y, 190 int width, 191 int height, 192 unsigned char *fx, 193 unsigned char *fy 194 ); 195 196 extern void _skip_ws(char**txt); 197 extern int _convert_type(unsigned char c); 198 extern unsigned char * load_level(int); 199 #endif 200