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_bd_graphics_engine;
170 boolean use_native_emc_graphics_engine;
171 boolean use_native_sp_graphics_engine;
172 boolean use_masked_pushing;
173 boolean use_masked_elements;
174 boolean use_masked_elements_initial;
177 int forced_scroll_delay_value;
178 int scroll_delay_value;
181 // values for sound engine customization
182 boolean use_native_bd_sound_engine;
184 // constant within running game
187 int initial_move_delay[MAX_PLAYERS];
188 int initial_move_delay_value[MAX_PLAYERS];
189 int initial_push_delay_value;
191 // flag for single or multi-player mode (needed for playing tapes)
192 // (when playing/recording games, this is identical to "setup.team_mode"
195 // flags to handle bugs in and changes between different engine versions
196 // (for the latest engine version, these flags should always be "FALSE")
197 boolean use_change_when_pushing_bug;
198 boolean use_block_last_field_bug;
199 boolean max_num_changes_per_frame;
200 boolean use_reverse_scan_direction;
202 // flags to indicate which game actions are used in this game
203 boolean use_key_actions;
204 boolean use_mouse_actions;
206 // variable within running game
207 int yamyam_content_nr;
208 boolean robot_wheel_active;
209 boolean magic_wall_active;
210 int magic_wall_time_left;
212 int timegate_time_left;
218 boolean explosions_delayed;
219 boolean envelope_active;
220 boolean no_level_time_limit; // (variable only in very special case)
221 boolean time_limit; // forced by levelset config or setup option
223 int time_final; // time (in seconds) or steps left or played
224 int score_time_final; // time (in frames) or steps played
232 int gems_still_needed;
233 int sokoban_fields_still_needed;
234 int sokoban_objects_still_needed;
235 int lights_still_needed;
236 int players_still_needed;
237 int friends_still_needed;
239 int robot_wheel_x, robot_wheel_y;
242 boolean all_players_gone;
244 // values for the new EMC elements
245 int lenses_time_left;
246 int magnify_time_left;
250 // values for player idle animation (no effect on engine)
251 int player_boring_delay_fixed;
252 int player_boring_delay_random;
253 int player_sleeping_delay_fixed;
254 int player_sleeping_delay_random;
256 // values for special game initialization control
257 boolean restart_level;
259 // values for special request dialog control
260 boolean request_active;
262 // values for special game control
263 int centered_player_nr;
264 int centered_player_nr_next;
265 boolean set_centered_player;
266 boolean set_centered_player_wrap;
268 // values for single step mode control
269 boolean enter_single_step_mode;
271 // values for random number generator initialization after snapshot
272 unsigned int num_random_calls;
274 // values for game engine snapshot control
275 struct GameSnapshotInfo snapshot;
277 // values for handling states for solved level and game over
282 boolean LevelSolved_GameWon;
283 boolean LevelSolved_GameEnd;
284 boolean LevelSolved_SaveTape;
285 boolean LevelSolved_SaveScore;
287 int LevelSolved_CountingTime;
288 int LevelSolved_CountingScore;
289 int LevelSolved_CountingHealth;
291 boolean RestartGameRequested;
296 boolean present; // player present in level playfield
297 boolean connected_locally; // player connected (locally)
298 boolean connected_network; // player connected (network)
299 boolean connected; // player connected (locally or via network)
300 boolean active; // player present and connected
301 boolean mapped; // player already mapped to input device
303 boolean killed; // player maybe present/active, but killed
304 boolean reanimated; // player maybe killed, but reanimated
305 boolean buried; // player finally killed and removed
307 int index_nr; // player number (0 to 3)
308 int index_bit; // player number bit (1 << 0 to 1 << 3)
309 int element_nr; // element (EL_PLAYER_1 to EL_PLAYER_4)
310 int client_nr; // network client identifier
312 byte action; // action from local input device
313 byte effective_action; /* action acknowledged from network server
314 or summarized over all configured input
315 devices when in single player mode */
316 byte programmed_action; /* action forced by game itself (like moving
317 through doors); overrides other actions */
318 byte snap_action; // action from TAS snap keys
320 struct MouseActionInfo mouse_action; // (used by MM engine only)
321 struct MouseActionInfo effective_mouse_action; // (used by MM engine only)
323 int jx, jy, last_jx, last_jy;
324 int MovDir, MovPos, GfxDir, GfxPos;
325 int Frame, StepFrame;
329 int initial_element; // EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY
333 boolean block_last_field;
334 int block_delay_adjustment; // needed for different engine versions
336 boolean can_fall_into_acid;
346 boolean is_auto_moving;
349 boolean is_collecting;
351 boolean is_switching;
353 boolean is_dropping_pressed;
360 boolean was_snapping;
361 boolean was_dropping;
365 boolean force_dropping; // needed for single step mode
367 int frame_counter_bored;
368 int frame_counter_sleeping;
370 int anim_delay_counter;
371 int post_delay_counter;
374 int action_waiting, last_action_waiting;
375 int special_action_bored;
376 int special_action_sleeping;
378 int num_special_action_bored;
379 int num_special_action_sleeping;
381 int switch_x, switch_y;
387 int move_delay_value;
388 int move_delay_value_next;
389 int move_delay_reset_counter;
392 int push_delay_value;
394 DelayCounter actual_frame_counter;
397 int drop_pressed_delay;
401 int key[MAX_NUM_KEYS];
403 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
404 int shield_normal_time_left;
405 int shield_deadly_time_left;
407 int last_removed_element;
409 int inventory_element[MAX_INVENTORY_SIZE];
410 int inventory_infinite_element;
414 extern struct GameInfo game;
415 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
419 void DEBUG_SetMaximumDynamite(void);
422 void GetPlayerConfig(void);
423 int GetElementFromGroupElement(int);
425 int getPlayerInventorySize(int);
427 void UpdateGameDoorValues(void);
428 void DrawGameDoorValues(void);
430 void UpdateAndDisplayGameControlValues(void);
432 void InitGameSound(void);
435 void UpdateEngineValues(int, int, int, int);
439 void MergeServerScore(void);
441 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
443 void Moving2Blocked(int, int, int *, int *);
444 void Blocked2Moving(int, int, int *, int *);
446 void DrawDynamite(int, int);
448 void StartGameActions(boolean, boolean, int);
450 void GameActions(void);
451 void GameActions_BD_Main(void);
452 void GameActions_EM_Main(void);
453 void GameActions_SP_Main(void);
454 void GameActions_MM_Main(void);
455 void GameActions_RND_Main(void);
456 void GameActions_RND(void);
458 void ScrollLevel(int, int);
460 void InitPlayLevelSound(void);
461 void PlayLevelSound_EM(int, int, int, int);
462 void PlayLevelSound_SP(int, int, int, int);
463 void PlayLevelSound_MM(int, int, int, int);
464 void PlaySound_MM(int);
465 void PlaySoundLoop_MM(int);
466 void StopSound_MM(int);
468 void RaiseScore(int);
469 void RaiseScoreElement(int);
471 void RequestQuitGameExt(boolean, boolean, char *);
472 void RequestQuitGame(boolean);
474 boolean CheckRestartGame(void);
475 boolean checkGameRunning(void);
476 boolean checkGamePlaying(void);
477 boolean checkGameSolved(void);
478 boolean checkGameFailed(void);
479 boolean checkGameEnded(void);
481 unsigned int InitEngineRandom_RND(int);
482 unsigned int RND(int);
484 void FreeEngineSnapshotSingle(void);
485 void FreeEngineSnapshotList(void);
486 void LoadEngineSnapshotSingle(void);
487 void SaveEngineSnapshotSingle(void);
488 boolean CheckSaveEngineSnapshotToList(void);
489 void SaveEngineSnapshotToList(void);
490 void SaveEngineSnapshotToListInitial(void);
491 boolean CheckEngineSnapshotSingle(void);
492 boolean CheckEngineSnapshotList(void);
494 void CreateGameButtons(void);
495 void FreeGameButtons(void);
496 void MapLoadSaveButtons(void);
497 void MapUndoRedoButtons(void);
498 void ModifyPauseButtons(void);
499 void MapGameButtons(void);
500 void UnmapGameButtons(void);
501 void RedrawGameButtons(void);
502 void MapGameButtonsOnTape(void);
503 void UnmapGameButtonsOnTape(void);
504 void RedrawGameButtonsOnTape(void);
506 void HandleSoundButtonKeys(Key);