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