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 time;
46 struct TextPosInfo time_hh;
47 struct TextPosInfo time_mm;
48 struct TextPosInfo time_ss;
49 struct TextPosInfo shield_normal;
50 struct TextPosInfo shield_normal_time;
51 struct TextPosInfo shield_deadly;
52 struct TextPosInfo shield_deadly_time;
53 struct TextPosInfo exit;
54 struct TextPosInfo emc_magic_ball;
55 struct TextPosInfo emc_magic_ball_switch;
56 struct TextPosInfo light_switch;
57 struct TextPosInfo light_switch_time;
58 struct TextPosInfo timegate_switch;
59 struct TextPosInfo timegate_switch_time;
60 struct TextPosInfo switchgate_switch;
61 struct TextPosInfo emc_lenses;
62 struct TextPosInfo emc_lenses_time;
63 struct TextPosInfo emc_magnifier;
64 struct TextPosInfo emc_magnifier_time;
65 struct TextPosInfo balloon_switch;
66 struct TextPosInfo dynabomb_number;
67 struct TextPosInfo dynabomb_size;
68 struct TextPosInfo dynabomb_power;
69 struct TextPosInfo penguins;
70 struct TextPosInfo sokoban_objects;
71 struct TextPosInfo sokoban_fields;
72 struct TextPosInfo robot_wheel;
73 struct TextPosInfo conveyor_belt[NUM_BELTS];
74 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
75 struct TextPosInfo magic_wall;
76 struct TextPosInfo magic_wall_time;
77 struct TextPosInfo gravity_state;
78 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
79 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
80 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
81 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
82 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
83 struct TextPosInfo player_name;
84 struct TextPosInfo level_name;
85 struct TextPosInfo level_author;
90 struct MenuPosInfo stop;
91 struct MenuPosInfo pause;
92 struct MenuPosInfo play;
93 struct MenuPosInfo sound_music;
94 struct MenuPosInfo sound_loops;
95 struct MenuPosInfo sound_simple;
113 /* values for control panel */
114 struct GamePanelInfo panel;
115 struct GameButtonInfo button;
117 /* values for graphics engine customization */
118 boolean use_native_emc_graphics_engine;
119 int forced_scroll_delay_value;
120 int scroll_delay_value;
122 /* values for engine initialization */
123 int default_push_delay_fixed;
124 int default_push_delay_random;
126 /* constant within running game */
129 int initial_move_delay[MAX_PLAYERS];
130 int initial_move_delay_value[MAX_PLAYERS];
131 int initial_push_delay_value;
133 /* flags to handle bugs in and changes between different engine versions */
134 /* (for the latest engine version, these flags should always be "FALSE") */
135 boolean use_change_when_pushing_bug;
136 boolean use_block_last_field_bug;
137 boolean max_num_changes_per_frame;
138 boolean use_reverse_scan_direction;
140 /* variable within running game */
141 int yamyam_content_nr;
142 boolean robot_wheel_active;
143 boolean magic_wall_active;
144 int magic_wall_time_left;
146 int timegate_time_left;
152 boolean explosions_delayed;
153 boolean envelope_active;
155 /* values for the new EMC elements */
156 int lenses_time_left;
157 int magnify_time_left;
161 /* values for player idle animation (no effect on engine) */
162 int player_boring_delay_fixed;
163 int player_boring_delay_random;
164 int player_sleeping_delay_fixed;
165 int player_sleeping_delay_random;
167 /* values for special game initialization control */
168 boolean restart_level;
170 /* values for special game control */
171 int centered_player_nr;
172 int centered_player_nr_next;
173 boolean set_centered_player;
175 /* values for random number generator initialization after snapshot */
176 unsigned long num_random_calls;
181 boolean present; /* player present in level playfield */
182 boolean connected; /* player connected (locally or via network) */
183 boolean active; /* player present and connected */
184 boolean killed; /* player maybe present/active, but killed */
186 int index_nr; /* player number (0 to 3) */
187 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
188 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
189 int client_nr; /* network client identifier */
191 byte action; /* action from local input device */
192 byte effective_action; /* action acknowledged from network server
193 or summarized over all configured input
194 devices when in single player mode */
195 byte programmed_action; /* action forced by game itself (like moving
196 through doors); overrides other actions */
198 int jx, jy, last_jx, last_jy;
199 int MovDir, MovPos, GfxDir, GfxPos;
200 int Frame, StepFrame;
207 boolean block_last_field;
208 int block_delay_adjustment; /* needed for different engine versions */
210 boolean can_fall_into_acid;
214 boolean LevelSolved, GameOver;
216 boolean LevelSolved_GameWon;
217 boolean LevelSolved_GameEnd;
218 boolean LevelSolved_PanelOff;
219 boolean LevelSolved_SaveTape;
220 boolean LevelSolved_SaveScore;
221 int LevelSolved_CountingTime;
222 int LevelSolved_CountingScore;
230 boolean is_auto_moving;
233 boolean is_collecting;
235 boolean is_switching;
237 boolean is_dropping_pressed;
244 int frame_counter_bored;
245 int frame_counter_sleeping;
247 int anim_delay_counter;
248 int post_delay_counter;
251 int action_waiting, last_action_waiting;
252 int special_action_bored;
253 int special_action_sleeping;
255 int num_special_action_bored;
256 int num_special_action_sleeping;
258 int switch_x, switch_y;
264 int move_delay_value;
265 int move_delay_value_next;
266 int move_delay_reset_counter;
269 int push_delay_value;
271 unsigned long actual_frame_counter;
274 int drop_pressed_delay;
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];
287 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
288 int shield_normal_time_left;
289 int shield_deadly_time_left;
291 int inventory_element[MAX_INVENTORY_SIZE];
292 int inventory_infinite_element;
296 extern struct GameInfo game;
297 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
301 void DEBUG_SetMaximumDynamite();
304 void GetPlayerConfig(void);
305 int GetElementFromGroupElement(int);
307 void DrawGameValue_Time(int);
308 void DrawGameDoorValues(void);
310 void UpdateAndDisplayGameControlValues();
312 void InitGameSound();
315 void UpdateEngineValues(int, int);
319 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
320 void Moving2Blocked(int, int, int *, int *);
321 void Blocked2Moving(int, int, int *, int *);
322 void DrawDynamite(int, int);
324 void StartGameActions(boolean, boolean, long);
326 void GameActions(void);
327 void GameActions_EM_Main();
328 void GameActions_RND();
330 void ScrollLevel(int, int);
332 void InitPlayLevelSound();
333 void PlayLevelSound_EM(int, int, int, int);
335 void RaiseScore(int);
336 void RaiseScoreElement(int);
338 void RequestQuitGameExt(boolean, boolean, char *);
339 void RequestQuitGame(boolean);
341 unsigned int InitEngineRandom_RND(long);
342 unsigned int RND(int);
344 void FreeEngineSnapshot();
345 void LoadEngineSnapshot();
346 void SaveEngineSnapshot();
347 boolean CheckEngineSnapshot();
349 void CreateGameButtons();
350 void FreeGameButtons();
351 void UnmapGameButtons();
352 void RedrawGameButtons();