1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment *
6 * Detmolder Strasse 189 *
9 * e-mail: info@artsoft.org *
10 *----------------------------------------------------------*
12 ***********************************************************/
17 /* (not included here due to collisions with Emerald Mine engine definitions) */
18 /* #include "main.h" */
20 #define MAX_INVENTORY_SIZE 1000
22 #define STD_NUM_KEYS 4
23 #define MAX_NUM_KEYS 8
26 #define NUM_BELT_PARTS 3
28 #define NUM_PANEL_INVENTORY 8
29 #define NUM_PANEL_GRAPHICS 8
30 #define NUM_PANEL_ELEMENTS 8
31 #define NUM_PANEL_CE_SCORE 8
36 struct TextPosInfo level_number;
37 struct TextPosInfo gems;
38 struct TextPosInfo inventory_count;
39 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
40 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
41 struct TextPosInfo key[MAX_NUM_KEYS];
42 struct TextPosInfo key_white;
43 struct TextPosInfo key_white_count;
44 struct TextPosInfo score;
45 struct TextPosInfo highscore;
46 struct TextPosInfo time;
47 struct TextPosInfo time_hh;
48 struct TextPosInfo time_mm;
49 struct TextPosInfo time_ss;
50 struct TextPosInfo frame;
51 struct TextPosInfo shield_normal;
52 struct TextPosInfo shield_normal_time;
53 struct TextPosInfo shield_deadly;
54 struct TextPosInfo shield_deadly_time;
55 struct TextPosInfo 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[NUM_BELTS];
76 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
77 struct TextPosInfo magic_wall;
78 struct TextPosInfo magic_wall_time;
79 struct TextPosInfo gravity_state;
80 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
81 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
82 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
83 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
84 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
85 struct TextPosInfo player_name;
86 struct TextPosInfo level_name;
87 struct TextPosInfo level_author;
95 struct Rect sound_music;
96 struct Rect sound_loops;
97 struct Rect sound_simple;
115 /* values for control panel */
116 struct GamePanelInfo panel;
117 struct GameButtonInfo button;
119 /* values for graphics engine customization */
120 boolean use_native_emc_graphics_engine;
121 boolean use_native_sp_graphics_engine;
122 boolean use_masked_pushing;
123 int forced_scroll_delay_value;
124 int scroll_delay_value;
127 /* values for engine initialization */
128 int default_push_delay_fixed;
129 int default_push_delay_random;
131 /* constant within running game */
134 int initial_move_delay[MAX_PLAYERS];
135 int initial_move_delay_value[MAX_PLAYERS];
136 int initial_push_delay_value;
138 /* flags to handle bugs in and changes between different engine versions */
139 /* (for the latest engine version, these flags should always be "FALSE") */
140 boolean use_change_when_pushing_bug;
141 boolean use_block_last_field_bug;
142 boolean max_num_changes_per_frame;
143 boolean use_reverse_scan_direction;
145 /* variable within running game */
146 int yamyam_content_nr;
147 boolean robot_wheel_active;
148 boolean magic_wall_active;
149 int magic_wall_time_left;
151 int timegate_time_left;
157 boolean explosions_delayed;
158 boolean envelope_active;
159 boolean no_time_limit; /* (variable only in very special case) */
161 /* values for the new EMC elements */
162 int lenses_time_left;
163 int magnify_time_left;
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;
173 /* values for special game initialization control */
174 boolean restart_level;
176 /* values for special game control */
177 int centered_player_nr;
178 int centered_player_nr_next;
179 boolean set_centered_player;
181 /* values for random number generator initialization after snapshot */
182 unsigned int num_random_calls;
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 mapped; /* player already mapped to input device */
192 boolean killed; /* player maybe present/active, but killed */
193 boolean reanimated; /* player maybe killed, but reanimated */
195 int index_nr; /* player number (0 to 3) */
196 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
197 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
198 int client_nr; /* network client identifier */
200 byte action; /* action from local input device */
201 byte mapped_action; /* action mapped from device to player */
202 byte effective_action; /* action acknowledged from network server
203 or summarized over all configured input
204 devices when in single player mode */
205 byte programmed_action; /* action forced by game itself (like moving
206 through doors); overrides other actions */
208 int jx, jy, last_jx, last_jy;
209 int MovDir, MovPos, GfxDir, GfxPos;
210 int Frame, StepFrame;
214 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
218 boolean block_last_field;
219 int block_delay_adjustment; /* needed for different engine versions */
221 boolean can_fall_into_acid;
225 boolean LevelSolved, GameOver;
227 boolean LevelSolved_GameWon;
228 boolean LevelSolved_GameEnd;
229 boolean LevelSolved_PanelOff;
230 boolean LevelSolved_SaveTape;
231 boolean LevelSolved_SaveScore;
232 int LevelSolved_CountingTime;
233 int LevelSolved_CountingScore;
241 boolean is_auto_moving;
244 boolean is_collecting;
246 boolean is_switching;
248 boolean is_dropping_pressed;
255 int frame_counter_bored;
256 int frame_counter_sleeping;
258 int anim_delay_counter;
259 int post_delay_counter;
262 int action_waiting, last_action_waiting;
263 int special_action_bored;
264 int special_action_sleeping;
266 int num_special_action_bored;
267 int num_special_action_sleeping;
269 int switch_x, switch_y;
275 int move_delay_value;
276 int move_delay_value_next;
277 int move_delay_reset_counter;
280 int push_delay_value;
282 unsigned int actual_frame_counter;
285 int drop_pressed_delay;
292 int gems_still_needed;
293 int sokobanfields_still_needed;
294 int lights_still_needed;
295 int friends_still_needed;
296 int key[MAX_NUM_KEYS];
298 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
299 int shield_normal_time_left;
300 int shield_deadly_time_left;
302 int inventory_element[MAX_INVENTORY_SIZE];
303 int inventory_infinite_element;
307 extern struct GameInfo game;
308 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
312 void DEBUG_SetMaximumDynamite();
315 void GetPlayerConfig(void);
316 int GetElementFromGroupElement(int);
318 void DrawGameValue_Time(int);
319 void DrawGameDoorValues(void);
321 void UpdateAndDisplayGameControlValues();
323 void InitGameSound();
326 void UpdateEngineValues(int, int);
330 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
331 void Moving2Blocked(int, int, int *, int *);
332 void Blocked2Moving(int, int, int *, int *);
333 void DrawDynamite(int, int);
335 void StartGameActions(boolean, boolean, int);
337 void GameActions(void);
338 void GameActions_EM_Main();
339 void GameActions_SP_Main();
340 void GameActions_RND();
342 void ScrollLevel(int, int);
344 void InitPlayLevelSound();
345 void PlayLevelSound_EM(int, int, int, int);
346 void PlayLevelSound_SP(int, int, int, int);
348 void RaiseScore(int);
349 void RaiseScoreElement(int);
351 void RequestQuitGameExt(boolean, boolean, char *);
352 void RequestQuitGame(boolean);
354 unsigned int InitEngineRandom_RND(int);
355 unsigned int RND(int);
357 void FreeEngineSnapshot();
358 void LoadEngineSnapshot();
359 void SaveEngineSnapshot();
360 boolean CheckEngineSnapshot();
362 void CreateGameButtons();
363 void FreeGameButtons();
364 void UnmapGameButtons();
365 void RedrawGameButtons();
367 void HandleSoundButtonKeys(Key);