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 shield_normal;
51 struct TextPosInfo shield_normal_time;
52 struct TextPosInfo shield_deadly;
53 struct TextPosInfo shield_deadly_time;
54 struct TextPosInfo exit;
55 struct TextPosInfo emc_magic_ball;
56 struct TextPosInfo emc_magic_ball_switch;
57 struct TextPosInfo light_switch;
58 struct TextPosInfo light_switch_time;
59 struct TextPosInfo timegate_switch;
60 struct TextPosInfo timegate_switch_time;
61 struct TextPosInfo switchgate_switch;
62 struct TextPosInfo emc_lenses;
63 struct TextPosInfo emc_lenses_time;
64 struct TextPosInfo emc_magnifier;
65 struct TextPosInfo emc_magnifier_time;
66 struct TextPosInfo balloon_switch;
67 struct TextPosInfo dynabomb_number;
68 struct TextPosInfo dynabomb_size;
69 struct TextPosInfo dynabomb_power;
70 struct TextPosInfo penguins;
71 struct TextPosInfo sokoban_objects;
72 struct TextPosInfo sokoban_fields;
73 struct TextPosInfo robot_wheel;
74 struct TextPosInfo conveyor_belt[NUM_BELTS];
75 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
76 struct TextPosInfo magic_wall;
77 struct TextPosInfo magic_wall_time;
78 struct TextPosInfo gravity_state;
79 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
80 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
81 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
82 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
83 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
84 struct TextPosInfo player_name;
85 struct TextPosInfo level_name;
86 struct TextPosInfo level_author;
91 struct MenuPosInfo stop;
92 struct MenuPosInfo pause;
93 struct MenuPosInfo play;
94 struct MenuPosInfo sound_music;
95 struct MenuPosInfo sound_loops;
96 struct MenuPosInfo sound_simple;
114 /* values for control panel */
115 struct GamePanelInfo panel;
116 struct GameButtonInfo button;
118 /* values for graphics engine customization */
119 boolean use_native_emc_graphics_engine;
120 boolean use_native_sp_graphics_engine;
121 boolean use_masked_pushing;
122 int forced_scroll_delay_value;
123 int scroll_delay_value;
125 /* values for engine initialization */
126 int default_push_delay_fixed;
127 int default_push_delay_random;
129 /* constant within running game */
132 int initial_move_delay[MAX_PLAYERS];
133 int initial_move_delay_value[MAX_PLAYERS];
134 int initial_push_delay_value;
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;
143 /* variable within running game */
144 int yamyam_content_nr;
145 boolean robot_wheel_active;
146 boolean magic_wall_active;
147 int magic_wall_time_left;
149 int timegate_time_left;
155 boolean explosions_delayed;
156 boolean envelope_active;
158 /* values for the new EMC elements */
159 int lenses_time_left;
160 int magnify_time_left;
164 /* values for player idle animation (no effect on engine) */
165 int player_boring_delay_fixed;
166 int player_boring_delay_random;
167 int player_sleeping_delay_fixed;
168 int player_sleeping_delay_random;
170 /* values for special game initialization control */
171 boolean restart_level;
173 /* values for special game control */
174 int centered_player_nr;
175 int centered_player_nr_next;
176 boolean set_centered_player;
178 /* values for random number generator initialization after snapshot */
179 unsigned long num_random_calls;
184 boolean present; /* player present in level playfield */
185 boolean connected; /* player connected (locally or via network) */
186 boolean active; /* player present and connected */
187 boolean mapped; /* player already mapped to input device */
189 boolean killed; /* player maybe present/active, but killed */
190 boolean reanimated; /* player maybe killed, but reanimated */
192 int index_nr; /* player number (0 to 3) */
193 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
194 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
195 int client_nr; /* network client identifier */
197 byte action; /* action from local input device */
198 byte mapped_action; /* action mapped from device to player */
199 byte effective_action; /* action acknowledged from network server
200 or summarized over all configured input
201 devices when in single player mode */
202 byte programmed_action; /* action forced by game itself (like moving
203 through doors); overrides other actions */
205 int jx, jy, last_jx, last_jy;
206 int MovDir, MovPos, GfxDir, GfxPos;
207 int Frame, StepFrame;
211 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
215 boolean block_last_field;
216 int block_delay_adjustment; /* needed for different engine versions */
218 boolean can_fall_into_acid;
222 boolean LevelSolved, GameOver;
224 boolean LevelSolved_GameWon;
225 boolean LevelSolved_GameEnd;
226 boolean LevelSolved_PanelOff;
227 boolean LevelSolved_SaveTape;
228 boolean LevelSolved_SaveScore;
229 int LevelSolved_CountingTime;
230 int LevelSolved_CountingScore;
238 boolean is_auto_moving;
241 boolean is_collecting;
243 boolean is_switching;
245 boolean is_dropping_pressed;
252 int frame_counter_bored;
253 int frame_counter_sleeping;
255 int anim_delay_counter;
256 int post_delay_counter;
259 int action_waiting, last_action_waiting;
260 int special_action_bored;
261 int special_action_sleeping;
263 int num_special_action_bored;
264 int num_special_action_sleeping;
266 int switch_x, switch_y;
272 int move_delay_value;
273 int move_delay_value_next;
274 int move_delay_reset_counter;
277 int push_delay_value;
279 unsigned long actual_frame_counter;
282 int drop_pressed_delay;
289 int gems_still_needed;
290 int sokobanfields_still_needed;
291 int lights_still_needed;
292 int friends_still_needed;
293 int key[MAX_NUM_KEYS];
295 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
296 int shield_normal_time_left;
297 int shield_deadly_time_left;
299 int inventory_element[MAX_INVENTORY_SIZE];
300 int inventory_infinite_element;
304 extern struct GameInfo game;
305 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
309 void DEBUG_SetMaximumDynamite();
312 void GetPlayerConfig(void);
313 int GetElementFromGroupElement(int);
315 void DrawGameValue_Time(int);
316 void DrawGameDoorValues(void);
318 void UpdateAndDisplayGameControlValues();
320 void InitGameSound();
323 void UpdateEngineValues(int, int);
327 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
328 void Moving2Blocked(int, int, int *, int *);
329 void Blocked2Moving(int, int, int *, int *);
330 void DrawDynamite(int, int);
332 void StartGameActions(boolean, boolean, long);
334 void GameActions(void);
335 void GameActions_EM_Main();
336 void GameActions_SP_Main();
337 void GameActions_RND();
339 void ScrollLevel(int, int);
341 void InitPlayLevelSound();
342 void PlayLevelSound_EM(int, int, int, int);
344 void RaiseScore(int);
345 void RaiseScoreElement(int);
347 void RequestQuitGameExt(boolean, boolean, char *);
348 void RequestQuitGame(boolean);
350 unsigned int InitEngineRandom_RND(long);
351 unsigned int RND(int);
353 void FreeEngineSnapshot();
354 void LoadEngineSnapshot();
355 void SaveEngineSnapshot();
356 boolean CheckEngineSnapshot();
358 void CreateGameButtons();
359 void FreeGameButtons();
360 void UnmapGameButtons();
361 void RedrawGameButtons();