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_needed;
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 no_level_time_limit; // (variable only in very special case)
220 boolean time_limit; // forced by levelset config or setup option
222 int time_final; // time (in seconds) or steps left or played
223 int score_time_final; // time (in frames) or steps played
231 int gems_still_needed;
232 int sokoban_fields_still_needed;
233 int sokoban_objects_still_needed;
234 int lights_still_needed;
235 int players_still_needed;
236 int friends_still_needed;
238 int robot_wheel_x, robot_wheel_y;
241 boolean all_players_gone;
243 // values for the new EMC elements
244 int lenses_time_left;
245 int magnify_time_left;
249 // values for player idle animation (no effect on engine)
250 int player_boring_delay_fixed;
251 int player_boring_delay_random;
252 int player_sleeping_delay_fixed;
253 int player_sleeping_delay_random;
255 // values for special game initialization control
256 boolean restart_level;
258 // values for special request dialog control
259 boolean request_active;
260 boolean envelope_active;
261 boolean any_door_active;
263 // values for special game control
264 int centered_player_nr;
265 int centered_player_nr_next;
266 boolean set_centered_player;
267 boolean set_centered_player_wrap;
269 // values for single step mode control
270 boolean enter_single_step_mode;
272 // values for random number generator initialization after snapshot
273 unsigned int num_random_calls;
275 // values for game engine snapshot control
276 struct GameSnapshotInfo snapshot;
278 // values for handling states for solved level and game over
283 boolean LevelSolved_GameWon;
284 boolean LevelSolved_GameEnd;
285 boolean LevelSolved_SaveTape;
286 boolean LevelSolved_SaveScore;
288 int LevelSolved_CountingTime;
289 int LevelSolved_CountingScore;
290 int LevelSolved_CountingHealth;
292 boolean RestartGameRequested;
297 boolean present; // player present in level playfield
298 boolean connected_locally; // player connected (locally)
299 boolean connected_network; // player connected (network)
300 boolean connected; // player connected (locally or via network)
301 boolean active; // player present and connected
302 boolean mapped; // player already mapped to input device
304 boolean killed; // player maybe present/active, but killed
305 boolean reanimated; // player maybe killed, but reanimated
306 boolean buried; // player finally killed and removed
308 int index_nr; // player number (0 to 3)
309 int index_bit; // player number bit (1 << 0 to 1 << 3)
310 int element_nr; // element (EL_PLAYER_1 to EL_PLAYER_4)
311 int client_nr; // network client identifier
313 byte action; // action from local input device
314 byte effective_action; /* action acknowledged from network server
315 or summarized over all configured input
316 devices when in single player mode */
317 byte programmed_action; /* action forced by game itself (like moving
318 through doors); overrides other actions */
319 byte snap_action; // action from TAS snap keys
321 struct MouseActionInfo mouse_action; // (used by MM engine only)
322 struct MouseActionInfo effective_mouse_action; // (used by MM engine only)
324 int jx, jy, last_jx, last_jy;
325 int MovDir, MovPos, GfxDir, GfxPos;
326 int Frame, StepFrame;
330 int initial_element; // EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY
334 boolean block_last_field;
335 int block_delay_adjustment; // needed for different engine versions
337 boolean can_fall_into_acid;
347 boolean is_auto_moving;
350 boolean is_collecting;
352 boolean is_switching;
354 boolean is_dropping_pressed;
361 boolean was_snapping;
362 boolean was_dropping;
366 boolean force_dropping; // needed for single step mode
368 int frame_counter_bored;
369 int frame_counter_sleeping;
371 int anim_delay_counter;
372 int post_delay_counter;
375 int action_waiting, last_action_waiting;
376 int special_action_bored;
377 int special_action_sleeping;
379 int num_special_action_bored;
380 int num_special_action_sleeping;
382 int switch_x, switch_y;
388 int move_delay_value;
389 int move_delay_value_next;
390 int move_delay_reset_counter;
393 int push_delay_value;
395 DelayCounter actual_frame_counter;
398 int drop_pressed_delay;
402 int key[MAX_NUM_KEYS];
404 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
405 int shield_normal_time_left;
406 int shield_deadly_time_left;
408 int last_removed_element;
410 int inventory_element[MAX_INVENTORY_SIZE];
411 int inventory_infinite_element;
415 extern struct GameInfo game;
416 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
420 void DEBUG_SetMaximumDynamite(void);
423 void GetPlayerConfig(void);
424 int GetElementFromGroupElement(int);
426 int getPlayerInventorySize(int);
428 void UpdateGameDoorValues(void);
429 void DrawGameDoorValues(void);
431 void UpdateAndDisplayGameControlValues(void);
433 void InitGameSound(void);
436 void UpdateEngineValues(int, int, int, int);
440 void MergeServerScore(void);
442 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
444 void Moving2Blocked(int, int, int *, int *);
445 void Blocked2Moving(int, int, int *, int *);
447 void DrawDynamite(int, int);
449 void StartGameActions(boolean, boolean, int);
451 void GameActions(void);
452 void GameActions_BD_Main(void);
453 void GameActions_EM_Main(void);
454 void GameActions_SP_Main(void);
455 void GameActions_MM_Main(void);
456 void GameActions_RND_Main(void);
457 void GameActions_RND(void);
459 void ScrollLevel(int, int);
461 void InitPlayLevelSound(void);
462 void PlayLevelSound_EM(int, int, int, int);
463 void PlayLevelSound_SP(int, int, int, int);
464 void PlayLevelSound_MM(int, int, int, int);
465 void PlaySound_MM(int);
466 void PlaySoundLoop_MM(int);
467 void StopSound_MM(int);
469 void RaiseScore(int);
470 void RaiseScoreElement(int);
472 void RequestQuitGameExt(boolean, boolean, char *);
473 void RequestQuitGame(boolean);
475 boolean CheckRestartGame(void);
476 boolean checkGameRunning(void);
477 boolean checkGamePlaying(void);
478 boolean checkGameSolved(void);
479 boolean checkGameFailed(void);
480 boolean checkGameEnded(void);
481 boolean checkRequestActive(void);
483 unsigned int InitEngineRandom_RND(int);
484 unsigned int RND(int);
486 void FreeEngineSnapshotSingle(void);
487 void FreeEngineSnapshotList(void);
488 void LoadEngineSnapshotSingle(void);
489 void SaveEngineSnapshotSingle(void);
490 boolean CheckSaveEngineSnapshotToList(void);
491 void SaveEngineSnapshotToList(void);
492 void SaveEngineSnapshotToListInitial(void);
493 boolean CheckEngineSnapshotSingle(void);
494 boolean CheckEngineSnapshotList(void);
496 void CreateGameButtons(void);
497 void FreeGameButtons(void);
498 void MapLoadSaveButtons(void);
499 void MapUndoRedoButtons(void);
500 void ModifyPauseButtons(void);
501 void MapGameButtons(void);
502 void UnmapGameButtons(void);
503 void RedrawGameButtons(void);
504 void MapGameButtonsOnTape(void);
505 void UnmapGameButtonsOnTape(void);
506 void RedrawGameButtonsOnTape(void);
508 void HandleSoundButtonKeys(Key);