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 SNAPSHOT_MODE_STEP 0
32 #define SNAPSHOT_MODE_MOVE 1
37 struct TextPosInfo level_number;
38 struct TextPosInfo gems;
39 struct TextPosInfo inventory_count;
40 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
41 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
42 struct TextPosInfo key[MAX_NUM_KEYS];
43 struct TextPosInfo key_white;
44 struct TextPosInfo key_white_count;
45 struct TextPosInfo score;
46 struct TextPosInfo highscore;
47 struct TextPosInfo time;
48 struct TextPosInfo time_hh;
49 struct TextPosInfo time_mm;
50 struct TextPosInfo time_ss;
51 struct TextPosInfo frame;
52 struct TextPosInfo shield_normal;
53 struct TextPosInfo shield_normal_time;
54 struct TextPosInfo shield_deadly;
55 struct TextPosInfo shield_deadly_time;
56 struct TextPosInfo exit;
57 struct TextPosInfo emc_magic_ball;
58 struct TextPosInfo emc_magic_ball_switch;
59 struct TextPosInfo light_switch;
60 struct TextPosInfo light_switch_time;
61 struct TextPosInfo timegate_switch;
62 struct TextPosInfo timegate_switch_time;
63 struct TextPosInfo switchgate_switch;
64 struct TextPosInfo emc_lenses;
65 struct TextPosInfo emc_lenses_time;
66 struct TextPosInfo emc_magnifier;
67 struct TextPosInfo emc_magnifier_time;
68 struct TextPosInfo balloon_switch;
69 struct TextPosInfo dynabomb_number;
70 struct TextPosInfo dynabomb_size;
71 struct TextPosInfo dynabomb_power;
72 struct TextPosInfo penguins;
73 struct TextPosInfo sokoban_objects;
74 struct TextPosInfo sokoban_fields;
75 struct TextPosInfo robot_wheel;
76 struct TextPosInfo conveyor_belt[NUM_BELTS];
77 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
78 struct TextPosInfo magic_wall;
79 struct TextPosInfo magic_wall_time;
80 struct TextPosInfo gravity_state;
81 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
82 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
83 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
84 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
85 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
86 struct TextPosInfo player_name;
87 struct TextPosInfo level_name;
88 struct TextPosInfo level_author;
103 struct XY sound_music;
104 struct XY sound_loops;
105 struct XY sound_simple;
108 struct GameSnapshotInfo
112 byte last_action[MAX_PLAYERS];
113 boolean changed_action;
118 /* values for control panel */
119 struct GamePanelInfo panel;
120 struct GameButtonInfo button;
122 /* values for graphics engine customization */
123 boolean use_native_emc_graphics_engine;
124 boolean use_native_sp_graphics_engine;
125 boolean use_masked_pushing;
126 int forced_scroll_delay_value;
127 int scroll_delay_value;
130 /* values for engine initialization */
131 int default_push_delay_fixed;
132 int default_push_delay_random;
134 /* constant within running game */
137 int initial_move_delay[MAX_PLAYERS];
138 int initial_move_delay_value[MAX_PLAYERS];
139 int initial_push_delay_value;
141 /* flag for single or multi-player mode (needed for playing tapes) */
142 /* (when playing/recording games, this is identical to "setup.team_mode" */
145 /* flags to handle bugs in and changes between different engine versions */
146 /* (for the latest engine version, these flags should always be "FALSE") */
147 boolean use_change_when_pushing_bug;
148 boolean use_block_last_field_bug;
149 boolean max_num_changes_per_frame;
150 boolean use_reverse_scan_direction;
152 /* variable within running game */
153 int yamyam_content_nr;
154 boolean robot_wheel_active;
155 boolean magic_wall_active;
156 int magic_wall_time_left;
158 int timegate_time_left;
164 boolean explosions_delayed;
165 boolean envelope_active;
166 boolean no_time_limit; /* (variable only in very special case) */
168 /* values for the new EMC elements */
169 int lenses_time_left;
170 int magnify_time_left;
174 /* values for player idle animation (no effect on engine) */
175 int player_boring_delay_fixed;
176 int player_boring_delay_random;
177 int player_sleeping_delay_fixed;
178 int player_sleeping_delay_random;
180 /* values for special game initialization control */
181 boolean restart_level;
183 /* values for special game control */
184 int centered_player_nr;
185 int centered_player_nr_next;
186 boolean set_centered_player;
188 /* values for random number generator initialization after snapshot */
189 unsigned int num_random_calls;
191 /* values for game engine snapshot control */
192 struct GameSnapshotInfo snapshot;
197 boolean present; /* player present in level playfield */
198 boolean connected; /* player connected (locally or via network) */
199 boolean active; /* player present and connected */
200 boolean mapped; /* player already mapped to input device */
202 boolean killed; /* player maybe present/active, but killed */
203 boolean reanimated; /* player maybe killed, but reanimated */
205 int index_nr; /* player number (0 to 3) */
206 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
207 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
208 int client_nr; /* network client identifier */
210 byte action; /* action from local input device */
211 byte mapped_action; /* action mapped from device to player */
212 byte effective_action; /* action acknowledged from network server
213 or summarized over all configured input
214 devices when in single player mode */
215 byte programmed_action; /* action forced by game itself (like moving
216 through doors); overrides other actions */
218 int jx, jy, last_jx, last_jy;
219 int MovDir, MovPos, GfxDir, GfxPos;
220 int Frame, StepFrame;
224 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
228 boolean block_last_field;
229 int block_delay_adjustment; /* needed for different engine versions */
231 boolean can_fall_into_acid;
235 boolean LevelSolved, GameOver;
237 boolean LevelSolved_GameWon;
238 boolean LevelSolved_GameEnd;
239 boolean LevelSolved_PanelOff;
240 boolean LevelSolved_SaveTape;
241 boolean LevelSolved_SaveScore;
242 int LevelSolved_CountingTime;
243 int LevelSolved_CountingScore;
251 boolean is_auto_moving;
254 boolean is_collecting;
256 boolean is_switching;
258 boolean is_dropping_pressed;
265 int frame_counter_bored;
266 int frame_counter_sleeping;
268 int anim_delay_counter;
269 int post_delay_counter;
272 int action_waiting, last_action_waiting;
273 int special_action_bored;
274 int special_action_sleeping;
276 int num_special_action_bored;
277 int num_special_action_sleeping;
279 int switch_x, switch_y;
285 int move_delay_value;
286 int move_delay_value_next;
287 int move_delay_reset_counter;
290 int push_delay_value;
292 unsigned int actual_frame_counter;
295 int drop_pressed_delay;
302 int gems_still_needed;
303 int sokobanfields_still_needed;
304 int lights_still_needed;
305 int friends_still_needed;
306 int key[MAX_NUM_KEYS];
308 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
309 int shield_normal_time_left;
310 int shield_deadly_time_left;
312 int inventory_element[MAX_INVENTORY_SIZE];
313 int inventory_infinite_element;
317 extern struct GameInfo game;
318 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
322 void DEBUG_SetMaximumDynamite();
325 void GetPlayerConfig(void);
326 int GetElementFromGroupElement(int);
328 void DrawGameValue_Time(int);
329 void DrawGameDoorValues(void);
331 void UpdateAndDisplayGameControlValues();
333 void InitGameSound();
336 void UpdateEngineValues(int, int);
340 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
341 void Moving2Blocked(int, int, int *, int *);
342 void Blocked2Moving(int, int, int *, int *);
343 void DrawDynamite(int, int);
345 void StartGameActions(boolean, boolean, int);
347 void GameActions(void);
348 void GameActions_EM_Main();
349 void GameActions_SP_Main();
350 void GameActions_RND();
352 void ScrollLevel(int, int);
354 void InitPlayLevelSound();
355 void PlayLevelSound_EM(int, int, int, int);
356 void PlayLevelSound_SP(int, int, int, int);
358 void RaiseScore(int);
359 void RaiseScoreElement(int);
361 void RequestQuitGameExt(boolean, boolean, char *);
362 void RequestQuitGame(boolean);
364 unsigned int InitEngineRandom_RND(int);
365 unsigned int RND(int);
367 void FreeEngineSnapshotSingle();
368 void FreeEngineSnapshotList();
369 void LoadEngineSnapshotSingle();
370 void SaveEngineSnapshotSingle();
371 boolean SaveEngineSnapshotToList();
372 boolean CheckEngineSnapshot();
374 void CreateGameButtons();
375 void FreeGameButtons();
376 void MapStopPlayButtons();
377 void MapUndoRedoButtons();
378 void MapGameButtons();
379 void UnmapGameButtons();
380 void RedrawGameButtons();
382 void HandleSoundButtonKeys(Key);