1 /*
2  * file xblast.h - common macros, constants ansd types
3  *
4  * $Id: xblast.h,v 1.16 2006/03/28 11:58:16 fzago Exp $
5  *
6  * Program XBLAST
7  * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published
11  * by the Free Software Foundation; either version 2; or (at your option)
12  * any later version
13  *
14  * This program is distributed in the hope that it will be entertaining,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.
21  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  *
23  */
24 
25 #ifdef XBLAST_XBLAST_H
26 #error
27 #endif
28 #define XBLAST_XBLAST_H
29 
30 /* include config header first */
31 #ifdef HAVE_CONFIG_H
32 /* autoconf generated */
33 #include "config.h"
34 #else
35 /* non-autoconf generated, include target specific header */
36 #ifdef __MINGW32__
37 #include "config-mingw.h"
38 #endif
39 #endif
40 
41 #include <unistd.h>
42 #include <stdio.h>
43 #include <stdlib.h>
44 #include <stdint.h>
45 #include <sys/stat.h>
46 #include <fcntl.h>
47 #include <string.h>
48 #include <math.h>
49 #include <assert.h>
50 #include <ctype.h>
51 #include <stdarg.h>
52 #include <errno.h>
53 #include <time.h>
54 
55 #ifdef HAVE_SYS_TIME_H
56 #include <sys/time.h>
57 #endif
58 
59 #ifdef WIN32
60 #include <windows.h>
61 #endif
62 
63 #ifdef W32
64 #ifndef WMS
65 #include <windows.h>
66 #include <winsock2.h>
67 #endif
68 #endif
69 
70 #if defined(__MINGW32__) || defined(WMS)
71 #include <windows.h>
72 #include <direct.h>
73 #endif
74 
75 #ifndef __USE_W32_SOCKETS
76 #ifndef W32
77 #include <sys/socket.h>
78 #endif
79 #endif
80 
81 #ifdef WIN32
82 #else
83 #include <dirent.h>
84 #endif
85 
86 /*--------------------------------------------------------------------------*/
87 
88 /*
89  * macros
90  */
91 #ifdef MAX
92 #undef MAX
93 #endif
94 #define MAX(a,b) ( (a)>=(b) ? (a) : (b) )
95 
96 #ifdef MIN
97 #undef MIN
98 #endif
99 #define MIN(a,b) ( (a)<=(b) ? (a) : (b) )
100 
101 #ifdef ABS
102 #undef ABS
103 #endif
104 #define ABS(a)   ( (a)>=0 ? (a) : (-(a)) )
105 
106 /* how may player are maximum */
107 #ifdef SMPF
108 #define MAX_PLAYER 16
109 #else
110 #define MAX_PLAYER 6
111 #endif
112 
113 /* maximum mask bytes allowed, affects player maximum in network game */
114 #define MAX_MASK_BYTES     4
115 
116 /* how many local players */
117 #define NUM_LOCAL_PLAYER 6
118 /* how many client can connect */
119 #define MAX_HOSTS  MAX_PLAYER
120 
121 /* maximum allowed number of victories to win */
122 #define MAX_VICTORIES 9
123 
124 /* dimension of of maze */
125 #define MAZE_W 15
126 #define MAZE_H 13
127 #define STAT_W 20
128 #ifdef SMPF
129 #define STAT_H 3
130 #else
131 #define STAT_H 2
132 #endif
133 
134 /* number block tiles */
135 #define MAX_BLOCK     11
136 #define MENU_MAX_TILE 21
137 #define MAX_TILE      MAX(MAX_BLOCK,MENU_MAX_TILE)
138 
139 /* number of bombs and their animations */
140 #define MAX_BOMBS 2
141 #define MAX_BOMB_ANIME 17
142 
143 /* size of big letters */
144 #define CHARW 3
145 #define CHARH 5
146 
147 #define MAX_EXPLOSION 16
148 
149 #define TIME_STEP   48
150 #define DEAD_TIME    8
151 #define GAME_TIME   (60*TIME_STEP + DEAD_TIME)
152 
153 																				 /* Added by Fouf on 09/14/99 23:55:18 *//* Written by Amilhastre */
154 #define BOMB_SEARCH_X  (2.5*BLOCK_WIDTH)
155 #define BOMB_SEARCH_Y  (2.5*BLOCK_HEIGHT)
156 
157 /* length of a frame in ms */
158 #define FRAME_TIME    50
159 
160 /*
161  * fundamental types
162  */
163 typedef enum
164 {
165 	XBFalse = 0, XBTrue
166 } XBBool;
167 
168 typedef struct
169 {
170 	double x, y;
171 } BMPoint;
172 
173 typedef struct
174 {
175 	int x, y;
176 	int w, h;
177 } BMRectangle;
178 
179 /*
180  *  position vector
181  */
182 typedef struct
183 {
184 	short y, x;
185 } BMPosition;
186 
187 /*
188  *  PFV Pointer to void/int functions
189  */
190 typedef void (*PFV) (void);
191 typedef int (*PFI) (void);
192 typedef BMRectangle *(*PFR) (void);
193 
194 /*
195  * player sprite animations phase
196  */
197 typedef enum
198 {
199 	SpriteStopDown = 0,
200 	SpriteWalkDown0, SpriteWalkDown1, SpriteWalkDown2, SpriteWalkDown3,
201 	SpriteStopUp,
202 	SpriteWalkUp0, SpriteWalkUp1, SpriteWalkUp2, SpriteWalkUp3,
203 	SpriteStopRight,
204 	SpriteWalkRight0, SpriteWalkRight1, SpriteWalkRight2, SpriteWalkRight3,
205 	SpriteStopLeft,
206 	SpriteWalkLeft0, SpriteWalkLeft1, SpriteWalkLeft2, SpriteWalkLeft3,
207 	SpriteDamagedDown, SpriteDamagedLeft, SpriteDamagedUp, SpriteDamagedRight,
208 	SpriteLooser, SpriteLooser1, SpriteLooser2,
209 	SpriteWinner, SpriteWinner2, SpriteWinner3,
210 	SpriteBigWinner,
211 	SpriteDeadDown, SpriteDeadLeft, SpriteDeadUp, SpriteDeadRight,
212 	SpriteMorphed,
213 	SpriteZombie,
214 	MAX_ANIME
215 } BMSpriteAnimation;
216 
217 #define MAX_ANIME_EPM ((int) SpriteDeadDown)
218 #define MAX_ANIME_PPM ((int) (MAX_ANIME - MAX_ANIME_EPM))
219 
220 /*
221  * player directions
222  */
223 typedef enum
224 {
225 	GoStop = 0, GoUp, GoLeft, GoDown, GoRight, GoDefault, GoAll,
226 	MAX_DIR
227 } BMDirection;
228 
229 /*
230  * ???
231  */
232 typedef enum
233 {
234 	SBVoid = 0,
235 	SBTextLeft, SBTextMid, SBTextRight,
236 	SBDead = 4,
237 	SBSick = 4 + MAX_PLAYER,
238 	SBPlayer = 4 + 2 * MAX_PLAYER,
239 	SBAbort = 4 + 3 * MAX_PLAYER,
240 	SBSickAbort = 4 + 4 * MAX_PLAYER,
241 	MAX_SCORE_TILES = 4 + 5 * MAX_PLAYER
242 } BMScoreTile;
243 
244 /*--------------------------------------------------------------------------*/
245 
246 #ifdef WMS
247 #define GAME_DATADIR "."
248 #endif
249 
250 /*--------------------------------------------------------------------------*/
251 
252 
253 #include "debug.h"
254 #include "socket.h"
255 #include "util.h"
256 #include "str_util.h"
257 #include "event.h"
258 #include "random.h"
259 #include "version.h"
260 
261 #include "color.h"
262 #include "sprite.h"
263 #include "image.h"
264 
265 #include "cfg_xblast.h"
266 #include "snd.h"
267 
268 #include "dat_rating.h"
269 #include "net_tele.h"
270 #include "action.h"
271 #include "ini_file.h"
272 
273 #include "cfg_main.h"
274 #include "cfg_game.h"
275 #include "cfg_player.h"
276 #include "cfg_stat.h"
277 #include "cfg_demo.h"
278 #include "cfg_level.h"
279 #include "cfg_control.h"
280 
281 #include "gui.h"
282 #include "browse.h"
283 #include "chat.h"
284 #include "atom.h"
285 
286 #include "net_dgram.h"
287 #include "net_socket.h"
288 
289 #include "network.h"
290 #include "com.h"
291 #include "com_central.h"
292 #include "com_base.h"
293 #include "com_central.h"
294 #include "com_dgram.h"
295 #include "com_from_central.h"
296 #include "com_newgame.h"
297 #include "com_reply.h"
298 #include "com_to_central.h"
299 #include "com_to_server.h"
300 #include "com_browse.h"
301 #include "com_dg_client.h"
302 #include "com_dg_server.h"
303 #include "com_listen.h"
304 #include "com_query.h"
305 #include "com_stream.h"
306 #include "com_to_client.h"
307 
308 #include "player.h"
309 #include "client.h"
310 #include "server.h"
311 #include "central.h"
312 #include "user.h"
313 
314 #include "mi_tool.h"
315 #include "mi_base.h"
316 #include "mi_button.h"
317 #include "mi_color.h"
318 #include "mi_cyclic.h"
319 #include "mi_int.h"
320 #include "mi_label.h"
321 #include "mi_player.h"
322 #include "mi_string.h"
323 #include "mi_toggle.h"
324 #include "mi_combo.h"
325 #include "mi_host.h"
326 #include "mi_keysym.h"
327 #include "mi_map.h"
328 #include "mi_stat.h"
329 #include "mi_tag.h"
330 
331 #include "menu.h"
332 #include "menu_level.h"
333 #include "menu_game.h"
334 #include "menu_layout.h"
335 #include "menu_extras.h"
336 #include "menu_player.h"
337 #include "menu_control.h"
338 #include "menu_network.h"
339 #include "menu_level.h"
340 #include "menu_edit.h"
341 
342 #include "game_local.h"
343 #include "game_demo.h"
344 #include "game_server.h"
345 #include "game_client.h"
346 
347 #include "map.h"
348 #include "level.h"
349 #include "geom.h"
350 #include "bomb.h"
351 #include "shrink.h"
352 #include "scramble.h"
353 #include "func.h"
354 #include "bot.h"
355 
356 #include "demo.h"
357 #include "game.h"
358 
359 #include "status.h"
360 
361 #include "intro.h"
362 #include "introdat.h"
363 
364 #include "info.h"
365 
366 #include "timeval.h"
367 
368 /* i18n */
369 #ifdef ENABLE_NLS
370 #include <libintl.h>
371 #include <locale.h>
372 #define _(String) gettext (String)
373 #define gettext_noop(String) String
374 #define N_(String) gettext_noop (String)
375 #else
376 #define _(String) String
377 #define N_(String) String
378 #define gettext(String) String
379 #endif
380