1 /* $Id: proto.h,v 5.48 2003/09/16 21:01:48 bertg Exp $
2  *
3  * XPilot, a multiplayer gravity war game.  Copyright (C) 1991-2001 by
4  *
5  *      Bj�rn Stabell        <bjoern@xpilot.org>
6  *      Ken Ronny Schouten   <ken@xpilot.org>
7  *      Bert Gijsbers        <bert@xpilot.org>
8  *      Dick Balaska         <dick@xpilot.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  */
24 
25 #ifndef	PROTO_H
26 #define	PROTO_H
27 
28 #ifndef OBJECT_H
29 /* need player */
30 #include "object.h"
31 #endif
32 
33 #ifndef LIST_H_INCLUDED
34 /* need list_t */
35 #include "list.h"
36 #endif
37 
38 /*
39  * Prototypes for cell.c
40  */
41 void Free_cells(void);
42 void Alloc_cells(void);
43 void Cell_init_object(object *obj);
44 void Cell_add_object(object *obj);
45 void Cell_remove_object(object *obj);
46 void Cell_get_objects(int x, int y, int r, int max, object ***list, int *count);
47 
48 /*
49  * Prototypes for collision.c
50  */
51 void Check_collision(void);
52 int wormXY(int x, int y);
53 int IsOffensiveItem(enum Item i);
54 int IsDefensiveItem(enum Item i);
55 int CountOffensiveItems(player *pl);
56 int CountDefensiveItems(player *pl);
57 
58 /*
59  * Prototypes for id.c
60  */
61 int peek_ID(void);
62 int request_ID(void);
63 void release_ID(int id);
64 
65 /*
66  * Prototypes for walls.c
67  */
68 void Walls_init(void);
69 void Treasure_init(void);
70 void Move_init(void);
71 void Move_object(object *obj);
72 void Move_player(int ind);
73 void Turn_player(int ind);
74 
75 /*
76  * Prototypes for event.c
77  */
78 int Handle_keyboard(int);
79 void Pause_player(int ind, int onoff);
80 int Player_lock_closest(int ind, int next);
81 bool team_dead(int team);
82 void filter_mods(modifiers *mods);
83 
84 /*
85  * Prototypes for map.c
86  */
87 void Free_map(void);
88 bool Grok_map(void);
89 void Find_base_direction(void);
90 void Compute_gravity(void);
91 DFLOAT Wrap_findDir(DFLOAT dx, DFLOAT dy);
92 DFLOAT Wrap_length(DFLOAT dx, DFLOAT dy);
93 unsigned short Find_closest_team(int posx, int posy);
94 
95 int Wildmap(
96 	int width,
97 	int height,
98 	char *name,
99 	char *author,
100 	char **data,
101 	int *width_ptr,
102 	int *height_ptr);
103 
104 /*
105  * Prototypes for math.c
106  */
107 int ON(char *optval);
108 int OFF(char *optval);
109 int mod(int x, int y);
110 int f2i(DFLOAT f);
111 DFLOAT findDir(DFLOAT x, DFLOAT y);
112 void Make_table(void);
113 
114 
115 /*
116  * Prototypes for cmdline.c
117  */
118 void tuner_none(void);
119 void tuner_dummy(void);
120 bool Init_options(void);
121 void Free_options(void);
122 
123 
124 /*
125  * Prototypes for play.c
126  */
127 void Thrust(int ind);
128 void Turn_thrust(int ind,int num_sparks);
129 void Recoil(object *ship, object *shot);
130 void Record_shove(player *pl, player *pusher, long time);
131 void Delta_mv(object *ship, object *obj);
132 void Delta_mv_elastic(object *obj1, object *obj2);
133 void Obj_repel(object *obj1, object *obj2, int repel_dist);
134 void Item_damage(int ind, DFLOAT prob);
135 void Tank_handle_detach(player*);
136 void Add_fuel(pl_fuel_t*, long);
137 void Update_tanks(pl_fuel_t *);
138 void Place_item(int type, int ind);
139 int Choose_random_item(void);
140 void Tractor_beam(int ind);
141 void General_tractor_beam(int ind, DFLOAT x, DFLOAT y,
142 			  int items, int target, bool pressor);
143 void Place_mine(int ind);
144 void Place_moving_mine(int ind);
145 void Place_general_mine(int ind, unsigned short team, long status, DFLOAT x, DFLOAT y,
146   			DFLOAT vx, DFLOAT vy, modifiers mods);
147 void Detonate_mines(int ind);
148 char *Describe_shot(int type, long status, modifiers mods, int hit);
149 void Fire_ecm(int ind);
150 void Fire_general_ecm(int ind, unsigned short team, DFLOAT x, DFLOAT y);
151 void Move_ball(int ind);
152 void Fire_shot(int ind, int type, int dir);
153 void Fire_general_shot(int ind, unsigned short team, bool cannon,
154 		       DFLOAT x, DFLOAT y, int type, int dir,
155 		       modifiers mods, int target);
156 void Fire_normal_shots(int ind);
157 void Fire_main_shot(int ind, int type, int dir);
158 void Fire_shot(int ind, int type, int dir);
159 void Fire_left_shot(int ind, int type, int dir, int gun);
160 void Fire_right_shot(int ind, int type, int dir, int gun);
161 void Fire_left_rshot(int ind, int type, int dir, int gun);
162 void Fire_right_rshot(int ind, int type, int dir, int gun);
163 void Make_treasure_ball(int treasure);
164 int Punish_team(int ind, int t_destroyed, int t_target);
165 void Delete_shot(int ind);
166 void Fire_laser(int ind);
167 void Fire_general_laser(int ind, unsigned short team, DFLOAT x, DFLOAT y, int dir,
168 			modifiers mods);
169 void Do_deflector(int ind);
170 void Do_transporter(int ind);
171 void Do_general_transporter(int ind, DFLOAT x, DFLOAT y, int target,
172 			    int *item, long *amount);
173 void do_hyperjump(player *pl);
174 void do_lose_item(int ind);
175 void Move_smart_shot(int ind);
176 void Move_mine(int ind);
177 void Make_debris(
178 	    /* pos.x, pos.y   */ DFLOAT  x,          DFLOAT y,
179 	    /* vel.x, vel.y   */ DFLOAT  velx,       DFLOAT vely,
180 	    /* owner id       */ int    id,
181 	    /* owner team     */ unsigned short team,
182 	    /* type           */ int    type,
183 	    /* mass           */ DFLOAT  mass,
184 	    /* status         */ long   status,
185 	    /* color          */ int    color,
186 	    /* radius         */ int    radius,
187 	    /* min,max debris */ int    min_debris, int    max_debris,
188 	    /* min,max dir    */ int    min_dir,    int    max_dir,
189 	    /* min,max speed  */ DFLOAT  min_speed,  DFLOAT  max_speed,
190 	    /* min,max life   */ int    min_life,   int    max_life
191 	    );
192 void Make_wreckage(
193 	    /* pos.x, pos.y   */ DFLOAT x,          DFLOAT y,
194 	    /* vel.x, vel.y   */ DFLOAT velx,       DFLOAT vely,
195 	    /* owner id       */ int    id,
196 	    /* owner team     */ unsigned short team,
197 	    /* min,max mass   */ DFLOAT min_mass,   DFLOAT max_mass,
198 	    /* total mass     */ DFLOAT total_mass,
199 	    /* status         */ long   status,
200 	    /* color          */ int    color,
201 	    /* max wreckage   */ int    max_wreckage,
202 	    /* min,max dir    */ int    min_dir,    int    max_dir,
203 	    /* min,max speed  */ DFLOAT min_speed,  DFLOAT max_speed,
204 	    /* min,max life   */ int    min_life,   int    max_life
205 	    );
206 void Make_item(int px, int py,
207 	       int vx, int vy,
208 	       int item, int num_per_pack,
209 	       long status);
210 void Explode(int ind);
211 void Explode_fighter(int ind);
212 void Throw_items(int ind);
213 void Detonate_items(int ind);
214 void add_temp_wormholes(int xin, int yin, int xout, int yout);
215 void remove_temp_wormhole(int ind);
216 
217 
218 /*
219  * Prototypes for asteroid.c
220  */
221 void Break_asteroid(int ind);
222 void Asteroid_update(void);
223 #ifdef LIST_H_INCLUDED
224 list_t Asteroid_get_list(void);
225 #endif
226 
227 
228 /*
229  * Prototypes for cannon.c
230  */
231 void Cannon_init(int ind);
232 void Cannon_add_item(int ind, int item, int amount);
233 void Cannon_throw_items(int ind);
234 void Cannon_check_defense(int ind);
235 void Cannon_check_fire(int ind);
236 
237 /*
238  * Prototypes for command.c
239  */
240 void Handle_player_command(player *pl, char *cmd);
241 
242 /*
243  * Prototypes for player.c
244  */
245 void Pick_startpos(int ind);
246 void Go_home(int ind);
247 void Compute_sensor_range(player *);
248 void Player_add_tank(int ind, long tank_fuel);
249 void Player_remove_tank(int ind, int which_tank);
250 void Player_hit_armor(int ind);
251 void Player_used_kill(int ind);
252 void Player_set_mass(int ind);
253 int Init_player(int ind, shipobj *ship);
254 void Alloc_players(int number);
255 void Free_players(void);
256 void Update_score_table(void);
257 void Reset_all_players(void);
258 void Check_team_members(int);
259 void Compute_game_status(void);
260 void Delete_player(int ind);
261 void Detach_ball(int ind, int ball);
262 void Kill_player(int ind);
263 void Player_death_reset(int ind);
264 void Team_game_over(int winning_team, const char *reason);
265 void Individual_game_over(int winner);
266 void Race_game_over(void);
267 int Team_immune(int id1, int id2);
268 
269 /*
270  * Prototypes for robot.c
271  */
272 void Parse_robot_file(void);
273 void Robot_init(void);
274 void Robot_delete(int ind, int kicked);
275 void Robot_destroy(int ind);
276 void Robot_update(void);
277 void Robot_invite(int ind, int inv_ind);
278 void Robot_war(int ind, int killer);
279 void Robot_reset_war(int ind);
280 int Robot_war_on_player(int ind);
281 void Robot_go_home(int ind);
282 void Robot_program(int ind, int victim_id);
283 void Robot_message(int ind, const char *message);
284 
285 /*
286  * Prototypes for rules.c
287  */
288 void Tune_item_probs(void);
289 void Tune_item_packs(void);
290 void Set_initial_resources(void);
291 void Set_world_items(void);
292 void Set_world_rules(void);
293 void Set_world_asteroids(void);
294 void Set_misc_item_limits(void);
295 void Tune_asteroid_prob(void);
296 
297 /*
298  * Prototypes for server.c
299  */
300 int End_game(void);
301 int Pick_team(int pick_for_type);
302 void Server_info(char *str, unsigned max_size);
303 void Log_game(const char *heading);
304 void Game_Over(void);
305 void Server_log_admin_message(int ind, const char *str);
306 int plock_server(int onoff);
307 void Main_loop(void);
308 
309 
310 /*
311  * Prototypes for contact.c
312  */
313 void Contact_cleanup(void);
314 int Contact_init(void);
315 void Contact(int fd, void *arg);
316 void Queue_loop(void);
317 int Queue_advance_player(char *name, char *msg);
318 int Queue_show_list(char *msg);
319 void Set_deny_hosts(void);
320 
321 /*
322  * Prototypes for metaserver.c
323  */
324 void Meta_send(char *mesg, int len);
325 int Meta_from(char *addr, int port);
326 void Meta_gone(void);
327 void Meta_init(void);
328 void Meta_update(int change);
329 
330 /*
331  * Prototypes for frame.c
332  */
333 void Frame_update(void);
334 void Set_message(const char *message);
335 void Set_player_message(player *pl, const char *message);
336 
337 /*
338  * Prototypes for update.c
339  */
340 void Update_radar_target(int);
341 void Update_objects(void);
342 void Autopilot(int ind, int on);
343 void Cloak(int ind, int on);
344 void Deflector(int ind, int on);
345 void Emergency_thrust(int ind, int on);
346 void Emergency_shield(int ind, int on);
347 void Phasing(int ind, int on);
348 
349 /*
350  * Prototypes for option.c
351  */
352 void Options_parse(void);
353 void Options_free(void);
354 bool Convert_string_to_int(const char *value_str, int *int_ptr);
355 bool Convert_string_to_float(const char *value_str, DFLOAT *float_ptr);
356 bool Convert_string_to_bool(const char *value_str, bool *bool_ptr);
357 void Convert_list_to_string(list_t list, char **string);
358 void Convert_string_to_list(const char *value, list_t *list_ptr);
359 
360 /*
361  * Prototypes for parser.c
362  */
363 int Parser_list_option(int *index, char *buf);
364 bool Parser(int argc, char **argv);
365 int Tune_option(char *name, char *val);
366 int Get_option_value(const char *name, char *value, unsigned size);
367 
368 /*
369  * Prototypes for fileparser.c
370  */
371 bool parseDefaultsFile(const char *filename);
372 bool parsePasswordFile(const char *filename);
373 bool parseMapFile(const char *filename);
374 void expandKeyword(const char *keyword);
375 
376 /*
377  * Prototypes for laser.c
378  */
379 void Laser_pulse_collision(void);
380 
381 /*
382  * Prototypes for alliance.c
383  */
384 int Invite_player(int ind, int ally_ind);
385 int Cancel_invitation(int ind);
386 int Refuse_alliance(int ind, int ally_ind);
387 int Refuse_all_alliances(int ind);
388 int Accept_alliance(int ind, int ally_ind);
389 int Accept_all_alliances(int ind);
390 int Get_alliance_member_count(int id);
391 void Player_join_alliance(int ind, int ally_ind);
392 void Dissolve_all_alliances(void);
393 int Leave_alliance(int ind);
394 void Alliance_player_list(int ind);
395 
396 /*
397  * Prototypes for object.c
398  */
399 object *Object_allocate(void);
400 void Object_free_ind(int ind);
401 void Object_free_ptr(object *obj);
402 void Alloc_shots(int number);
403 void Free_shots(void);
404 
405 /*
406  * Prototypes for showtime.c
407  */
408 char *showtime(void);
409 
410 #endif
411