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