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