rnd-20060812-2-src
[rocksndiamonds.git] / src / game.h
1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back!               *
3 *----------------------------------------------------------*
4 * (c) 1995-2002 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 #if 1
71   /* values for the new EMC elements */
72   int lenses_time_left;
73   int magnify_time_left;
74   boolean ball_state;
75   int ball_content_nr;
76 #endif
77
78   /* values for player idle animation (no effect on engine) */
79   int player_boring_delay_fixed;
80   int player_boring_delay_random;
81   int player_sleeping_delay_fixed;
82   int player_sleeping_delay_random;
83
84   /* values for special game initialization control */
85   boolean restart_level;
86
87   /* values for special game control */
88   int centered_player_nr;
89   int centered_player_nr_next;
90   boolean set_centered_player;
91 };
92
93 struct PlayerInfo
94 {
95   boolean present;              /* player present in level playfield */
96   boolean connected;            /* player connected (locally or via network) */
97   boolean active;               /* player present and connected */
98
99   int index_nr;                 /* player number (0 to 3) */
100   int index_bit;                /* player number bit (1 << 0 to 1 << 3) */
101   int element_nr;               /* element (EL_PLAYER_1 to EL_PLAYER_4) */
102   int client_nr;                /* network client identifier */
103
104   byte action;                  /* action from local input device */
105   byte effective_action;        /* action acknowledged from network server
106                                    or summarized over all configured input
107                                    devices when in single player mode */
108   byte programmed_action;       /* action forced by game itself (like moving
109                                    through doors); overrides other actions */
110
111   int jx, jy, last_jx, last_jy;
112   int MovDir, MovPos, GfxDir, GfxPos;
113   int Frame, StepFrame;
114
115   int GfxAction;
116
117   boolean use_murphy;
118   int artwork_element;
119
120   boolean block_last_field;
121   int block_delay_adjustment;   /* needed for different engine versions */
122
123   boolean can_fall_into_acid;
124
125   boolean gravity;
126
127   boolean LevelSolved, GameOver;
128
129   int last_move_dir;
130
131   boolean is_active;
132
133   boolean is_waiting;
134   boolean is_moving;
135   boolean is_auto_moving;
136   boolean is_digging;
137   boolean is_snapping;
138   boolean is_collecting;
139   boolean is_pushing;
140   boolean is_switching;
141   boolean is_dropping;
142   boolean is_dropping_pressed;
143
144   boolean is_bored;
145   boolean is_sleeping;
146
147   boolean cannot_move;
148
149   int frame_counter_bored;
150   int frame_counter_sleeping;
151
152   int anim_delay_counter;
153   int post_delay_counter;
154
155   int dir_waiting;
156   int action_waiting, last_action_waiting;
157   int special_action_bored;
158   int special_action_sleeping;
159
160   int num_special_action_bored;
161   int num_special_action_sleeping;
162
163   int switch_x, switch_y;
164   int drop_x, drop_y;
165
166   int show_envelope;
167
168   int move_delay;
169   int move_delay_value;
170   int move_delay_value_next;
171   int move_delay_reset_counter;
172
173   int push_delay;
174   int push_delay_value;
175
176   unsigned long actual_frame_counter;
177
178   int drop_delay;
179   int drop_pressed_delay;
180
181   int step_counter;
182
183   int score;
184   int gems_still_needed;
185   int sokobanfields_still_needed;
186   int lights_still_needed;
187   int friends_still_needed;
188   int key[MAX_NUM_KEYS];
189   int dynabomb_count, dynabomb_size, dynabombs_left, dynabomb_xl;
190   int shield_normal_time_left;
191   int shield_deadly_time_left;
192
193   int inventory_element[MAX_INVENTORY_SIZE];
194   int inventory_infinite_element;
195   int inventory_size;
196 };
197
198
199 extern struct GameInfo          game;
200 extern struct PlayerInfo        stored_player[], *local_player;
201
202
203 #ifdef DEBUG
204 void DEBUG_SetMaximumDynamite();
205 #endif
206
207 void GetPlayerConfig(void);
208
209 void DrawGameValue_Time(int);
210 void DrawGameDoorValues(void);
211
212 void InitGameSound();
213 void InitGame(void);
214
215 void UpdateEngineValues(int, int);
216 void GameWon(void);
217
218 void InitPlayerGfxAnimation(struct PlayerInfo *, int, int);
219 void Moving2Blocked(int, int, int *, int *);
220 void Blocked2Moving(int, int, int *, int *);
221 void DrawDynamite(int, int);
222
223 void StartGameActions(boolean, boolean, long);
224
225 void GameActions(void);
226 void GameActions_EM_Main();
227 void GameActions_RND();
228
229 void ScrollLevel(int, int);
230
231 void InitPlayLevelSound();
232 void PlayLevelSound_EM(int, int, int, int);
233
234 void RaiseScore(int);
235 void RaiseScoreElement(int);
236 void RequestQuitGame(boolean);
237
238 void CreateGameButtons();
239 void FreeGameButtons();
240 void UnmapGameButtons();
241
242 #endif