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