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