1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // http://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
15 /* (not included here due to collisions with Emerald Mine engine definitions) */
16 /* #include "main.h" */
18 #define MAX_INVENTORY_SIZE 1000
20 #define STD_NUM_KEYS 4
21 #define MAX_NUM_KEYS 8
24 #define NUM_BELT_PARTS 3
26 #define NUM_PANEL_INVENTORY 8
27 #define NUM_PANEL_GRAPHICS 8
28 #define NUM_PANEL_ELEMENTS 8
29 #define NUM_PANEL_CE_SCORE 8
31 #define STR_SNAPSHOT_MODE_OFF "off"
32 #define STR_SNAPSHOT_MODE_EVERY_STEP "every_step"
33 #define STR_SNAPSHOT_MODE_EVERY_MOVE "every_move"
34 #define STR_SNAPSHOT_MODE_EVERY_COLLECT "every_collect"
35 #define STR_SNAPSHOT_MODE_DEFAULT STR_SNAPSHOT_MODE_OFF
37 #define SNAPSHOT_MODE_OFF 0
38 #define SNAPSHOT_MODE_EVERY_STEP 1
39 #define SNAPSHOT_MODE_EVERY_MOVE 2
40 #define SNAPSHOT_MODE_EVERY_COLLECT 3
41 #define SNAPSHOT_MODE_DEFAULT SNAPSHOT_MODE_OFF
46 struct TextPosInfo level_number;
47 struct TextPosInfo gems;
48 struct TextPosInfo inventory_count;
49 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
50 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
51 struct TextPosInfo key[MAX_NUM_KEYS];
52 struct TextPosInfo key_white;
53 struct TextPosInfo key_white_count;
54 struct TextPosInfo score;
55 struct TextPosInfo highscore;
56 struct TextPosInfo time;
57 struct TextPosInfo time_hh;
58 struct TextPosInfo time_mm;
59 struct TextPosInfo time_ss;
60 struct TextPosInfo time_anim;
61 struct TextPosInfo health;
62 struct TextPosInfo health_anim;
63 struct TextPosInfo frame;
64 struct TextPosInfo shield_normal;
65 struct TextPosInfo shield_normal_time;
66 struct TextPosInfo shield_deadly;
67 struct TextPosInfo shield_deadly_time;
68 struct TextPosInfo exit;
69 struct TextPosInfo emc_magic_ball;
70 struct TextPosInfo emc_magic_ball_switch;
71 struct TextPosInfo light_switch;
72 struct TextPosInfo light_switch_time;
73 struct TextPosInfo timegate_switch;
74 struct TextPosInfo timegate_switch_time;
75 struct TextPosInfo switchgate_switch;
76 struct TextPosInfo emc_lenses;
77 struct TextPosInfo emc_lenses_time;
78 struct TextPosInfo emc_magnifier;
79 struct TextPosInfo emc_magnifier_time;
80 struct TextPosInfo balloon_switch;
81 struct TextPosInfo dynabomb_number;
82 struct TextPosInfo dynabomb_size;
83 struct TextPosInfo dynabomb_power;
84 struct TextPosInfo penguins;
85 struct TextPosInfo sokoban_objects;
86 struct TextPosInfo sokoban_fields;
87 struct TextPosInfo robot_wheel;
88 struct TextPosInfo conveyor_belt[NUM_BELTS];
89 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
90 struct TextPosInfo magic_wall;
91 struct TextPosInfo magic_wall_time;
92 struct TextPosInfo gravity_state;
93 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
94 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
95 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
96 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
97 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
98 struct TextPosInfo player_name;
99 struct TextPosInfo level_name;
100 struct TextPosInfo level_author;
103 struct GameButtonInfo
116 struct XY sound_music;
117 struct XY sound_loops;
118 struct XY sound_simple;
121 struct GameSnapshotInfo
125 byte last_action[MAX_PLAYERS];
126 boolean changed_action;
127 boolean collected_item;
129 boolean save_snapshot;
134 /* values for control panel */
135 struct GamePanelInfo panel;
136 struct GameButtonInfo button;
138 /* values for graphics engine customization */
139 int graphics_engine_version;
140 boolean use_native_emc_graphics_engine;
141 boolean use_native_sp_graphics_engine;
142 boolean use_masked_pushing;
143 int forced_scroll_delay_value;
144 int scroll_delay_value;
147 /* values for engine initialization */
148 int default_push_delay_fixed;
149 int default_push_delay_random;
151 /* constant within running game */
154 int initial_move_delay[MAX_PLAYERS];
155 int initial_move_delay_value[MAX_PLAYERS];
156 int initial_push_delay_value;
158 /* flag for single or multi-player mode (needed for playing tapes) */
159 /* (when playing/recording games, this is identical to "setup.team_mode" */
162 /* flags to handle bugs in and changes between different engine versions */
163 /* (for the latest engine version, these flags should always be "FALSE") */
164 boolean use_change_when_pushing_bug;
165 boolean use_block_last_field_bug;
166 boolean max_num_changes_per_frame;
167 boolean use_reverse_scan_direction;
169 /* variable within running game */
170 int yamyam_content_nr;
171 boolean robot_wheel_active;
172 boolean magic_wall_active;
173 int magic_wall_time_left;
175 int timegate_time_left;
181 boolean explosions_delayed;
182 boolean envelope_active;
183 boolean no_time_limit; /* (variable only in very special case) */
185 /* values for the new EMC elements */
186 int lenses_time_left;
187 int magnify_time_left;
191 /* values for player idle animation (no effect on engine) */
192 int player_boring_delay_fixed;
193 int player_boring_delay_random;
194 int player_sleeping_delay_fixed;
195 int player_sleeping_delay_random;
197 /* values for special game initialization control */
198 boolean restart_level;
200 /* values for special game control */
201 int centered_player_nr;
202 int centered_player_nr_next;
203 boolean set_centered_player;
205 /* values for random number generator initialization after snapshot */
206 unsigned int num_random_calls;
208 /* values for game engine snapshot control */
209 struct GameSnapshotInfo snapshot;
214 boolean present; /* player present in level playfield */
215 boolean connected; /* player connected (locally or via network) */
216 boolean active; /* player present and connected */
217 boolean mapped; /* player already mapped to input device */
219 boolean killed; /* player maybe present/active, but killed */
220 boolean reanimated; /* player maybe killed, but reanimated */
222 int index_nr; /* player number (0 to 3) */
223 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
224 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
225 int client_nr; /* network client identifier */
227 byte action; /* action from local input device */
228 byte mapped_action; /* action mapped from device to player */
229 byte effective_action; /* action acknowledged from network server
230 or summarized over all configured input
231 devices when in single player mode */
232 byte programmed_action; /* action forced by game itself (like moving
233 through doors); overrides other actions */
235 struct MouseActionInfo mouse_action; /* (used by MM engine only) */
236 struct MouseActionInfo effective_mouse_action; /* (used by MM engine only) */
238 int jx, jy, last_jx, last_jy;
239 int MovDir, MovPos, GfxDir, GfxPos;
240 int Frame, StepFrame;
244 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
248 boolean block_last_field;
249 int block_delay_adjustment; /* needed for different engine versions */
251 boolean can_fall_into_acid;
255 boolean LevelSolved, GameOver;
257 boolean LevelSolved_GameWon;
258 boolean LevelSolved_GameEnd;
259 boolean LevelSolved_PanelOff;
260 boolean LevelSolved_SaveTape;
261 boolean LevelSolved_SaveScore;
262 int LevelSolved_CountingTime;
263 int LevelSolved_CountingScore;
271 boolean is_auto_moving;
274 boolean is_collecting;
276 boolean is_switching;
278 boolean is_dropping_pressed;
285 boolean was_snapping;
286 boolean was_dropping;
290 boolean force_dropping; /* needed for single step mode */
292 int frame_counter_bored;
293 int frame_counter_sleeping;
295 int anim_delay_counter;
296 int post_delay_counter;
299 int action_waiting, last_action_waiting;
300 int special_action_bored;
301 int special_action_sleeping;
303 int num_special_action_bored;
304 int num_special_action_sleeping;
306 int switch_x, switch_y;
312 int move_delay_value;
313 int move_delay_value_next;
314 int move_delay_reset_counter;
317 int push_delay_value;
319 unsigned int actual_frame_counter;
322 int drop_pressed_delay;
329 int gems_still_needed;
330 int sokobanfields_still_needed;
331 int lights_still_needed;
332 int friends_still_needed;
333 int key[MAX_NUM_KEYS];
335 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
336 int shield_normal_time_left;
337 int shield_deadly_time_left;
339 int inventory_element[MAX_INVENTORY_SIZE];
340 int inventory_infinite_element;
344 extern struct GameInfo game;
345 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
349 void DEBUG_SetMaximumDynamite();
352 void GetPlayerConfig(void);
353 int GetElementFromGroupElement(int);
355 int getPlayerInventorySize(int);
357 void DrawGameValue_Time(int);
358 void DrawGameDoorValues(void);
360 void UpdateAndDisplayGameControlValues();
362 void InitGameSound();
365 void UpdateEngineValues(int, int, int, int);
369 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
370 void Moving2Blocked(int, int, int *, int *);
371 void Blocked2Moving(int, int, int *, int *);
372 void DrawDynamite(int, int);
374 void StartGameActions(boolean, boolean, int);
376 void GameActions(void);
377 void GameActions_EM_Main();
378 void GameActions_SP_Main();
379 void GameActions_MM_Main();
380 void GameActions_RND_Main();
381 void GameActions_RND();
383 void ScrollLevel(int, int);
385 void InitPlayLevelSound();
386 void PlayLevelSound_EM(int, int, int, int);
387 void PlayLevelSound_SP(int, int, int, int);
388 void PlayLevelSound_MM(int, int, int, int);
389 void PlaySound_MM(int);
390 void PlaySoundLoop_MM(int);
391 void StopSound_MM(int);
393 void RaiseScore(int);
394 void RaiseScoreElement(int);
396 void RequestQuitGameExt(boolean, boolean, char *);
397 void RequestQuitGame(boolean);
399 unsigned int InitEngineRandom_RND(int);
400 unsigned int RND(int);
402 void FreeEngineSnapshotSingle();
403 void FreeEngineSnapshotList();
404 void LoadEngineSnapshotSingle();
405 void SaveEngineSnapshotSingle();
406 boolean CheckSaveEngineSnapshotToList();
407 void SaveEngineSnapshotToList();
408 void SaveEngineSnapshotToListInitial();
409 boolean CheckEngineSnapshotSingle();
410 boolean CheckEngineSnapshotList();
412 void CreateGameButtons();
413 void FreeGameButtons();
414 void MapUndoRedoButtons();
415 void UnmapUndoRedoButtons();
416 void MapGameButtons();
417 void UnmapGameButtons();
418 void RedrawGameButtons();
420 void HandleSoundButtonKeys(Key);