rnd-20070404-2-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 magic_wall_active;
149   int magic_wall_time_left;
150   int light_time_left;
151   int timegate_time_left;
152   int belt_dir[4];
153   int belt_dir_nr[4];
154   int switchgate_pos;
155   int wind_direction;
156   boolean gravity;
157   boolean explosions_delayed;
158   boolean envelope_active;
159
160   /* values for the new EMC elements */
161   int lenses_time_left;
162   int magnify_time_left;
163   boolean ball_state;
164   int ball_content_nr;
165
166   /* values for player idle animation (no effect on engine) */
167   int player_boring_delay_fixed;
168   int player_boring_delay_random;
169   int player_sleeping_delay_fixed;
170   int player_sleeping_delay_random;
171
172   /* values for special game initialization control */
173   boolean restart_level;
174
175   /* values for special game control */
176   int centered_player_nr;
177   int centered_player_nr_next;
178   boolean set_centered_player;
179
180   /* values for random number generator initialization after snapshot */
181   unsigned long num_random_calls;
182 };
183
184 struct PlayerInfo
185 {
186   boolean present;              /* player present in level playfield */
187   boolean connected;            /* player connected (locally or via network) */
188   boolean active;               /* player present and connected */
189   boolean killed;               /* player maybe present/active, but killed */
190
191   int index_nr;                 /* player number (0 to 3) */
192   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
193   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
194   int client_nr;                /* network client identifier */
195
196   byte action;                  /* action from local input device */
197   byte effective_action;        /* action acknowledged from network server
198                                    or summarized over all configured input
199                                    devices when in single player mode */
200   byte programmed_action;       /* action forced by game itself (like moving
201                                    through doors); overrides other actions */
202
203   int jx, jy, last_jx, last_jy;
204   int MovDir, MovPos, GfxDir, GfxPos;
205   int Frame, StepFrame;
206
207   int GfxAction;
208
209   boolean use_murphy;
210   int artwork_element;
211
212   boolean block_last_field;
213   int block_delay_adjustment;   /* needed for different engine versions */
214
215   boolean can_fall_into_acid;
216
217   boolean gravity;
218
219   boolean LevelSolved, GameOver;
220
221   boolean LevelSolved_GameWon;
222   boolean LevelSolved_GameEnd;
223   boolean LevelSolved_PanelOff;
224   boolean LevelSolved_SaveTape;
225   boolean LevelSolved_SaveScore;
226
227   int last_move_dir;
228
229   boolean is_active;
230
231   boolean is_waiting;
232   boolean is_moving;
233   boolean is_auto_moving;
234   boolean is_digging;
235   boolean is_snapping;
236   boolean is_collecting;
237   boolean is_pushing;
238   boolean is_switching;
239   boolean is_dropping;
240   boolean is_dropping_pressed;
241
242   boolean is_bored;
243   boolean is_sleeping;
244
245   boolean cannot_move;
246
247   int frame_counter_bored;
248   int frame_counter_sleeping;
249
250   int anim_delay_counter;
251   int post_delay_counter;
252
253   int dir_waiting;
254   int action_waiting, last_action_waiting;
255   int special_action_bored;
256   int special_action_sleeping;
257
258   int num_special_action_bored;
259   int num_special_action_sleeping;
260
261   int switch_x, switch_y;
262   int drop_x, drop_y;
263
264   int show_envelope;
265
266   int move_delay;
267   int move_delay_value;
268   int move_delay_value_next;
269   int move_delay_reset_counter;
270
271   int push_delay;
272   int push_delay_value;
273
274   unsigned long actual_frame_counter;
275
276   int drop_delay;
277   int drop_pressed_delay;
278
279   int step_counter;
280
281   int score;
282   int score_final;
283
284   int gems_still_needed;
285   int sokobanfields_still_needed;
286   int lights_still_needed;
287   int friends_still_needed;
288   int key[MAX_NUM_KEYS];
289   int num_white_keys;
290   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
291   int shield_normal_time_left;
292   int shield_deadly_time_left;
293
294   int inventory_element[MAX_INVENTORY_SIZE];
295   int inventory_infinite_element;
296   int inventory_size;
297 };
298
299 extern struct GameInfo          game;
300 extern struct PlayerInfo        stored_player[MAX_PLAYERS], *local_player;
301
302
303 #ifdef DEBUG
304 void DEBUG_SetMaximumDynamite();
305 #endif
306
307 void GetPlayerConfig(void);
308 int GetElementFromGroupElement(int);
309
310 void DrawGameValue_Time(int);
311 void DrawGameDoorValues(void);
312
313 void InitGameSound();
314 void InitGame();
315
316 void UpdateEngineValues(int, int);
317 void GameWon(void);
318 void GameEnd(void);
319
320 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
321 void Moving2Blocked(int, int, int *, int *);
322 void Blocked2Moving(int, int, int *, int *);
323 void DrawDynamite(int, int);
324
325 void StartGameActions(boolean, boolean, long);
326
327 void GameActions(void);
328 void GameActions_EM_Main();
329 void GameActions_RND();
330
331 void ScrollLevel(int, int);
332
333 void InitPlayLevelSound();
334 void PlayLevelSound_EM(int, int, int, int);
335
336 void RaiseScore(int);
337 void RaiseScoreElement(int);
338
339 void RequestQuitGameExt(boolean, boolean, char *);
340 void RequestQuitGame(boolean);
341
342 unsigned int InitEngineRandom_RND(long);
343 unsigned int RND(int);
344
345 void FreeEngineSnapshot();
346 void LoadEngineSnapshot();
347 void SaveEngineSnapshot();
348 boolean CheckEngineSnapshot();
349
350 void CreateGameButtons();
351 void FreeGameButtons();
352 void UnmapGameButtons();
353
354 #endif