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