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 frame;
61 struct TextPosInfo shield_normal;
62 struct TextPosInfo shield_normal_time;
63 struct TextPosInfo shield_deadly;
64 struct TextPosInfo shield_deadly_time;
65 struct TextPosInfo exit;
66 struct TextPosInfo emc_magic_ball;
67 struct TextPosInfo emc_magic_ball_switch;
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[NUM_BELTS];
86 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
87 struct TextPosInfo magic_wall;
88 struct TextPosInfo magic_wall_time;
89 struct TextPosInfo gravity_state;
90 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
91 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
92 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
93 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
94 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
95 struct TextPosInfo player_name;
96 struct TextPosInfo level_name;
97 struct TextPosInfo level_author;
100 struct GameButtonInfo
113 struct XY sound_music;
114 struct XY sound_loops;
115 struct XY sound_simple;
118 struct GameSnapshotInfo
122 byte last_action[MAX_PLAYERS];
123 boolean changed_action;
124 boolean collected_item;
129 /* values for control panel */
130 struct GamePanelInfo panel;
131 struct GameButtonInfo button;
133 /* values for graphics engine customization */
134 int graphics_engine_version;
135 boolean use_native_emc_graphics_engine;
136 boolean use_native_sp_graphics_engine;
137 boolean use_masked_pushing;
138 int forced_scroll_delay_value;
139 int scroll_delay_value;
142 /* values for engine initialization */
143 int default_push_delay_fixed;
144 int default_push_delay_random;
146 /* constant within running game */
149 int initial_move_delay[MAX_PLAYERS];
150 int initial_move_delay_value[MAX_PLAYERS];
151 int initial_push_delay_value;
153 /* flag for single or multi-player mode (needed for playing tapes) */
154 /* (when playing/recording games, this is identical to "setup.team_mode" */
157 /* flags to handle bugs in and changes between different engine versions */
158 /* (for the latest engine version, these flags should always be "FALSE") */
159 boolean use_change_when_pushing_bug;
160 boolean use_block_last_field_bug;
161 boolean max_num_changes_per_frame;
162 boolean use_reverse_scan_direction;
164 /* variable within running game */
165 int yamyam_content_nr;
166 boolean robot_wheel_active;
167 boolean magic_wall_active;
168 int magic_wall_time_left;
170 int timegate_time_left;
176 boolean explosions_delayed;
177 boolean envelope_active;
178 boolean no_time_limit; /* (variable only in very special case) */
180 /* values for the new EMC elements */
181 int lenses_time_left;
182 int magnify_time_left;
186 /* values for player idle animation (no effect on engine) */
187 int player_boring_delay_fixed;
188 int player_boring_delay_random;
189 int player_sleeping_delay_fixed;
190 int player_sleeping_delay_random;
192 /* values for special game initialization control */
193 boolean restart_level;
195 /* values for special game control */
196 int centered_player_nr;
197 int centered_player_nr_next;
198 boolean set_centered_player;
200 /* values for random number generator initialization after snapshot */
201 unsigned int num_random_calls;
203 /* values for game engine snapshot control */
204 struct GameSnapshotInfo snapshot;
209 boolean present; /* player present in level playfield */
210 boolean connected; /* player connected (locally or via network) */
211 boolean active; /* player present and connected */
212 boolean mapped; /* player already mapped to input device */
214 boolean killed; /* player maybe present/active, but killed */
215 boolean reanimated; /* player maybe killed, but reanimated */
217 int index_nr; /* player number (0 to 3) */
218 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
219 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
220 int client_nr; /* network client identifier */
222 byte action; /* action from local input device */
223 byte mapped_action; /* action mapped from device to player */
224 byte effective_action; /* action acknowledged from network server
225 or summarized over all configured input
226 devices when in single player mode */
227 byte programmed_action; /* action forced by game itself (like moving
228 through doors); overrides other actions */
230 int jx, jy, last_jx, last_jy;
231 int MovDir, MovPos, GfxDir, GfxPos;
232 int Frame, StepFrame;
236 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
240 boolean block_last_field;
241 int block_delay_adjustment; /* needed for different engine versions */
243 boolean can_fall_into_acid;
247 boolean LevelSolved, GameOver;
249 boolean LevelSolved_GameWon;
250 boolean LevelSolved_GameEnd;
251 boolean LevelSolved_PanelOff;
252 boolean LevelSolved_SaveTape;
253 boolean LevelSolved_SaveScore;
254 int LevelSolved_CountingTime;
255 int LevelSolved_CountingScore;
263 boolean is_auto_moving;
266 boolean is_collecting;
268 boolean is_switching;
270 boolean is_dropping_pressed;
277 int frame_counter_bored;
278 int frame_counter_sleeping;
280 int anim_delay_counter;
281 int post_delay_counter;
284 int action_waiting, last_action_waiting;
285 int special_action_bored;
286 int special_action_sleeping;
288 int num_special_action_bored;
289 int num_special_action_sleeping;
291 int switch_x, switch_y;
297 int move_delay_value;
298 int move_delay_value_next;
299 int move_delay_reset_counter;
302 int push_delay_value;
304 unsigned int actual_frame_counter;
307 int drop_pressed_delay;
314 int gems_still_needed;
315 int sokobanfields_still_needed;
316 int lights_still_needed;
317 int friends_still_needed;
318 int key[MAX_NUM_KEYS];
320 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
321 int shield_normal_time_left;
322 int shield_deadly_time_left;
324 int inventory_element[MAX_INVENTORY_SIZE];
325 int inventory_infinite_element;
329 extern struct GameInfo game;
330 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
334 void DEBUG_SetMaximumDynamite();
337 void GetPlayerConfig(void);
338 int GetElementFromGroupElement(int);
340 void DrawGameValue_Time(int);
341 void DrawGameDoorValues(void);
343 void UpdateAndDisplayGameControlValues();
345 void InitGameSound();
348 void UpdateEngineValues(int, int);
352 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
353 void Moving2Blocked(int, int, int *, int *);
354 void Blocked2Moving(int, int, int *, int *);
355 void DrawDynamite(int, int);
357 void StartGameActions(boolean, boolean, int);
359 void GameActions(void);
360 void GameActions_EM_Main();
361 void GameActions_SP_Main();
362 void GameActions_RND_Main();
363 void GameActions_RND();
365 void ScrollLevel(int, int);
367 void InitPlayLevelSound();
368 void PlayLevelSound_EM(int, int, int, int);
369 void PlayLevelSound_SP(int, int, int, int);
371 void RaiseScore(int);
372 void RaiseScoreElement(int);
374 void RequestQuitGameExt(boolean, boolean, char *);
375 void RequestQuitGame(boolean);
377 unsigned int InitEngineRandom_RND(int);
378 unsigned int RND(int);
380 void FreeEngineSnapshotSingle();
381 void FreeEngineSnapshotList();
382 void LoadEngineSnapshotSingle();
383 void SaveEngineSnapshotSingle();
384 boolean SaveEngineSnapshotToList();
385 void SaveEngineSnapshotToListInitial();
386 boolean CheckEngineSnapshotSingle();
387 boolean CheckEngineSnapshotList();
389 void CreateGameButtons();
390 void FreeGameButtons();
391 void MapUndoRedoButtons();
392 void UnmapUndoRedoButtons();
393 void MapGameButtons();
394 void UnmapGameButtons();
395 void RedrawGameButtons();
397 void HandleSoundButtonKeys(Key);