1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
15 // (not included here due to collisions with Emerald Mine engine definitions)
18 #define MAX_INVENTORY_SIZE 1000
20 #define MAX_HEALTH 100
22 #define STD_NUM_KEYS 4
23 #define MAX_NUM_KEYS 8
26 #define NUM_BELT_PARTS 3
28 #define NUM_PANEL_INVENTORY 8
29 #define NUM_PANEL_GRAPHICS 8
30 #define NUM_PANEL_ELEMENTS 8
31 #define NUM_PANEL_CE_SCORE 8
33 #define STR_SNAPSHOT_MODE_OFF "off"
34 #define STR_SNAPSHOT_MODE_EVERY_STEP "every_step"
35 #define STR_SNAPSHOT_MODE_EVERY_MOVE "every_move"
36 #define STR_SNAPSHOT_MODE_EVERY_COLLECT "every_collect"
37 #define STR_SNAPSHOT_MODE_DEFAULT STR_SNAPSHOT_MODE_OFF
39 #define STR_SCORES_TYPE_LOCAL_ONLY "local_scores_only"
40 #define STR_SCORES_TYPE_SERVER_ONLY "server_scores_only"
41 #define STR_SCORES_TYPE_LOCAL_AND_SERVER "local_and_server_scores"
42 #define STR_SCORES_TYPE_DEFAULT STR_SCORES_TYPE_LOCAL_AND_SERVER
44 #define SNAPSHOT_MODE_OFF 0
45 #define SNAPSHOT_MODE_EVERY_STEP 1
46 #define SNAPSHOT_MODE_EVERY_MOVE 2
47 #define SNAPSHOT_MODE_EVERY_COLLECT 3
48 #define SNAPSHOT_MODE_DEFAULT SNAPSHOT_MODE_OFF
53 struct TextPosInfo level_number;
54 struct TextPosInfo gems;
55 struct TextPosInfo gems_total;
56 struct TextPosInfo gems_collected;
57 struct TextPosInfo gems_score;
58 struct TextPosInfo inventory_count;
59 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
60 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
61 struct TextPosInfo key[MAX_NUM_KEYS];
62 struct TextPosInfo key_white;
63 struct TextPosInfo key_white_count;
64 struct TextPosInfo score;
65 struct TextPosInfo highscore;
66 struct TextPosInfo time;
67 struct TextPosInfo time_hh;
68 struct TextPosInfo time_mm;
69 struct TextPosInfo time_ss;
70 struct TextPosInfo time_anim;
71 struct TextPosInfo health;
72 struct TextPosInfo health_anim;
73 struct TextPosInfo frame;
74 struct TextPosInfo shield_normal;
75 struct TextPosInfo shield_normal_time;
76 struct TextPosInfo shield_deadly;
77 struct TextPosInfo shield_deadly_time;
78 struct TextPosInfo exit;
79 struct TextPosInfo emc_magic_ball;
80 struct TextPosInfo emc_magic_ball_switch;
81 struct TextPosInfo light_switch;
82 struct TextPosInfo light_switch_time;
83 struct TextPosInfo timegate_switch;
84 struct TextPosInfo timegate_switch_time;
85 struct TextPosInfo switchgate_switch;
86 struct TextPosInfo emc_lenses;
87 struct TextPosInfo emc_lenses_time;
88 struct TextPosInfo emc_magnifier;
89 struct TextPosInfo emc_magnifier_time;
90 struct TextPosInfo balloon_switch;
91 struct TextPosInfo dynabomb_number;
92 struct TextPosInfo dynabomb_size;
93 struct TextPosInfo dynabomb_power;
94 struct TextPosInfo penguins;
95 struct TextPosInfo sokoban_objects;
96 struct TextPosInfo sokoban_fields;
97 struct TextPosInfo robot_wheel;
98 struct TextPosInfo conveyor_belt[NUM_BELTS];
99 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
100 struct TextPosInfo magic_wall;
101 struct TextPosInfo magic_wall_time;
102 struct TextPosInfo gravity_state;
103 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
104 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
105 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
106 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
107 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
108 struct TextPosInfo player_name;
109 struct TextPosInfo level_name;
110 struct TextPosInfo level_author;
112 // value to determine if panel will be updated or not
116 struct GameButtonInfo
131 struct XY sound_music;
132 struct XY sound_loops;
133 struct XY sound_simple;
135 struct XY panel_stop;
136 struct XY panel_pause;
137 struct XY panel_play;
139 struct XY panel_restart;
141 struct XY panel_sound_music;
142 struct XY panel_sound_loops;
143 struct XY panel_sound_simple;
145 struct XY touch_stop;
146 struct XY touch_pause;
147 struct XY touch_restart;
150 struct GameSnapshotInfo
154 byte last_action[MAX_PLAYERS];
155 boolean changed_action;
156 boolean collected_item;
158 boolean save_snapshot;
163 // values for control panel
164 struct GamePanelInfo panel;
165 struct GameButtonInfo button;
167 // values for graphics engine customization
168 int graphics_engine_version;
169 boolean use_native_emc_graphics_engine;
170 boolean use_native_sp_graphics_engine;
171 boolean use_masked_pushing;
172 boolean use_masked_elements;
173 boolean use_masked_elements_initial;
176 int forced_scroll_delay_value;
177 int scroll_delay_value;
180 // constant within running game
183 int initial_move_delay[MAX_PLAYERS];
184 int initial_move_delay_value[MAX_PLAYERS];
185 int initial_push_delay_value;
187 // flag for single or multi-player mode (needed for playing tapes)
188 // (when playing/recording games, this is identical to "setup.team_mode"
191 // flags to handle bugs in and changes between different engine versions
192 // (for the latest engine version, these flags should always be "FALSE")
193 boolean use_change_when_pushing_bug;
194 boolean use_block_last_field_bug;
195 boolean max_num_changes_per_frame;
196 boolean use_reverse_scan_direction;
198 // flags to indicate which game actions are used in this game
199 boolean use_key_actions;
200 boolean use_mouse_actions;
202 // variable within running game
203 int yamyam_content_nr;
204 boolean robot_wheel_active;
205 boolean magic_wall_active;
206 int magic_wall_time_left;
208 int timegate_time_left;
214 boolean explosions_delayed;
215 boolean envelope_active;
216 boolean no_level_time_limit; // (variable only in very special case)
217 boolean time_limit; // forced by levelset config or setup option
219 int time_final; // time (in seconds) or steps left or played
220 int score_time_final; // time (in frames) or steps played
228 int gems_still_needed;
229 int sokoban_fields_still_needed;
230 int sokoban_objects_still_needed;
231 int lights_still_needed;
232 int players_still_needed;
233 int friends_still_needed;
235 int robot_wheel_x, robot_wheel_y;
238 boolean all_players_gone;
240 // values for the new EMC elements
241 int lenses_time_left;
242 int magnify_time_left;
246 // values for player idle animation (no effect on engine)
247 int player_boring_delay_fixed;
248 int player_boring_delay_random;
249 int player_sleeping_delay_fixed;
250 int player_sleeping_delay_random;
252 // values for special game initialization control
253 boolean restart_level;
255 // values for special request dialog control
256 boolean request_active;
258 // values for special game control
259 int centered_player_nr;
260 int centered_player_nr_next;
261 boolean set_centered_player;
262 boolean set_centered_player_wrap;
264 // values for single step mode control
265 boolean enter_single_step_mode;
267 // values for random number generator initialization after snapshot
268 unsigned int num_random_calls;
270 // values for game engine snapshot control
271 struct GameSnapshotInfo snapshot;
273 // values for handling states for solved level and game over
278 boolean LevelSolved_GameWon;
279 boolean LevelSolved_GameEnd;
280 boolean LevelSolved_SaveTape;
281 boolean LevelSolved_SaveScore;
283 int LevelSolved_CountingTime;
284 int LevelSolved_CountingScore;
285 int LevelSolved_CountingHealth;
287 boolean RestartGameRequested;
292 boolean present; // player present in level playfield
293 boolean connected_locally; // player connected (locally)
294 boolean connected_network; // player connected (network)
295 boolean connected; // player connected (locally or via network)
296 boolean active; // player present and connected
297 boolean mapped; // player already mapped to input device
299 boolean killed; // player maybe present/active, but killed
300 boolean reanimated; // player maybe killed, but reanimated
301 boolean buried; // player finally killed and removed
303 int index_nr; // player number (0 to 3)
304 int index_bit; // player number bit (1 << 0 to 1 << 3)
305 int element_nr; // element (EL_PLAYER_1 to EL_PLAYER_4)
306 int client_nr; // network client identifier
308 byte action; // action from local input device
309 byte effective_action; /* action acknowledged from network server
310 or summarized over all configured input
311 devices when in single player mode */
312 byte programmed_action; /* action forced by game itself (like moving
313 through doors); overrides other actions */
314 byte snap_action; // action from TAS snap keys
316 struct MouseActionInfo mouse_action; // (used by MM engine only)
317 struct MouseActionInfo effective_mouse_action; // (used by MM engine only)
319 int jx, jy, last_jx, last_jy;
320 int MovDir, MovPos, GfxDir, GfxPos;
321 int Frame, StepFrame;
325 int initial_element; // EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY
329 boolean block_last_field;
330 int block_delay_adjustment; // needed for different engine versions
332 boolean can_fall_into_acid;
342 boolean is_auto_moving;
345 boolean is_collecting;
347 boolean is_switching;
349 boolean is_dropping_pressed;
356 boolean was_snapping;
357 boolean was_dropping;
361 boolean force_dropping; // needed for single step mode
363 int frame_counter_bored;
364 int frame_counter_sleeping;
366 int anim_delay_counter;
367 int post_delay_counter;
370 int action_waiting, last_action_waiting;
371 int special_action_bored;
372 int special_action_sleeping;
374 int num_special_action_bored;
375 int num_special_action_sleeping;
377 int switch_x, switch_y;
383 int move_delay_value;
384 int move_delay_value_next;
385 int move_delay_reset_counter;
388 int push_delay_value;
390 DelayCounter actual_frame_counter;
393 int drop_pressed_delay;
397 int key[MAX_NUM_KEYS];
399 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
400 int shield_normal_time_left;
401 int shield_deadly_time_left;
403 int last_removed_element;
405 int inventory_element[MAX_INVENTORY_SIZE];
406 int inventory_infinite_element;
410 extern struct GameInfo game;
411 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
415 void DEBUG_SetMaximumDynamite(void);
418 void GetPlayerConfig(void);
419 int GetElementFromGroupElement(int);
421 int getPlayerInventorySize(int);
423 void UpdateGameDoorValues(void);
424 void DrawGameDoorValues(void);
426 void UpdateAndDisplayGameControlValues(void);
428 void InitGameSound(void);
431 void UpdateEngineValues(int, int, int, int);
435 void MergeServerScore(void);
437 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
439 void Moving2Blocked(int, int, int *, int *);
440 void Blocked2Moving(int, int, int *, int *);
442 void DrawDynamite(int, int);
444 void StartGameActions(boolean, boolean, int);
446 void GameActions(void);
447 void GameActions_EM_Main(void);
448 void GameActions_SP_Main(void);
449 void GameActions_MM_Main(void);
450 void GameActions_RND_Main(void);
451 void GameActions_RND(void);
453 void ScrollLevel(int, int);
455 void InitPlayLevelSound(void);
456 void PlayLevelSound_EM(int, int, int, int);
457 void PlayLevelSound_SP(int, int, int, int);
458 void PlayLevelSound_MM(int, int, int, int);
459 void PlaySound_MM(int);
460 void PlaySoundLoop_MM(int);
461 void StopSound_MM(int);
463 void RaiseScore(int);
464 void RaiseScoreElement(int);
466 void RequestQuitGameExt(boolean, boolean, char *);
467 void RequestQuitGame(boolean);
469 boolean CheckRestartGame(void);
470 boolean checkGameSolved(void);
471 boolean checkGameFailed(void);
472 boolean checkGameEnded(void);
474 unsigned int InitEngineRandom_RND(int);
475 unsigned int RND(int);
477 void FreeEngineSnapshotSingle(void);
478 void FreeEngineSnapshotList(void);
479 void LoadEngineSnapshotSingle(void);
480 void SaveEngineSnapshotSingle(void);
481 boolean CheckSaveEngineSnapshotToList(void);
482 void SaveEngineSnapshotToList(void);
483 void SaveEngineSnapshotToListInitial(void);
484 boolean CheckEngineSnapshotSingle(void);
485 boolean CheckEngineSnapshotList(void);
487 void CreateGameButtons(void);
488 void FreeGameButtons(void);
489 void MapLoadSaveButtons(void);
490 void MapUndoRedoButtons(void);
491 void ModifyPauseButtons(void);
492 void MapGameButtons(void);
493 void UnmapGameButtons(void);
494 void RedrawGameButtons(void);
495 void MapGameButtonsOnTape(void);
496 void UnmapGameButtonsOnTape(void);
497 void RedrawGameButtonsOnTape(void);
499 void HandleSoundButtonKeys(Key);