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