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;
126 boolean save_snapshot;
131 /* values for control panel */
132 struct GamePanelInfo panel;
133 struct GameButtonInfo button;
135 /* values for graphics engine customization */
136 int graphics_engine_version;
137 boolean use_native_emc_graphics_engine;
138 boolean use_native_sp_graphics_engine;
139 boolean use_masked_pushing;
140 int forced_scroll_delay_value;
141 int scroll_delay_value;
144 /* values for engine initialization */
145 int default_push_delay_fixed;
146 int default_push_delay_random;
148 /* constant within running game */
151 int initial_move_delay[MAX_PLAYERS];
152 int initial_move_delay_value[MAX_PLAYERS];
153 int initial_push_delay_value;
155 /* flag for single or multi-player mode (needed for playing tapes) */
156 /* (when playing/recording games, this is identical to "setup.team_mode" */
159 /* flags to handle bugs in and changes between different engine versions */
160 /* (for the latest engine version, these flags should always be "FALSE") */
161 boolean use_change_when_pushing_bug;
162 boolean use_block_last_field_bug;
163 boolean max_num_changes_per_frame;
164 boolean use_reverse_scan_direction;
166 /* variable within running game */
167 int yamyam_content_nr;
168 boolean robot_wheel_active;
169 boolean magic_wall_active;
170 int magic_wall_time_left;
172 int timegate_time_left;
178 boolean explosions_delayed;
179 boolean envelope_active;
180 boolean no_time_limit; /* (variable only in very special case) */
182 /* values for the new EMC elements */
183 int lenses_time_left;
184 int magnify_time_left;
188 /* values for player idle animation (no effect on engine) */
189 int player_boring_delay_fixed;
190 int player_boring_delay_random;
191 int player_sleeping_delay_fixed;
192 int player_sleeping_delay_random;
194 /* values for special game initialization control */
195 boolean restart_level;
197 /* values for special game control */
198 int centered_player_nr;
199 int centered_player_nr_next;
200 boolean set_centered_player;
202 /* values for random number generator initialization after snapshot */
203 unsigned int num_random_calls;
205 /* values for game engine snapshot control */
206 struct GameSnapshotInfo snapshot;
211 boolean present; /* player present in level playfield */
212 boolean connected; /* player connected (locally or via network) */
213 boolean active; /* player present and connected */
214 boolean mapped; /* player already mapped to input device */
216 boolean killed; /* player maybe present/active, but killed */
217 boolean reanimated; /* player maybe killed, but reanimated */
219 int index_nr; /* player number (0 to 3) */
220 int index_bit; /* player number bit (1 << 0 to 1 << 3) */
221 int element_nr; /* element (EL_PLAYER_1 to EL_PLAYER_4) */
222 int client_nr; /* network client identifier */
224 byte action; /* action from local input device */
225 byte mapped_action; /* action mapped from device to player */
226 byte effective_action; /* action acknowledged from network server
227 or summarized over all configured input
228 devices when in single player mode */
229 byte programmed_action; /* action forced by game itself (like moving
230 through doors); overrides other actions */
232 int jx, jy, last_jx, last_jy;
233 int MovDir, MovPos, GfxDir, GfxPos;
234 int Frame, StepFrame;
238 int initial_element; /* EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY */
242 boolean block_last_field;
243 int block_delay_adjustment; /* needed for different engine versions */
245 boolean can_fall_into_acid;
249 boolean LevelSolved, GameOver;
251 boolean LevelSolved_GameWon;
252 boolean LevelSolved_GameEnd;
253 boolean LevelSolved_PanelOff;
254 boolean LevelSolved_SaveTape;
255 boolean LevelSolved_SaveScore;
256 int LevelSolved_CountingTime;
257 int LevelSolved_CountingScore;
265 boolean is_auto_moving;
268 boolean is_collecting;
270 boolean is_switching;
272 boolean is_dropping_pressed;
279 boolean was_snapping;
280 boolean was_dropping;
284 int frame_counter_bored;
285 int frame_counter_sleeping;
287 int anim_delay_counter;
288 int post_delay_counter;
291 int action_waiting, last_action_waiting;
292 int special_action_bored;
293 int special_action_sleeping;
295 int num_special_action_bored;
296 int num_special_action_sleeping;
298 int switch_x, switch_y;
304 int move_delay_value;
305 int move_delay_value_next;
306 int move_delay_reset_counter;
309 int push_delay_value;
311 unsigned int actual_frame_counter;
314 int drop_pressed_delay;
321 int gems_still_needed;
322 int sokobanfields_still_needed;
323 int lights_still_needed;
324 int friends_still_needed;
325 int key[MAX_NUM_KEYS];
327 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
328 int shield_normal_time_left;
329 int shield_deadly_time_left;
331 int inventory_element[MAX_INVENTORY_SIZE];
332 int inventory_infinite_element;
336 extern struct GameInfo game;
337 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
341 void DEBUG_SetMaximumDynamite();
344 void GetPlayerConfig(void);
345 int GetElementFromGroupElement(int);
347 int getPlayerInventorySize(int);
349 void DrawGameValue_Time(int);
350 void DrawGameDoorValues(void);
352 void UpdateAndDisplayGameControlValues();
354 void InitGameSound();
357 void UpdateEngineValues(int, int, int, int);
361 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
362 void Moving2Blocked(int, int, int *, int *);
363 void Blocked2Moving(int, int, int *, int *);
364 void DrawDynamite(int, int);
366 void StartGameActions(boolean, boolean, int);
368 void GameActions(void);
369 void GameActions_EM_Main();
370 void GameActions_SP_Main();
371 void GameActions_RND_Main();
372 void GameActions_RND();
374 void ScrollLevel(int, int);
376 void InitPlayLevelSound();
377 void PlayLevelSound_EM(int, int, int, int);
378 void PlayLevelSound_SP(int, int, int, int);
380 void RaiseScore(int);
381 void RaiseScoreElement(int);
383 void RequestQuitGameExt(boolean, boolean, char *);
384 void RequestQuitGame(boolean);
386 unsigned int InitEngineRandom_RND(int);
387 unsigned int RND(int);
389 void FreeEngineSnapshotSingle();
390 void FreeEngineSnapshotList();
391 void LoadEngineSnapshotSingle();
392 void SaveEngineSnapshotSingle();
393 boolean CheckSaveEngineSnapshotToList();
394 void SaveEngineSnapshotToList();
395 void SaveEngineSnapshotToListInitial();
396 boolean CheckEngineSnapshotSingle();
397 boolean CheckEngineSnapshotList();
399 void CreateGameButtons();
400 void FreeGameButtons();
401 void MapUndoRedoButtons();
402 void UnmapUndoRedoButtons();
403 void MapGameButtons();
404 void UnmapGameButtons();
405 void RedrawGameButtons();
407 void HandleSoundButtonKeys(Key);