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