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)
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 SNAPSHOT_MODE_OFF 0
40 #define SNAPSHOT_MODE_EVERY_STEP 1
41 #define SNAPSHOT_MODE_EVERY_MOVE 2
42 #define SNAPSHOT_MODE_EVERY_COLLECT 3
43 #define SNAPSHOT_MODE_DEFAULT SNAPSHOT_MODE_OFF
48 struct TextPosInfo level_number;
49 struct TextPosInfo gems;
50 struct TextPosInfo inventory_count;
51 struct TextPosInfo inventory_first[NUM_PANEL_INVENTORY];
52 struct TextPosInfo inventory_last[NUM_PANEL_INVENTORY];
53 struct TextPosInfo key[MAX_NUM_KEYS];
54 struct TextPosInfo key_white;
55 struct TextPosInfo key_white_count;
56 struct TextPosInfo score;
57 struct TextPosInfo highscore;
58 struct TextPosInfo time;
59 struct TextPosInfo time_hh;
60 struct TextPosInfo time_mm;
61 struct TextPosInfo time_ss;
62 struct TextPosInfo time_anim;
63 struct TextPosInfo health;
64 struct TextPosInfo health_anim;
65 struct TextPosInfo frame;
66 struct TextPosInfo shield_normal;
67 struct TextPosInfo shield_normal_time;
68 struct TextPosInfo shield_deadly;
69 struct TextPosInfo shield_deadly_time;
70 struct TextPosInfo exit;
71 struct TextPosInfo emc_magic_ball;
72 struct TextPosInfo emc_magic_ball_switch;
73 struct TextPosInfo light_switch;
74 struct TextPosInfo light_switch_time;
75 struct TextPosInfo timegate_switch;
76 struct TextPosInfo timegate_switch_time;
77 struct TextPosInfo switchgate_switch;
78 struct TextPosInfo emc_lenses;
79 struct TextPosInfo emc_lenses_time;
80 struct TextPosInfo emc_magnifier;
81 struct TextPosInfo emc_magnifier_time;
82 struct TextPosInfo balloon_switch;
83 struct TextPosInfo dynabomb_number;
84 struct TextPosInfo dynabomb_size;
85 struct TextPosInfo dynabomb_power;
86 struct TextPosInfo penguins;
87 struct TextPosInfo sokoban_objects;
88 struct TextPosInfo sokoban_fields;
89 struct TextPosInfo robot_wheel;
90 struct TextPosInfo conveyor_belt[NUM_BELTS];
91 struct TextPosInfo conveyor_belt_switch[NUM_BELTS];
92 struct TextPosInfo magic_wall;
93 struct TextPosInfo magic_wall_time;
94 struct TextPosInfo gravity_state;
95 struct TextPosInfo graphic[NUM_PANEL_GRAPHICS];
96 struct TextPosInfo element[NUM_PANEL_ELEMENTS];
97 struct TextPosInfo element_count[NUM_PANEL_ELEMENTS];
98 struct TextPosInfo ce_score[NUM_PANEL_CE_SCORE];
99 struct TextPosInfo ce_score_element[NUM_PANEL_CE_SCORE];
100 struct TextPosInfo player_name;
101 struct TextPosInfo level_name;
102 struct TextPosInfo level_author;
104 // value to determine if panel will be updated or not
108 struct GameButtonInfo
121 struct XY sound_music;
122 struct XY sound_loops;
123 struct XY sound_simple;
125 struct XY panel_stop;
126 struct XY panel_pause;
127 struct XY panel_play;
129 struct XY panel_sound_music;
130 struct XY panel_sound_loops;
131 struct XY panel_sound_simple;
134 struct GameSnapshotInfo
138 byte last_action[MAX_PLAYERS];
139 boolean changed_action;
140 boolean collected_item;
142 boolean save_snapshot;
147 // values for control panel
148 struct GamePanelInfo panel;
149 struct GameButtonInfo button;
151 // values for graphics engine customization
152 int graphics_engine_version;
153 boolean use_native_emc_graphics_engine;
154 boolean use_native_sp_graphics_engine;
155 boolean use_masked_pushing;
156 int forced_scroll_delay_value;
157 int scroll_delay_value;
160 // constant within running game
163 int initial_move_delay[MAX_PLAYERS];
164 int initial_move_delay_value[MAX_PLAYERS];
165 int initial_push_delay_value;
167 // flag for single or multi-player mode (needed for playing tapes)
168 // (when playing/recording games, this is identical to "setup.team_mode"
171 // flags to handle bugs in and changes between different engine versions
172 // (for the latest engine version, these flags should always be "FALSE")
173 boolean use_change_when_pushing_bug;
174 boolean use_block_last_field_bug;
175 boolean max_num_changes_per_frame;
176 boolean use_reverse_scan_direction;
178 // variable within running game
179 int yamyam_content_nr;
180 boolean robot_wheel_active;
181 boolean magic_wall_active;
182 int magic_wall_time_left;
184 int timegate_time_left;
189 boolean explosions_delayed;
190 boolean envelope_active;
191 boolean no_time_limit; // (variable only in very special case)
193 int gems_still_needed;
194 int sokoban_fields_still_needed;
195 int sokoban_objects_still_needed;
196 int lights_still_needed;
197 int players_still_needed;
198 int friends_still_needed;
200 // values for the new EMC elements
201 int lenses_time_left;
202 int magnify_time_left;
206 // values for player idle animation (no effect on engine)
207 int player_boring_delay_fixed;
208 int player_boring_delay_random;
209 int player_sleeping_delay_fixed;
210 int player_sleeping_delay_random;
212 // values for special game initialization control
213 boolean restart_level;
215 // trigger message to ask for restarting the game
216 char *restart_game_message;
218 // values for special request dialog control
219 boolean request_active;
221 // values for special game control
222 int centered_player_nr;
223 int centered_player_nr_next;
224 boolean set_centered_player;
226 // values for random number generator initialization after snapshot
227 unsigned int num_random_calls;
229 // values for game engine snapshot control
230 struct GameSnapshotInfo snapshot;
232 // values for handling states for solved level
235 boolean LevelSolved_GameWon;
236 boolean LevelSolved_GameEnd;
237 boolean LevelSolved_SaveTape;
238 boolean LevelSolved_SaveScore;
240 int LevelSolved_CountingTime;
241 int LevelSolved_CountingScore;
242 int LevelSolved_CountingHealth;
247 boolean present; // player present in level playfield
248 boolean connected_locally; // player connected (locally)
249 boolean connected_network; // player connected (network)
250 boolean connected; // player connected (locally or via network)
251 boolean active; // player present and connected
252 boolean mapped; // player already mapped to input device
254 boolean killed; // player maybe present/active, but killed
255 boolean reanimated; // player maybe killed, but reanimated
257 int index_nr; // player number (0 to 3)
258 int index_bit; // player number bit (1 << 0 to 1 << 3)
259 int element_nr; // element (EL_PLAYER_1 to EL_PLAYER_4)
260 int client_nr; // network client identifier
262 byte action; // action from local input device
263 byte mapped_action; // action mapped from device to player
264 byte effective_action; /* action acknowledged from network server
265 or summarized over all configured input
266 devices when in single player mode */
267 byte programmed_action; /* action forced by game itself (like moving
268 through doors); overrides other actions */
270 struct MouseActionInfo mouse_action; // (used by MM engine only)
271 struct MouseActionInfo effective_mouse_action; // (used by MM engine only)
273 int jx, jy, last_jx, last_jy;
274 int MovDir, MovPos, GfxDir, GfxPos;
275 int Frame, StepFrame;
279 int initial_element; // EL_PLAYER_1 to EL_PLAYER_4 or EL_SP_MURPHY
283 boolean block_last_field;
284 int block_delay_adjustment; // needed for different engine versions
286 boolean can_fall_into_acid;
298 boolean is_auto_moving;
301 boolean is_collecting;
303 boolean is_switching;
305 boolean is_dropping_pressed;
312 boolean was_snapping;
313 boolean was_dropping;
317 boolean force_dropping; // needed for single step mode
319 int frame_counter_bored;
320 int frame_counter_sleeping;
322 int anim_delay_counter;
323 int post_delay_counter;
326 int action_waiting, last_action_waiting;
327 int special_action_bored;
328 int special_action_sleeping;
330 int num_special_action_bored;
331 int num_special_action_sleeping;
333 int switch_x, switch_y;
339 int move_delay_value;
340 int move_delay_value_next;
341 int move_delay_reset_counter;
344 int push_delay_value;
346 unsigned int actual_frame_counter;
349 int drop_pressed_delay;
359 int key[MAX_NUM_KEYS];
361 int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
362 int shield_normal_time_left;
363 int shield_deadly_time_left;
365 int inventory_element[MAX_INVENTORY_SIZE];
366 int inventory_infinite_element;
370 extern struct GameInfo game;
371 extern struct PlayerInfo stored_player[MAX_PLAYERS], *local_player;
375 void DEBUG_SetMaximumDynamite(void);
378 void GetPlayerConfig(void);
379 int GetElementFromGroupElement(int);
381 int getPlayerInventorySize(int);
383 void DrawGameValue_Time(int);
384 void DrawGameDoorValues(void);
386 void UpdateAndDisplayGameControlValues(void);
388 void InitGameSound(void);
391 void UpdateEngineValues(int, int, int, int);
395 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
396 void Moving2Blocked(int, int, int *, int *);
397 void Blocked2Moving(int, int, int *, int *);
398 void DrawDynamite(int, int);
400 void StartGameActions(boolean, boolean, int);
402 void GameActions(void);
403 void GameActions_EM_Main(void);
404 void GameActions_SP_Main(void);
405 void GameActions_MM_Main(void);
406 void GameActions_RND_Main(void);
407 void GameActions_RND(void);
409 void ScrollLevel(int, int);
411 void InitPlayLevelSound(void);
412 void PlayLevelSound_EM(int, int, int, int);
413 void PlayLevelSound_SP(int, int, int, int);
414 void PlayLevelSound_MM(int, int, int, int);
415 void PlaySound_MM(int);
416 void PlaySoundLoop_MM(int);
417 void StopSound_MM(int);
419 void RaiseScore(int);
420 void RaiseScoreElement(int);
422 void RequestQuitGameExt(boolean, boolean, char *);
423 void RequestQuitGame(boolean);
424 void RequestRestartGame(char *);
425 void CheckGameOver(void);
427 boolean checkGameSolved(void);
428 boolean checkGameFailed(void);
429 boolean checkGameEnded(void);
431 unsigned int InitEngineRandom_RND(int);
432 unsigned int RND(int);
434 void FreeEngineSnapshotSingle(void);
435 void FreeEngineSnapshotList(void);
436 void LoadEngineSnapshotSingle(void);
437 void SaveEngineSnapshotSingle(void);
438 boolean CheckSaveEngineSnapshotToList(void);
439 void SaveEngineSnapshotToList(void);
440 void SaveEngineSnapshotToListInitial(void);
441 boolean CheckEngineSnapshotSingle(void);
442 boolean CheckEngineSnapshotList(void);
444 void CreateGameButtons(void);
445 void FreeGameButtons(void);
446 void MapUndoRedoButtons(void);
447 void UnmapUndoRedoButtons(void);
448 void MapGameButtons(void);
449 void UnmapGameButtons(void);
450 void RedrawGameButtons(void);
451 void MapGameButtonsOnTape(void);
452 void UnmapGameButtonsOnTape(void);
453 void RedrawGameButtonsOnTape(void);
455 void HandleSoundButtonKeys(Key);