rnd-20070312-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 #define STD_NUM_KEYS            4
22 #define MAX_NUM_KEYS            8
23
24
25 #if 1
26 struct GamePanelInfo
27 {
28   struct TextPosInfo level;
29   struct TextPosInfo gems;
30   struct TextPosInfo inventory;
31   struct TextPosInfo keys;
32   struct TextPosInfo score;
33   struct TextPosInfo time;
34
35   struct TextPosInfo time_hh;
36   struct TextPosInfo time_mm;
37   struct TextPosInfo time_ss;
38   struct TextPosInfo drop_next_1;
39   struct TextPosInfo drop_next_2;
40   struct TextPosInfo drop_next_3;
41   struct TextPosInfo drop_next_4;
42   struct TextPosInfo drop_next_5;
43   struct TextPosInfo drop_next_6;
44   struct TextPosInfo drop_next_7;
45   struct TextPosInfo drop_next_8;
46   struct TextPosInfo emc_keys;
47   struct TextPosInfo key_1;
48   struct TextPosInfo key_2;
49   struct TextPosInfo key_3;
50   struct TextPosInfo key_4;
51   struct TextPosInfo key_5;
52   struct TextPosInfo key_6;
53   struct TextPosInfo key_7;
54   struct TextPosInfo key_8;
55   struct TextPosInfo key_white;
56   struct TextPosInfo key_white_count;
57   struct TextPosInfo shield_normal;
58   struct TextPosInfo shield_normal_time;
59   struct TextPosInfo shield_deadly;
60   struct TextPosInfo shield_deadly_time;
61   struct TextPosInfo exit;
62   struct TextPosInfo em_exit;
63   struct TextPosInfo sp_exit;
64   struct TextPosInfo steel_exit;
65   struct TextPosInfo em_steel_exit;
66   struct TextPosInfo emc_magic_ball;
67   struct TextPosInfo emc_magic_ball_switch;
68   struct TextPosInfo emc_magic_ball_time;
69   struct TextPosInfo light_switch;
70   struct TextPosInfo light_switch_time;
71   struct TextPosInfo timegate_switch;
72   struct TextPosInfo timegate_switch_time;
73   struct TextPosInfo switchgate_switch;
74   struct TextPosInfo emc_lenses;
75   struct TextPosInfo emc_lenses_time;
76   struct TextPosInfo emc_magnifier;
77   struct TextPosInfo emc_magnifier_time;
78   struct TextPosInfo balloon_switch;
79   struct TextPosInfo dynabomb_number;
80   struct TextPosInfo dynabomb_size;
81   struct TextPosInfo dynabomb_power;
82   struct TextPosInfo penguins;
83   struct TextPosInfo sokoban_objects;
84   struct TextPosInfo sokoban_fields;
85   struct TextPosInfo robot_wheel;
86   struct TextPosInfo conveyor_belt_1;
87   struct TextPosInfo conveyor_belt_1_switch;
88   struct TextPosInfo conveyor_belt_2;
89   struct TextPosInfo conveyor_belt_2_switch;
90   struct TextPosInfo conveyor_belt_3;
91   struct TextPosInfo conveyor_belt_3_switch;
92   struct TextPosInfo conveyor_belt_4;
93   struct TextPosInfo conveyor_belt_4_switch;
94   struct TextPosInfo magic_wall;
95   struct TextPosInfo magic_wall_time;
96   struct TextPosInfo bd_magic_wall;
97   struct TextPosInfo dc_magic_wall;
98   struct TextPosInfo player_name;
99   struct TextPosInfo level_name;
100   struct TextPosInfo level_author;
101 };
102
103 struct GameButtonInfo
104 {
105   struct MenuPosInfo stop;
106   struct MenuPosInfo pause;
107   struct MenuPosInfo play;
108   struct MenuPosInfo sound_music;
109   struct MenuPosInfo sound_loops;
110   struct MenuPosInfo sound_simple;
111 };
112
113 #else
114
115 struct GamePanelInfo
116 {
117   struct XY level;
118   struct XY gems;
119   struct XY inventory;
120   struct XY keys;
121   struct XY score;
122   struct XY time;
123 };
124 #endif
125
126 struct GameInfo
127 {
128   /* values for control panel */
129   struct GamePanelInfo panel;
130   struct GameButtonInfo button;
131
132   /* values for engine initialization */
133   int default_push_delay_fixed;
134   int default_push_delay_random;
135
136   /* constant within running game */
137   int engine_version;
138   int emulation;
139   int initial_move_delay[MAX_PLAYERS];
140   int initial_move_delay_value[MAX_PLAYERS];
141   int initial_push_delay_value;
142
143   /* flags to handle bugs in and changes between different engine versions */
144   /* (for the latest engine version, these flags should always be "FALSE") */
145   boolean use_change_when_pushing_bug;
146   boolean use_block_last_field_bug;
147   boolean max_num_changes_per_frame;
148   boolean use_reverse_scan_direction;
149
150   /* variable within running game */
151   int yamyam_content_nr;
152   boolean magic_wall_active;
153   int magic_wall_time_left;
154   int light_time_left;
155   int timegate_time_left;
156   int belt_dir[4];
157   int belt_dir_nr[4];
158   int switchgate_pos;
159   int wind_direction;
160   boolean gravity;
161   boolean explosions_delayed;
162   boolean envelope_active;
163
164   /* values for the new EMC elements */
165   int lenses_time_left;
166   int magnify_time_left;
167   boolean ball_state;
168   int ball_content_nr;
169
170   /* values for player idle animation (no effect on engine) */
171   int player_boring_delay_fixed;
172   int player_boring_delay_random;
173   int player_sleeping_delay_fixed;
174   int player_sleeping_delay_random;
175
176   /* values for special game initialization control */
177   boolean restart_level;
178
179   /* values for special game control */
180   int centered_player_nr;
181   int centered_player_nr_next;
182   boolean set_centered_player;
183
184   /* values for random number generator initialization after snapshot */
185   unsigned long num_random_calls;
186 };
187
188 struct PlayerInfo
189 {
190   boolean present;              /* player present in level playfield */
191   boolean connected;            /* player connected (locally or via network) */
192   boolean active;               /* player present and connected */
193   boolean killed;               /* player maybe present/active, but killed */
194
195   int index_nr;                 /* player number (0 to 3) */
196   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
197   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
198   int client_nr;                /* network client identifier */
199
200   byte action;                  /* action from local input device */
201   byte effective_action;        /* action acknowledged from network server
202                                    or summarized over all configured input
203                                    devices when in single player mode */
204   byte programmed_action;       /* action forced by game itself (like moving
205                                    through doors); overrides other actions */
206
207   int jx, jy, last_jx, last_jy;
208   int MovDir, MovPos, GfxDir, GfxPos;
209   int Frame, StepFrame;
210
211   int GfxAction;
212
213   boolean use_murphy;
214   int artwork_element;
215
216   boolean block_last_field;
217   int block_delay_adjustment;   /* needed for different engine versions */
218
219   boolean can_fall_into_acid;
220
221   boolean gravity;
222
223   boolean LevelSolved, GameOver;
224
225   boolean LevelSolved_GameWon;
226   boolean LevelSolved_GameEnd;
227   boolean LevelSolved_PanelOff;
228   boolean LevelSolved_SaveTape;
229   boolean LevelSolved_SaveScore;
230
231   int last_move_dir;
232
233   boolean is_active;
234
235   boolean is_waiting;
236   boolean is_moving;
237   boolean is_auto_moving;
238   boolean is_digging;
239   boolean is_snapping;
240   boolean is_collecting;
241   boolean is_pushing;
242   boolean is_switching;
243   boolean is_dropping;
244   boolean is_dropping_pressed;
245
246   boolean is_bored;
247   boolean is_sleeping;
248
249   boolean cannot_move;
250
251   int frame_counter_bored;
252   int frame_counter_sleeping;
253
254   int anim_delay_counter;
255   int post_delay_counter;
256
257   int dir_waiting;
258   int action_waiting, last_action_waiting;
259   int special_action_bored;
260   int special_action_sleeping;
261
262   int num_special_action_bored;
263   int num_special_action_sleeping;
264
265   int switch_x, switch_y;
266   int drop_x, drop_y;
267
268   int show_envelope;
269
270   int move_delay;
271   int move_delay_value;
272   int move_delay_value_next;
273   int move_delay_reset_counter;
274
275   int push_delay;
276   int push_delay_value;
277
278   unsigned long actual_frame_counter;
279
280   int drop_delay;
281   int drop_pressed_delay;
282
283   int step_counter;
284
285   int score;
286   int score_final;
287
288   int gems_still_needed;
289   int sokobanfields_still_needed;
290   int lights_still_needed;
291   int friends_still_needed;
292   int key[MAX_NUM_KEYS];
293   int num_white_keys;
294   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
295   int shield_normal_time_left;
296   int shield_deadly_time_left;
297
298   int inventory_element[MAX_INVENTORY_SIZE];
299   int inventory_infinite_element;
300   int inventory_size;
301 };
302
303 extern struct GameInfo          game;
304 extern struct PlayerInfo        stored_player[MAX_PLAYERS], *local_player;
305
306
307 #ifdef DEBUG
308 void DEBUG_SetMaximumDynamite();
309 #endif
310
311 void GetPlayerConfig(void);
312 int GetElementFromGroupElement(int);
313
314 void DrawGameValue_Time(int);
315 void DrawGameDoorValues(void);
316
317 void InitGameSound();
318 void InitGame();
319
320 void UpdateEngineValues(int, int);
321 void GameWon(void);
322 void GameEnd(void);
323
324 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
325 void Moving2Blocked(int, int, int *, int *);
326 void Blocked2Moving(int, int, int *, int *);
327 void DrawDynamite(int, int);
328
329 void StartGameActions(boolean, boolean, long);
330
331 void GameActions(void);
332 void GameActions_EM_Main();
333 void GameActions_RND();
334
335 void ScrollLevel(int, int);
336
337 void InitPlayLevelSound();
338 void PlayLevelSound_EM(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(long);
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 UnmapGameButtons();
357
358 #endif