major cleanup of preprocessor hell
[rocksndiamonds.git] / src / game.h
1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
5 //                  Holger Schemel
6 //                  info@artsoft.org
7 //                  http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
9 // game.h
10 // ============================================================================
11
12 #ifndef GAME_H
13 #define GAME_H
14
15 /* (not included here due to collisions with Emerald Mine engine definitions) */
16 /* #include "main.h" */
17
18 #define MAX_INVENTORY_SIZE      1000
19
20 #define STD_NUM_KEYS            4
21 #define MAX_NUM_KEYS            8
22
23 #define NUM_BELTS               4
24 #define NUM_BELT_PARTS          3
25
26 #define NUM_PANEL_INVENTORY     8
27 #define NUM_PANEL_GRAPHICS      8
28 #define NUM_PANEL_ELEMENTS      8
29 #define NUM_PANEL_CE_SCORE      8
30
31 struct GamePanelInfo
32 {
33   struct TextPosInfo level_number;
34   struct TextPosInfo gems;
35   struct TextPosInfo inventory_count;
36   struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
37   struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
38   struct TextPosInfo key[MAX_NUM_KEYS];
39   struct TextPosInfo key_white;
40   struct TextPosInfo key_white_count;
41   struct TextPosInfo score;
42   struct TextPosInfo highscore;
43   struct TextPosInfo time;
44   struct TextPosInfo time_hh;
45   struct TextPosInfo time_mm;
46   struct TextPosInfo time_ss;
47   struct TextPosInfo frame;
48   struct TextPosInfo shield_normal;
49   struct TextPosInfo shield_normal_time;
50   struct TextPosInfo shield_deadly;
51   struct TextPosInfo shield_deadly_time;
52   struct TextPosInfo exit;
53   struct TextPosInfo emc_magic_ball;
54   struct TextPosInfo emc_magic_ball_switch;
55   struct TextPosInfo light_switch;
56   struct TextPosInfo light_switch_time;
57   struct TextPosInfo timegate_switch;
58   struct TextPosInfo timegate_switch_time;
59   struct TextPosInfo switchgate_switch;
60   struct TextPosInfo emc_lenses;
61   struct TextPosInfo emc_lenses_time;
62   struct TextPosInfo emc_magnifier;
63   struct TextPosInfo emc_magnifier_time;
64   struct TextPosInfo balloon_switch;
65   struct TextPosInfo dynabomb_number;
66   struct TextPosInfo dynabomb_size;
67   struct TextPosInfo dynabomb_power;
68   struct TextPosInfo penguins;
69   struct TextPosInfo sokoban_objects;
70   struct TextPosInfo sokoban_fields;
71   struct TextPosInfo robot_wheel;
72   struct TextPosInfo conveyor_belt[NUM_BELTS];
73   struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
74   struct TextPosInfo magic_wall;
75   struct TextPosInfo magic_wall_time;
76   struct TextPosInfo gravity_state;
77   struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
78   struct TextPosInfo element[NUM_PANEL_ELEMENTS];
79   struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
80   struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
81   struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
82   struct TextPosInfo player_name;
83   struct TextPosInfo level_name;
84   struct TextPosInfo level_author;
85 };
86
87 struct GameButtonInfo
88 {
89   struct Rect stop;
90   struct Rect pause;
91   struct Rect play;
92
93   struct Rect sound_music;
94   struct Rect sound_loops;
95   struct Rect sound_simple;
96
97   struct Rect save;
98   struct Rect load;
99 };
100
101 struct GameInfo
102 {
103   /* values for control panel */
104   struct GamePanelInfo panel;
105   struct GameButtonInfo button;
106
107   /* values for graphics engine customization */
108   boolean use_native_emc_graphics_engine;
109   boolean use_native_sp_graphics_engine;
110   boolean use_masked_pushing;
111   int forced_scroll_delay_value;
112   int scroll_delay_value;
113   int tile_size;
114
115   /* values for engine initialization */
116   int default_push_delay_fixed;
117   int default_push_delay_random;
118
119   /* constant within running game */
120   int engine_version;
121   int emulation;
122   int initial_move_delay[MAX_PLAYERS];
123   int initial_move_delay_value[MAX_PLAYERS];
124   int initial_push_delay_value;
125
126   /* flag for single or multi-player mode (needed for playing tapes) */
127   /* (when playing/recording games, this is identical to "setup.team_mode" */
128   boolean team_mode;
129
130   /* flags to handle bugs in and changes between different engine versions */
131   /* (for the latest engine version, these flags should always be "FALSE") */
132   boolean use_change_when_pushing_bug;
133   boolean use_block_last_field_bug;
134   boolean max_num_changes_per_frame;
135   boolean use_reverse_scan_direction;
136
137   /* variable within running game */
138   int yamyam_content_nr;
139   boolean robot_wheel_active;
140   boolean magic_wall_active;
141   int magic_wall_time_left;
142   int light_time_left;
143   int timegate_time_left;
144   int belt_dir[4];
145   int belt_dir_nr[4];
146   int switchgate_pos;
147   int wind_direction;
148   boolean gravity;
149   boolean explosions_delayed;
150   boolean envelope_active;
151   boolean no_time_limit;        /* (variable only in very special case) */
152
153   /* values for the new EMC elements */
154   int lenses_time_left;
155   int magnify_time_left;
156   boolean ball_state;
157   int ball_content_nr;
158
159   /* values for player idle animation (no effect on engine) */
160   int player_boring_delay_fixed;
161   int player_boring_delay_random;
162   int player_sleeping_delay_fixed;
163   int player_sleeping_delay_random;
164
165   /* values for special game initialization control */
166   boolean restart_level;
167
168   /* values for special game control */
169   int centered_player_nr;
170   int centered_player_nr_next;
171   boolean set_centered_player;
172
173   /* values for random number generator initialization after snapshot */
174   unsigned int num_random_calls;
175 };
176
177 struct PlayerInfo
178 {
179   boolean present;              /* player present in level playfield */
180   boolean connected;            /* player connected (locally or via network) */
181   boolean active;               /* player present and connected */
182   boolean mapped;               /* player already mapped to input device */
183
184   boolean killed;               /* player maybe present/active, but killed */
185   boolean reanimated;           /* player maybe killed, but reanimated */
186
187   int index_nr;                 /* player number (0 to 3) */
188   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
189   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
190   int client_nr;                /* network client identifier */
191
192   byte action;                  /* action from local input device */
193   byte mapped_action;           /* action mapped from device to player */
194   byte effective_action;        /* action acknowledged from network server
195                                    or summarized over all configured input
196                                    devices when in single player mode */
197   byte programmed_action;       /* action forced by game itself (like moving
198                                    through doors); overrides other actions */
199
200   int jx, jy, last_jx, last_jy;
201   int MovDir, MovPos, GfxDir, GfxPos;
202   int Frame, StepFrame;
203
204   int GfxAction;
205
206   int initial_element;          /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
207   int artwork_element;
208   boolean use_murphy;
209
210   boolean block_last_field;
211   int block_delay_adjustment;   /* needed for different engine versions */
212
213   boolean can_fall_into_acid;
214
215   boolean gravity;
216
217   boolean LevelSolved, GameOver;
218
219   boolean LevelSolved_GameWon;
220   boolean LevelSolved_GameEnd;
221   boolean LevelSolved_PanelOff;
222   boolean LevelSolved_SaveTape;
223   boolean LevelSolved_SaveScore;
224   int LevelSolved_CountingTime;
225   int LevelSolved_CountingScore;
226
227   int last_move_dir;
228
229   boolean is_active;
230
231   boolean is_waiting;
232   boolean is_moving;
233   boolean is_auto_moving;
234   boolean is_digging;
235   boolean is_snapping;
236   boolean is_collecting;
237   boolean is_pushing;
238   boolean is_switching;
239   boolean is_dropping;
240   boolean is_dropping_pressed;
241
242   boolean is_bored;
243   boolean is_sleeping;
244
245   boolean cannot_move;
246
247   int frame_counter_bored;
248   int frame_counter_sleeping;
249
250   int anim_delay_counter;
251   int post_delay_counter;
252
253   int dir_waiting;
254   int action_waiting, last_action_waiting;
255   int special_action_bored;
256   int special_action_sleeping;
257
258   int num_special_action_bored;
259   int num_special_action_sleeping;
260
261   int switch_x, switch_y;
262   int drop_x, drop_y;
263
264   int show_envelope;
265
266   int move_delay;
267   int move_delay_value;
268   int move_delay_value_next;
269   int move_delay_reset_counter;
270
271   int push_delay;
272   int push_delay_value;
273
274   unsigned int actual_frame_counter;
275
276   int drop_delay;
277   int drop_pressed_delay;
278
279   int step_counter;
280
281   int score;
282   int score_final;
283
284   int gems_still_needed;
285   int sokobanfields_still_needed;
286   int lights_still_needed;
287   int friends_still_needed;
288   int key[MAX_NUM_KEYS];
289   int num_white_keys;
290   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
291   int shield_normal_time_left;
292   int shield_deadly_time_left;
293
294   int inventory_element[MAX_INVENTORY_SIZE];
295   int inventory_infinite_element;
296   int inventory_size;
297 };
298
299 extern struct GameInfo          game;
300 extern struct PlayerInfo        stored_player[MAX_PLAYERS], *local_player;
301
302
303 #ifdef DEBUG
304 void DEBUG_SetMaximumDynamite();
305 #endif
306
307 void GetPlayerConfig(void);
308 int GetElementFromGroupElement(int);
309
310 void DrawGameValue_Time(int);
311 void DrawGameDoorValues(void);
312
313 void UpdateAndDisplayGameControlValues();
314
315 void InitGameSound();
316 void InitGame();
317
318 void UpdateEngineValues(int, int);
319 void GameWon(void);
320 void GameEnd(void);
321
322 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
323 void Moving2Blocked(int, int, int *, int *);
324 void Blocked2Moving(int, int, int *, int *);
325 void DrawDynamite(int, int);
326
327 void StartGameActions(boolean, boolean, int);
328
329 void GameActions(void);
330 void GameActions_EM_Main();
331 void GameActions_SP_Main();
332 void GameActions_RND();
333
334 void ScrollLevel(int, int);
335
336 void InitPlayLevelSound();
337 void PlayLevelSound_EM(int, int, int, int);
338 void PlayLevelSound_SP(int, int, int, int);
339
340 void RaiseScore(int);
341 void RaiseScoreElement(int);
342
343 void RequestQuitGameExt(boolean, boolean, char *);
344 void RequestQuitGame(boolean);
345
346 unsigned int InitEngineRandom_RND(int);
347 unsigned int RND(int);
348
349 void FreeEngineSnapshot();
350 void LoadEngineSnapshot();
351 void SaveEngineSnapshot();
352 boolean CheckEngineSnapshot();
353
354 void CreateGameButtons();
355 void FreeGameButtons();
356 void MapGameButtons();
357 void UnmapGameButtons();
358 void RedrawGameButtons();
359
360 void HandleSoundButtonKeys(Key);
361
362 #endif