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
33 struct TextPosInfo level_number;
34 struct TextPosInfo gems;
35 struct TextPosInfo inventory_count;
36 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
37 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
38 struct TextPosInfo key[MAX_NUM_KEYS];
39 struct TextPosInfo key_white;
40 struct TextPosInfo key_white_count;
41 struct TextPosInfo score;
42 struct TextPosInfo highscore;
43 struct TextPosInfo time;
44 struct TextPosInfo time_hh;
45 struct TextPosInfo time_mm;
46 struct TextPosInfo time_ss;
47 struct TextPosInfo frame;
48 struct TextPosInfo shield_normal;
49 struct TextPosInfo shield_normal_time;
50 struct TextPosInfo shield_deadly;
51 struct TextPosInfo shield_deadly_time;
52 struct TextPosInfo exit;
53 struct TextPosInfo emc_magic_ball;
54 struct TextPosInfo emc_magic_ball_switch;
55 struct TextPosInfo light_switch;
56 struct TextPosInfo light_switch_time;
57 struct TextPosInfo timegate_switch;
58 struct TextPosInfo timegate_switch_time;
59 struct TextPosInfo switchgate_switch;
60 struct TextPosInfo emc_lenses;
61 struct TextPosInfo emc_lenses_time;
62 struct TextPosInfo emc_magnifier;
63 struct TextPosInfo emc_magnifier_time;
64 struct TextPosInfo balloon_switch;
65 struct TextPosInfo dynabomb_number;
66 struct TextPosInfo dynabomb_size;
67 struct TextPosInfo dynabomb_power;
68 struct TextPosInfo penguins;
69 struct TextPosInfo sokoban_objects;
70 struct TextPosInfo sokoban_fields;
71 struct TextPosInfo robot_wheel;
72 struct TextPosInfo conveyor_belt[NUM_BELTS];
73 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
74 struct TextPosInfo magic_wall;
75 struct TextPosInfo magic_wall_time;
76 struct TextPosInfo gravity_state;
77 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
78 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
79 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
80 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
81 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
82 struct TextPosInfo player_name;
83 struct TextPosInfo level_name;
84 struct TextPosInfo level_author;
99 struct XY sound_music;
100 struct XY sound_loops;
101 struct XY sound_simple;
106 /* values for control panel */
107 struct GamePanelInfo panel;
108 struct GameButtonInfo button;
110 /* values for graphics engine customization */
111 boolean use_native_emc_graphics_engine;
112 boolean use_native_sp_graphics_engine;
113 boolean use_masked_pushing;
114 int forced_scroll_delay_value;
115 int scroll_delay_value;
118 /* values for engine initialization */
119 int default_push_delay_fixed;
120 int default_push_delay_random;
122 /* constant within running game */
125 int initial_move_delay[MAX_PLAYERS];
126 int initial_move_delay_value[MAX_PLAYERS];
127 int initial_push_delay_value;
129 /* flag for single or multi-player mode (needed for playing tapes) */
130 /* (when playing/recording games, this is identical to "setup.team_mode" */
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;
154 boolean no_time_limit; /* (variable only in very special case) */
156 /* values for the new EMC elements */
157 int lenses_time_left;
158 int magnify_time_left;
162 /* values for player idle animation (no effect on engine) */
163 int player_boring_delay_fixed;
164 int player_boring_delay_random;
165 int player_sleeping_delay_fixed;
166 int player_sleeping_delay_random;
168 /* values for special game initialization control */
169 boolean restart_level;
171 /* values for special game control */
172 int centered_player_nr;
173 int centered_player_nr_next;
174 boolean set_centered_player;
176 /* values for random number generator initialization after snapshot */
177 unsigned int num_random_calls;
182 boolean present; /* player present in level playfield */
183 boolean connected; /* player connected (locally or via network) */
184 boolean active; /* player present and connected */
185 boolean mapped; /* player already mapped to input device */
187 boolean killed; /* player maybe present/active, but killed */
188 boolean reanimated; /* player maybe killed, but reanimated */
190 int index_nr; /* player number (0 to 3) */
191 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
192 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
193 int client_nr; /* network client identifier */
195 byte action; /* action from local input device */
196 byte mapped_action; /* action mapped from device to player */
197 byte effective_action; /* action acknowledged from network server
198 or summarized over all configured input
199 devices when in single player mode */
200 byte programmed_action; /* action forced by game itself (like moving
201 through doors); overrides other actions */
203 int jx, jy, last_jx, last_jy;
204 int MovDir, MovPos, GfxDir, GfxPos;
205 int Frame, StepFrame;
209 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
213 boolean block_last_field;
214 int block_delay_adjustment; /* needed for different engine versions */
216 boolean can_fall_into_acid;
220 boolean LevelSolved, GameOver;
222 boolean LevelSolved_GameWon;
223 boolean LevelSolved_GameEnd;
224 boolean LevelSolved_PanelOff;
225 boolean LevelSolved_SaveTape;
226 boolean LevelSolved_SaveScore;
227 int LevelSolved_CountingTime;
228 int LevelSolved_CountingScore;
236 boolean is_auto_moving;
239 boolean is_collecting;
241 boolean is_switching;
243 boolean is_dropping_pressed;
250 int frame_counter_bored;
251 int frame_counter_sleeping;
253 int anim_delay_counter;
254 int post_delay_counter;
257 int action_waiting, last_action_waiting;
258 int special_action_bored;
259 int special_action_sleeping;
261 int num_special_action_bored;
262 int num_special_action_sleeping;
264 int switch_x, switch_y;
270 int move_delay_value;
271 int move_delay_value_next;
272 int move_delay_reset_counter;
275 int push_delay_value;
277 unsigned int actual_frame_counter;
280 int drop_pressed_delay;
287 int gems_still_needed;
288 int sokobanfields_still_needed;
289 int lights_still_needed;
290 int friends_still_needed;
291 int key[MAX_NUM_KEYS];
293 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
294 int shield_normal_time_left;
295 int shield_deadly_time_left;
297 int inventory_element[MAX_INVENTORY_SIZE];
298 int inventory_infinite_element;
302 extern struct GameInfo game;
303 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
307 void DEBUG_SetMaximumDynamite();
310 void GetPlayerConfig(void);
311 int GetElementFromGroupElement(int);
313 void DrawGameValue_Time(int);
314 void DrawGameDoorValues(void);
316 void UpdateAndDisplayGameControlValues();
318 void InitGameSound();
321 void UpdateEngineValues(int, int);
325 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
326 void Moving2Blocked(int, int, int *, int *);
327 void Blocked2Moving(int, int, int *, int *);
328 void DrawDynamite(int, int);
330 void StartGameActions(boolean, boolean, int);
332 void GameActions(void);
333 void GameActions_EM_Main();
334 void GameActions_SP_Main();
335 void GameActions_RND();
337 void ScrollLevel(int, int);
339 void InitPlayLevelSound();
340 void PlayLevelSound_EM(int, int, int, int);
341 void PlayLevelSound_SP(int, int, int, int);
343 void RaiseScore(int);
344 void RaiseScoreElement(int);
346 void RequestQuitGameExt(boolean, boolean, char *);
347 void RequestQuitGame(boolean);
349 unsigned int InitEngineRandom_RND(int);
350 unsigned int RND(int);
352 void FreeEngineSnapshotSingle();
353 void FreeEngineSnapshotList();
354 void LoadEngineSnapshotSingle();
355 void SaveEngineSnapshotSingle();
356 void SaveEngineSnapshotToList();
357 boolean CheckEngineSnapshot();
359 void CreateGameButtons();
360 void FreeGameButtons();
361 void MapStopPlayButtons();
362 void MapUndoRedoButtons();
363 void MapGameButtons();
364 void UnmapGameButtons();
365 void RedrawGameButtons();
367 void HandleSoundButtonKeys(Key);