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 int jx, jy, last_jx, last_jy;
236 int MovDir, MovPos, GfxDir, GfxPos;
237 int Frame, StepFrame;
241 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
245 boolean block_last_field;
246 int block_delay_adjustment; /* needed for different engine versions */
248 boolean can_fall_into_acid;
252 boolean LevelSolved, GameOver;
254 boolean LevelSolved_GameWon;
255 boolean LevelSolved_GameEnd;
256 boolean LevelSolved_PanelOff;
257 boolean LevelSolved_SaveTape;
258 boolean LevelSolved_SaveScore;
259 int LevelSolved_CountingTime;
260 int LevelSolved_CountingScore;
268 boolean is_auto_moving;
271 boolean is_collecting;
273 boolean is_switching;
275 boolean is_dropping_pressed;
282 boolean was_snapping;
283 boolean was_dropping;
287 boolean force_dropping; /* needed for single step mode */
289 int frame_counter_bored;
290 int frame_counter_sleeping;
292 int anim_delay_counter;
293 int post_delay_counter;
296 int action_waiting, last_action_waiting;
297 int special_action_bored;
298 int special_action_sleeping;
300 int num_special_action_bored;
301 int num_special_action_sleeping;
303 int switch_x, switch_y;
309 int move_delay_value;
310 int move_delay_value_next;
311 int move_delay_reset_counter;
314 int push_delay_value;
316 unsigned int actual_frame_counter;
319 int drop_pressed_delay;
326 int gems_still_needed;
327 int sokobanfields_still_needed;
328 int lights_still_needed;
329 int friends_still_needed;
330 int key[MAX_NUM_KEYS];
332 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
333 int shield_normal_time_left;
334 int shield_deadly_time_left;
336 int inventory_element[MAX_INVENTORY_SIZE];
337 int inventory_infinite_element;
341 extern struct GameInfo game;
342 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
346 void DEBUG_SetMaximumDynamite();
349 void GetPlayerConfig(void);
350 int GetElementFromGroupElement(int);
352 int getPlayerInventorySize(int);
354 void DrawGameValue_Time(int);
355 void DrawGameDoorValues(void);
357 void UpdateAndDisplayGameControlValues();
359 void InitGameSound();
362 void UpdateEngineValues(int, int, int, int);
366 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
367 void Moving2Blocked(int, int, int *, int *);
368 void Blocked2Moving(int, int, int *, int *);
369 void DrawDynamite(int, int);
371 void StartGameActions(boolean, boolean, int);
373 void GameActions(void);
374 void GameActions_EM_Main();
375 void GameActions_SP_Main();
376 void GameActions_MM_Main();
377 void GameActions_RND_Main();
378 void GameActions_RND();
380 void ScrollLevel(int, int);
382 void InitPlayLevelSound();
383 void PlayLevelSound_EM(int, int, int, int);
384 void PlayLevelSound_SP(int, int, int, int);
386 void RaiseScore(int);
387 void RaiseScoreElement(int);
389 void RequestQuitGameExt(boolean, boolean, char *);
390 void RequestQuitGame(boolean);
392 unsigned int InitEngineRandom_RND(int);
393 unsigned int RND(int);
395 void FreeEngineSnapshotSingle();
396 void FreeEngineSnapshotList();
397 void LoadEngineSnapshotSingle();
398 void SaveEngineSnapshotSingle();
399 boolean CheckSaveEngineSnapshotToList();
400 void SaveEngineSnapshotToList();
401 void SaveEngineSnapshotToListInitial();
402 boolean CheckEngineSnapshotSingle();
403 boolean CheckEngineSnapshotList();
405 void CreateGameButtons();
406 void FreeGameButtons();
407 void MapUndoRedoButtons();
408 void UnmapUndoRedoButtons();
409 void MapGameButtons();
410 void UnmapGameButtons();
411 void RedrawGameButtons();
413 void HandleSoundButtonKeys(Key);