removed unused fields from structure definition
[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 MAX_HEALTH                      100
21
22 #define STD_NUM_KEYS                    4
23 #define MAX_NUM_KEYS                    8
24
25 #define NUM_BELTS                       4
26 #define NUM_BELT_PARTS                  3
27
28 #define NUM_PANEL_INVENTORY             8
29 #define NUM_PANEL_GRAPHICS              8
30 #define NUM_PANEL_ELEMENTS              8
31 #define NUM_PANEL_CE_SCORE              8
32
33 #define STR_SNAPSHOT_MODE_OFF           "off"
34 #define STR_SNAPSHOT_MODE_EVERY_STEP    "every_step"
35 #define STR_SNAPSHOT_MODE_EVERY_MOVE    "every_move"
36 #define STR_SNAPSHOT_MODE_EVERY_COLLECT "every_collect"
37 #define STR_SNAPSHOT_MODE_DEFAULT       STR_SNAPSHOT_MODE_OFF
38
39 #define SNAPSHOT_MODE_OFF               0
40 #define SNAPSHOT_MODE_EVERY_STEP        1
41 #define SNAPSHOT_MODE_EVERY_MOVE        2
42 #define SNAPSHOT_MODE_EVERY_COLLECT     3
43 #define SNAPSHOT_MODE_DEFAULT           SNAPSHOT_MODE_OFF
44
45
46 struct GamePanelInfo
47 {
48   struct TextPosInfo level_number;
49   struct TextPosInfo gems;
50   struct TextPosInfo inventory_count;
51   struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
52   struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
53   struct TextPosInfo key[MAX_NUM_KEYS];
54   struct TextPosInfo key_white;
55   struct TextPosInfo key_white_count;
56   struct TextPosInfo score;
57   struct TextPosInfo highscore;
58   struct TextPosInfo time;
59   struct TextPosInfo time_hh;
60   struct TextPosInfo time_mm;
61   struct TextPosInfo time_ss;
62   struct TextPosInfo time_anim;
63   struct TextPosInfo health;
64   struct TextPosInfo health_anim;
65   struct TextPosInfo frame;
66   struct TextPosInfo shield_normal;
67   struct TextPosInfo shield_normal_time;
68   struct TextPosInfo shield_deadly;
69   struct TextPosInfo shield_deadly_time;
70   struct TextPosInfo exit;
71   struct TextPosInfo emc_magic_ball;
72   struct TextPosInfo emc_magic_ball_switch;
73   struct TextPosInfo light_switch;
74   struct TextPosInfo light_switch_time;
75   struct TextPosInfo timegate_switch;
76   struct TextPosInfo timegate_switch_time;
77   struct TextPosInfo switchgate_switch;
78   struct TextPosInfo emc_lenses;
79   struct TextPosInfo emc_lenses_time;
80   struct TextPosInfo emc_magnifier;
81   struct TextPosInfo emc_magnifier_time;
82   struct TextPosInfo balloon_switch;
83   struct TextPosInfo dynabomb_number;
84   struct TextPosInfo dynabomb_size;
85   struct TextPosInfo dynabomb_power;
86   struct TextPosInfo penguins;
87   struct TextPosInfo sokoban_objects;
88   struct TextPosInfo sokoban_fields;
89   struct TextPosInfo robot_wheel;
90   struct TextPosInfo conveyor_belt[NUM_BELTS];
91   struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
92   struct TextPosInfo magic_wall;
93   struct TextPosInfo magic_wall_time;
94   struct TextPosInfo gravity_state;
95   struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
96   struct TextPosInfo element[NUM_PANEL_ELEMENTS];
97   struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
98   struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
99   struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
100   struct TextPosInfo player_name;
101   struct TextPosInfo level_name;
102   struct TextPosInfo level_author;
103 };
104
105 struct GameButtonInfo
106 {
107   struct XY stop;
108   struct XY pause;
109   struct XY play;
110
111   struct XY undo;
112   struct XY redo;
113
114   struct XY save;
115   struct XY pause2;
116   struct XY load;
117
118   struct XY sound_music;
119   struct XY sound_loops;
120   struct XY sound_simple;
121
122   struct XY panel_stop;
123   struct XY panel_pause;
124   struct XY panel_play;
125
126   struct XY panel_sound_music;
127   struct XY panel_sound_loops;
128   struct XY panel_sound_simple;
129 };
130
131 struct GameSnapshotInfo
132 {
133   int mode;
134
135   byte last_action[MAX_PLAYERS];
136   boolean changed_action;
137   boolean collected_item;
138
139   boolean save_snapshot;
140 };
141
142 struct GameInfo
143 {
144   /* values for control panel */
145   struct GamePanelInfo panel;
146   struct GameButtonInfo button;
147
148   /* values for graphics engine customization */
149   int graphics_engine_version;
150   boolean use_native_emc_graphics_engine;
151   boolean use_native_sp_graphics_engine;
152   boolean use_masked_pushing;
153   int forced_scroll_delay_value;
154   int scroll_delay_value;
155   int tile_size;
156
157   /* constant within running game */
158   int engine_version;
159   int emulation;
160   int initial_move_delay[MAX_PLAYERS];
161   int initial_move_delay_value[MAX_PLAYERS];
162   int initial_push_delay_value;
163
164   /* flag for single or multi-player mode (needed for playing tapes) */
165   /* (when playing/recording games, this is identical to "setup.team_mode" */
166   boolean team_mode;
167
168   /* flags to handle bugs in and changes between different engine versions */
169   /* (for the latest engine version, these flags should always be "FALSE") */
170   boolean use_change_when_pushing_bug;
171   boolean use_block_last_field_bug;
172   boolean max_num_changes_per_frame;
173   boolean use_reverse_scan_direction;
174
175   /* variable within running game */
176   int yamyam_content_nr;
177   boolean robot_wheel_active;
178   boolean magic_wall_active;
179   int magic_wall_time_left;
180   int light_time_left;
181   int timegate_time_left;
182   int belt_dir[4];
183   int belt_dir_nr[4];
184   int switchgate_pos;
185   int wind_direction;
186   boolean explosions_delayed;
187   boolean envelope_active;
188   boolean no_time_limit;        /* (variable only in very special case) */
189
190   /* values for the new EMC elements */
191   int lenses_time_left;
192   int magnify_time_left;
193   boolean ball_state;
194   int ball_content_nr;
195
196   /* values for player idle animation (no effect on engine) */
197   int player_boring_delay_fixed;
198   int player_boring_delay_random;
199   int player_sleeping_delay_fixed;
200   int player_sleeping_delay_random;
201
202   /* values for special game initialization control */
203   boolean restart_level;
204
205   /* trigger message to ask for restarting the game */
206   char *restart_game_message;
207
208   /* values for special game control */
209   int centered_player_nr;
210   int centered_player_nr_next;
211   boolean set_centered_player;
212
213   /* values for random number generator initialization after snapshot */
214   unsigned int num_random_calls;
215
216   /* values for game engine snapshot control */
217   struct GameSnapshotInfo snapshot;
218 };
219
220 struct PlayerInfo
221 {
222   boolean present;              /* player present in level playfield */
223   boolean connected_locally;    /* player connected (locally) */
224   boolean connected_network;    /* player connected (network) */
225   boolean connected;            /* player connected (locally or via network) */
226   boolean active;               /* player present and connected */
227   boolean mapped;               /* player already mapped to input device */
228
229   boolean killed;               /* player maybe present/active, but killed */
230   boolean reanimated;           /* player maybe killed, but reanimated */
231
232   int index_nr;                 /* player number (0 to 3) */
233   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
234   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
235   int client_nr;                /* network client identifier */
236
237   byte action;                  /* action from local input device */
238   byte mapped_action;           /* action mapped from device to player */
239   byte effective_action;        /* action acknowledged from network server
240                                    or summarized over all configured input
241                                    devices when in single player mode */
242   byte programmed_action;       /* action forced by game itself (like moving
243                                    through doors); overrides other actions */
244
245   struct MouseActionInfo mouse_action;           /* (used by MM engine only) */
246   struct MouseActionInfo effective_mouse_action; /* (used by MM engine only) */
247
248   int jx, jy, last_jx, last_jy;
249   int MovDir, MovPos, GfxDir, GfxPos;
250   int Frame, StepFrame;
251
252   int GfxAction;
253
254   int initial_element;          /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
255   int artwork_element;
256   boolean use_murphy;
257
258   boolean block_last_field;
259   int block_delay_adjustment;   /* needed for different engine versions */
260
261   boolean can_fall_into_acid;
262
263   boolean gravity;
264
265   boolean LevelSolved, GameOver;
266
267   boolean LevelSolved_GameWon;
268   boolean LevelSolved_GameEnd;
269   boolean LevelSolved_PanelOff;
270   boolean LevelSolved_SaveTape;
271   boolean LevelSolved_SaveScore;
272
273   int LevelSolved_CountingTime;
274   int LevelSolved_CountingScore;
275   int LevelSolved_CountingHealth;
276
277   int last_move_dir;
278
279   boolean is_active;
280
281   boolean is_waiting;
282   boolean is_moving;
283   boolean is_auto_moving;
284   boolean is_digging;
285   boolean is_snapping;
286   boolean is_collecting;
287   boolean is_pushing;
288   boolean is_switching;
289   boolean is_dropping;
290   boolean is_dropping_pressed;
291
292   boolean is_bored;
293   boolean is_sleeping;
294
295   boolean was_waiting;
296   boolean was_moving;
297   boolean was_snapping;
298   boolean was_dropping;
299
300   boolean cannot_move;
301
302   boolean force_dropping;       /* needed for single step mode */
303
304   int frame_counter_bored;
305   int frame_counter_sleeping;
306
307   int anim_delay_counter;
308   int post_delay_counter;
309
310   int dir_waiting;
311   int action_waiting, last_action_waiting;
312   int special_action_bored;
313   int special_action_sleeping;
314
315   int num_special_action_bored;
316   int num_special_action_sleeping;
317
318   int switch_x, switch_y;
319   int drop_x, drop_y;
320
321   int show_envelope;
322
323   int move_delay;
324   int move_delay_value;
325   int move_delay_value_next;
326   int move_delay_reset_counter;
327
328   int push_delay;
329   int push_delay_value;
330
331   unsigned int actual_frame_counter;
332
333   int drop_delay;
334   int drop_pressed_delay;
335
336   int step_counter;
337
338   int score;
339   int score_final;
340
341   int health;
342   int health_final;
343
344   int gems_still_needed;
345   int sokobanfields_still_needed;
346   int lights_still_needed;
347   int players_still_needed;
348   int friends_still_needed;
349   int key[MAX_NUM_KEYS];
350   int num_white_keys;
351   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
352   int shield_normal_time_left;
353   int shield_deadly_time_left;
354
355   int inventory_element[MAX_INVENTORY_SIZE];
356   int inventory_infinite_element;
357   int inventory_size;
358 };
359
360 extern struct GameInfo          game;
361 extern struct PlayerInfo        stored_player[MAX_PLAYERS], *local_player;
362
363
364 #ifdef DEBUG
365 void DEBUG_SetMaximumDynamite();
366 #endif
367
368 void GetPlayerConfig(void);
369 int GetElementFromGroupElement(int);
370
371 int getPlayerInventorySize(int);
372
373 void DrawGameValue_Time(int);
374 void DrawGameDoorValues(void);
375
376 void UpdateAndDisplayGameControlValues();
377
378 void InitGameSound();
379 void InitGame();
380
381 void UpdateEngineValues(int, int, int, int);
382 void GameWon(void);
383 void GameEnd(void);
384
385 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
386 void Moving2Blocked(int, int, int *, int *);
387 void Blocked2Moving(int, int, int *, int *);
388 void DrawDynamite(int, int);
389
390 void StartGameActions(boolean, boolean, int);
391
392 void GameActions(void);
393 void GameActions_EM_Main();
394 void GameActions_SP_Main();
395 void GameActions_MM_Main();
396 void GameActions_RND_Main();
397 void GameActions_RND();
398
399 void ScrollLevel(int, int);
400
401 void InitPlayLevelSound();
402 void PlayLevelSound_EM(int, int, int, int);
403 void PlayLevelSound_SP(int, int, int, int);
404 void PlayLevelSound_MM(int, int, int, int);
405 void PlaySound_MM(int);
406 void PlaySoundLoop_MM(int);
407 void StopSound_MM(int);
408
409 void RaiseScore(int);
410 void RaiseScoreElement(int);
411
412 void RequestQuitGameExt(boolean, boolean, char *);
413 void RequestQuitGame(boolean);
414 void RequestRestartGame(char *);
415
416 unsigned int InitEngineRandom_RND(int);
417 unsigned int RND(int);
418
419 void FreeEngineSnapshotSingle();
420 void FreeEngineSnapshotList();
421 void LoadEngineSnapshotSingle();
422 void SaveEngineSnapshotSingle();
423 boolean CheckSaveEngineSnapshotToList();
424 void SaveEngineSnapshotToList();
425 void SaveEngineSnapshotToListInitial();
426 boolean CheckEngineSnapshotSingle();
427 boolean CheckEngineSnapshotList();
428
429 void CreateGameButtons();
430 void FreeGameButtons();
431 void MapUndoRedoButtons();
432 void UnmapUndoRedoButtons();
433 void MapGameButtons();
434 void UnmapGameButtons();
435 void RedrawGameButtons();
436 void MapGameButtonsOnTape();
437 void UnmapGameButtonsOnTape();
438 void RedrawGameButtonsOnTape();
439
440 void HandleSoundButtonKeys(Key);
441
442 #endif