rnd-20070207-2-src
[rocksndiamonds.git] / src / game.h
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2006 Artsoft Entertainment                      *
5 *               Holger Schemel                             *
6 *               Detmolder Strasse 189                      *
7 *               33604 Bielefeld                            *
8 *               Germany                                    *
9 *               e-mail: info@artsoft.org                   *
10 *----------------------------------------------------------*
11 * game.h                                                   *
12 ***********************************************************/
13
14 #ifndef GAME_H
15 #define GAME_H
16
17 /* (not included here due to collisions with Emerald Mine engine definitions) */
18 /* #include "main.h" */
19
20 #define MAX_INVENTORY_SIZE      1000
21 #define STD_NUM_KEYS            4
22 #define MAX_NUM_KEYS            8
23
24
25 #if 1
26 struct GamePanelInfo
27 {
28   struct TextPosInfo level;
29   struct TextPosInfo gems;
30   struct TextPosInfo inventory;
31   struct TextPosInfo keys;
32   struct TextPosInfo score;
33   struct TextPosInfo time;
34 };
35 #else
36 struct GamePanelInfo
37 {
38   struct XY level;
39   struct XY gems;
40   struct XY inventory;
41   struct XY keys;
42   struct XY score;
43   struct XY time;
44 };
45 #endif
46
47 struct GameInfo
48 {
49   /* values for control panel */
50   struct GamePanelInfo panel;
51
52   /* values for engine initialization */
53   int default_push_delay_fixed;
54   int default_push_delay_random;
55
56   /* constant within running game */
57   int engine_version;
58   int emulation;
59   int initial_move_delay[MAX_PLAYERS];
60   int initial_move_delay_value[MAX_PLAYERS];
61   int initial_push_delay_value;
62
63   /* flags to handle bugs in and changes between different engine versions */
64   /* (for the latest engine version, these flags should always be "FALSE") */
65   boolean use_change_when_pushing_bug;
66   boolean use_block_last_field_bug;
67   boolean max_num_changes_per_frame;
68   boolean use_reverse_scan_direction;
69
70   /* variable within running game */
71   int yamyam_content_nr;
72   boolean magic_wall_active;
73   int magic_wall_time_left;
74   int light_time_left;
75   int timegate_time_left;
76   int belt_dir[4];
77   int belt_dir_nr[4];
78   int switchgate_pos;
79   int wind_direction;
80   boolean gravity;
81   boolean explosions_delayed;
82   boolean envelope_active;
83
84   /* values for the new EMC elements */
85   int lenses_time_left;
86   int magnify_time_left;
87   boolean ball_state;
88   int ball_content_nr;
89
90   /* values for player idle animation (no effect on engine) */
91   int player_boring_delay_fixed;
92   int player_boring_delay_random;
93   int player_sleeping_delay_fixed;
94   int player_sleeping_delay_random;
95
96   /* values for special game initialization control */
97   boolean restart_level;
98
99   /* values for special game control */
100   int centered_player_nr;
101   int centered_player_nr_next;
102   boolean set_centered_player;
103
104   /* values for random number generator initialization after snapshot */
105   unsigned long num_random_calls;
106 };
107
108 struct PlayerInfo
109 {
110   boolean present;              /* player present in level playfield */
111   boolean connected;            /* player connected (locally or via network) */
112   boolean active;               /* player present and connected */
113   boolean killed;               /* player maybe present/active, but killed */
114
115   int index_nr;                 /* player number (0 to 3) */
116   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
117   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
118   int client_nr;                /* network client identifier */
119
120   byte action;                  /* action from local input device */
121   byte effective_action;        /* action acknowledged from network server
122                                    or summarized over all configured input
123                                    devices when in single player mode */
124   byte programmed_action;       /* action forced by game itself (like moving
125                                    through doors); overrides other actions */
126
127   int jx, jy, last_jx, last_jy;
128   int MovDir, MovPos, GfxDir, GfxPos;
129   int Frame, StepFrame;
130
131   int GfxAction;
132
133   boolean use_murphy;
134   int artwork_element;
135
136   boolean block_last_field;
137   int block_delay_adjustment;   /* needed for different engine versions */
138
139   boolean can_fall_into_acid;
140
141   boolean gravity;
142
143   boolean LevelSolved, GameOver;
144
145   boolean LevelSolved_GameWon;
146   boolean LevelSolved_GameEnd;
147   boolean LevelSolved_PanelOff;
148   boolean LevelSolved_SaveTape;
149   boolean LevelSolved_SaveScore;
150
151   int last_move_dir;
152
153   boolean is_active;
154
155   boolean is_waiting;
156   boolean is_moving;
157   boolean is_auto_moving;
158   boolean is_digging;
159   boolean is_snapping;
160   boolean is_collecting;
161   boolean is_pushing;
162   boolean is_switching;
163   boolean is_dropping;
164   boolean is_dropping_pressed;
165
166   boolean is_bored;
167   boolean is_sleeping;
168
169   boolean cannot_move;
170
171   int frame_counter_bored;
172   int frame_counter_sleeping;
173
174   int anim_delay_counter;
175   int post_delay_counter;
176
177   int dir_waiting;
178   int action_waiting, last_action_waiting;
179   int special_action_bored;
180   int special_action_sleeping;
181
182   int num_special_action_bored;
183   int num_special_action_sleeping;
184
185   int switch_x, switch_y;
186   int drop_x, drop_y;
187
188   int show_envelope;
189
190   int move_delay;
191   int move_delay_value;
192   int move_delay_value_next;
193   int move_delay_reset_counter;
194
195   int push_delay;
196   int push_delay_value;
197
198   unsigned long actual_frame_counter;
199
200   int drop_delay;
201   int drop_pressed_delay;
202
203   int step_counter;
204
205   int score;
206   int score_final;
207
208   int gems_still_needed;
209   int sokobanfields_still_needed;
210   int lights_still_needed;
211   int friends_still_needed;
212   int key[MAX_NUM_KEYS];
213   int num_white_keys;
214   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
215   int shield_normal_time_left;
216   int shield_deadly_time_left;
217
218   int inventory_element[MAX_INVENTORY_SIZE];
219   int inventory_infinite_element;
220   int inventory_size;
221 };
222
223 extern struct GameInfo          game;
224 extern struct PlayerInfo        stored_player[MAX_PLAYERS], *local_player;
225
226
227 #ifdef DEBUG
228 void DEBUG_SetMaximumDynamite();
229 #endif
230
231 void GetPlayerConfig(void);
232
233 void DrawGameValue_Time(int);
234 void DrawGameDoorValues(void);
235
236 void InitGameSound();
237 void InitGame();
238
239 void UpdateEngineValues(int, int);
240 void GameWon(void);
241 void GameEnd(void);
242
243 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
244 void Moving2Blocked(int, int, int *, int *);
245 void Blocked2Moving(int, int, int *, int *);
246 void DrawDynamite(int, int);
247
248 void StartGameActions(boolean, boolean, long);
249
250 void GameActions(void);
251 void GameActions_EM_Main();
252 void GameActions_RND();
253
254 void ScrollLevel(int, int);
255
256 void InitPlayLevelSound();
257 void PlayLevelSound_EM(int, int, int, int);
258
259 void RaiseScore(int);
260 void RaiseScoreElement(int);
261
262 void RequestQuitGameExt(boolean, boolean, char *);
263 void RequestQuitGame(boolean);
264
265 unsigned int InitEngineRandom_RND(long);
266 unsigned int RND(int);
267
268 void FreeEngineSnapshot();
269 void LoadEngineSnapshot();
270 void SaveEngineSnapshot();
271 boolean CheckEngineSnapshot();
272
273 void CreateGameButtons();
274 void FreeGameButtons();
275 void UnmapGameButtons();
276
277 #endif