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