1 /*
2  * XPilot NG, a multiplayer space war game.
3  *
4  * Copyright (C) 1991-2001 by
5  *
6  *      Bj�rn Stabell        <bjoern@xpilot.org>
7  *      Ken Ronny Schouten   <ken@xpilot.org>
8  *      Bert Gijsbers        <bert@xpilot.org>
9  *      Dick Balaska         <dick@xpilot.org>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
24  */
25 
26 #ifndef CLIENT_H
27 #define CLIENT_H
28 
29 #ifdef _WINDOWS
30 #ifndef	_WINSOCKAPI_
31 #include <winsock.h>
32 #endif
33 #endif
34 
35 #ifndef DRAW_H
36 /* need shipshape_t */
37 #include "shipshape.h"
38 #endif
39 #ifndef ITEM_H
40 /* need NUM_ITEMS */
41 #include "item.h"
42 #endif
43 #ifndef CONNECTPARAM_H
44 /* need Connect_param_t */
45 #include "connectparam.h"
46 #endif
47 #ifndef OPTION_H
48 /* need xp_keysym_t */
49 #include "option.h"
50 #endif
51 
52 typedef struct {
53     bool	talking;	/* Some talk window is open? */
54     bool	pointerControl;	/* Pointer (mouse) control is on? */
55     bool	restorePointerControl;
56 				/* Pointer control should be restored later? */
57     bool	quitMode;	/* Client is in quit mode? */
58     double	clientLag;
59     double	scaleFactor;
60     double	scale;
61     float	fscale;
62     double	altScaleFactor;
63 } client_data_t;
64 
65 typedef struct {
66     bool clientRanker;
67     bool clockAMPM;
68     bool filledDecor;
69     bool filledWorld;
70     bool outlineDecor;
71     bool outlineWorld;
72     bool showDecor;
73     bool showItems;
74     bool showLivesByShip;
75     bool showMessages;
76     bool showMyShipShape;
77     bool showNastyShots;
78     bool showShipShapes;
79     bool showShipShapesHack;
80     bool slidingRadar;
81     bool texturedDecor;
82     bool texturedWalls;
83 } instruments_t;
84 
85 typedef struct {
86     bool help;
87     bool version;
88     bool text;
89     bool list_servers; /* list */
90     bool auto_connect; /* join */
91     char shutdown_reason[MAX_CHARS]; /* shutdown reason */
92 } xp_args_t;
93 
94 #define PACKET_LOSS		0
95 #define PACKET_DROP		1
96 #define PACKET_DRAW		2
97 
98 #define MAX_SCORE_OBJECTS	10
99 
100 #define MAX_SPARK_SIZE		8
101 #define MIN_SPARK_SIZE		1
102 #define MAX_MAP_POINT_SIZE	8
103 #define MIN_MAP_POINT_SIZE	0
104 #define MAX_SHOT_SIZE		20
105 #define MIN_SHOT_SIZE		1
106 #define MAX_TEAMSHOT_SIZE	20
107 #define MIN_TEAMSHOT_SIZE	1
108 
109 #define MIN_SHOW_ITEMS_TIME	0.0
110 #define MAX_SHOW_ITEMS_TIME	300.0
111 
112 #define MIN_SCALEFACTOR		0.1
113 #define MAX_SCALEFACTOR		20.0
114 
115 #define FUEL_NOTIFY_TIME	3.0
116 #define CONTROL_TIME		8.0
117 
118 #define MAX_MSGS		15	/* Max. messages displayed ever */
119 #define MAX_HIST_MSGS		128	/* Max. messages in history */
120 
121 #define MSG_LIFE_TIME		120.0	/* Seconds */
122 #define MSG_FLASH_TIME		105.0	/* Old messages have life time less
123 					   than this */
124 #define MAX_POINTER_BUTTONS	5
125 
126 /*
127  * Macros to manipulate dynamic arrays.
128  */
129 
130 /*
131  * Macro to add one new element of a given type to a dynamic array.
132  * T is the type of the element.
133  * P is the pointer to the array memory.
134  * N is the current number of elements in the array.
135  * M is the current size of the array.
136  * V is the new element to add.
137  * The goal is to keep the number of malloc/realloc calls low
138  * while not wasting too much memory because of over-allocation.
139  */
140 #define STORE(T,P,N,M,V)						\
141     if (N >= M && ((M <= 0)						\
142 	? (P = (T *) malloc((M = 1) * sizeof(*P)))			\
143 	: (P = (T *) realloc(P, (M += M) * sizeof(*P)))) == NULL) {	\
144 	error("No memory");						\
145 	exit(1);							\
146     } else								\
147 	(P[N++] = V)
148 /*
149  * Macro to make room in a given dynamic array for new elements.
150  * P is the pointer to the array memory.
151  * N is the current number of elements in the array.
152  * M is the current size of the array.
153  * T is the type of the elements.
154  * E is the number of new elements to store in the array.
155  * The goal is to keep the number of malloc/realloc calls low
156  * while not wasting too much memory because of over-allocation.
157  */
158 #define EXPAND(P,N,M,T,E)						\
159     if ((N) + (E) > (M)) {						\
160 	if ((M) <= 0) {							\
161 	    M = (E) + 2;						\
162 	    P = (T *) malloc((M) * sizeof(T));				\
163 	    N = 0;							\
164 	} else {							\
165 	    M = ((M) << 1) + (E);					\
166 	    P = (T *) realloc(P, (M) * sizeof(T));			\
167 	}								\
168 	if (P == NULL) {						\
169 	    error("No memory");						\
170 	    N = M = 0;							\
171 	    return;	/* ! */						\
172 	}								\
173     }
174 
175 #define UNEXPAND(P,N,M)							\
176     if ((N) < ((M) >> 2)) {						\
177 	free(P);							\
178 	M = 0;								\
179     }									\
180     N = 0;
181 
182 #ifndef PAINT_FREE
183 # define PAINT_FREE	1
184 #endif
185 #if PAINT_FREE
186 # define RELEASE(P, N, M)					\
187 do {								\
188 	if (!(N)) ; else (free(P), (M) = 0, (N) = 0);		\
189 } while (0)
190 #else
191 # define RELEASE(P, N, M)	((N) = 0)
192 #endif
193 
194 
195 typedef struct {
196     double	score;
197     short	id;
198     uint16_t	team;
199     short	check;
200     short	round;
201     long	timing_loops;
202     short	timing;
203     short	life;
204     short	mychar;
205     short	alliance;
206     short	name_width;	/* In pixels */
207     short	name_len;	/* In bytes */
208     short	max_chars_in_names;	/* name_width was calculated
209 					   for this value of maxCharsInNames */
210     short	ignorelevel;
211     shipshape_t	*ship;
212     char	nick_name[MAX_CHARS];
213     char	user_name[MAX_CHARS];
214     char	host_name[MAX_CHARS];
215     char	id_string[MAX_CHARS];
216 } other_t;
217 
218 typedef struct {
219     int		pos;		/* Block index */
220     double	fuel;		/* Amount of fuel available */
221     irec_t	bounds;		/* Location on map */
222 } fuelstation_t;
223 
224 typedef struct {
225     int		pos;		/* Block index */
226     short	id;		/* Id of owner or -1 */
227     uint16_t	team;		/* Team this base belongs to */
228     irec_t	bounds;		/* Location on map */
229     int		type;		/* orientation */
230     long	appeartime;	/* For base warning */
231 } homebase_t;
232 
233 typedef struct {
234     int		pos;		/* Block index */
235     short	dead_time,	/* Frames inactive */
236 		dot;		/* Draw dot if inactive */
237 } cannontime_t;
238 
239 typedef struct {
240     int		pos;		/* Block index */
241     short	dead_time;	/* Frames inactive */
242     double	damage;		/* Damage to target */
243 } target_t;
244 
245 typedef struct {
246     int		pos;		/* Block index */
247     irec_t	bounds;		/* Location on map */
248 } checkpoint_t;
249 
250 typedef struct {
251     int width;			/* Line width, -1 means no line */
252     unsigned long color;	/* Line color */
253     int rgb;			/* RGB values corresponding to color */
254     int style;			/* 0=LineSolid, 1=LineOnOffDash, 2=LineDoubleDash */
255 } edge_style_t;
256 
257 typedef struct {
258     unsigned long color;	/* The color if drawn in filled mode */
259     int rgb;			/* RGB values corresponding to color */
260     int texture;		/* The texture if drawn in texture mode */
261     int flags;			/* Flags about this style (see draw.h) */
262     int def_edge_style;		/* The default style for edges */
263 } polygon_style_t;
264 
265 typedef struct {
266     ipos_t *points;		/* points[0] is absolute, rest are relative */
267     int num_points;		/* number of points */
268     irec_t bounds;		/* bounding box for the polygon */
269     int *edge_styles;		/* optional array of indexes to edge_styles */
270     int style;			/* index to polygon_styles array */
271 } xp_polygon_t;
272 
273 
274 /*
275  * Types for dynamic game data
276  */
277 
278 typedef struct {
279     short		x0, y0, x1, y1;
280 } refuel_t;
281 
282 typedef struct {
283     short		x0, y0, x1, y1;
284     u_byte		tractor;
285 } connector_t;
286 
287 typedef struct {
288     unsigned char	color, dir;
289     short		x, y, len;
290 } laser_t;
291 
292 typedef struct {
293     short		x, y, dir;
294     unsigned char	len;
295 } missile_t;
296 
297 typedef struct {
298     short		x, y, id;
299     u_byte		style;
300 } ball_t;
301 
302 typedef struct {
303     short		x, y, id, dir;
304     u_byte		shield, cloak, eshield;
305     u_byte		phased, deflector;
306 } ship_t;
307 
308 typedef struct {
309     short		x, y, teammine, id;
310 } mine_t;
311 
312 typedef struct {
313     short		x, y, type;
314 } itemtype_t;
315 
316 typedef struct {
317     short		x, y, size;
318 } ecm_t;
319 
320 typedef struct {
321     short		x1, y1, x2, y2;
322 } trans_t;
323 
324 typedef struct {
325     short		x, y, count;
326 } paused_t;
327 
328 typedef struct {
329     short		x, y, id, count;
330 } appearing_t;
331 
332 typedef enum {
333     RadarEnemy,
334     RadarFriend
335 } radar_type_t;
336 
337 typedef struct {
338     short		x, y, size;
339     radar_type_t        type;
340 } radar_t;
341 
342 typedef struct {
343     short		x, y, type;
344 } vcannon_t;
345 
346 typedef struct {
347     short		x, y;
348     double		fuel;
349 } vfuel_t;
350 
351 typedef struct {
352     short		x, y, xi, yi, type;
353 } vbase_t;
354 
355 typedef struct {
356     u_byte		x, y;
357 } debris_t;
358 
359 typedef struct {
360     short		x, y, xi, yi, type;
361 } vdecor_t;
362 
363 typedef struct {
364     short		x, y;
365     u_byte		wrecktype, size, rotation;
366 } wreckage_t;
367 
368 typedef struct {
369     short		x, y;
370     u_byte		type, size, rotation;
371 } asteroid_t;
372 
373 typedef struct {
374     short		x, y;
375 } wormhole_t;
376 
377 
378 /*#define SCORE_OBJECT_COUNT	100*/
379 typedef struct {
380     double	score,
381 		life_time;
382     int		x,
383 		y,
384 		hud_msg_len,
385 		hud_msg_width,
386 		msg_width,
387 		msg_len;
388     char	msg[10],
389 		hud_msg[MAX_CHARS+10];
390 } score_object_t;
391 
392 
393 /*
394  * is a selection pending (in progress), done, drawn emphasized?
395  */
396 #define SEL_NONE       (1 << 0)
397 #define SEL_PENDING    (1 << 1)
398 #define SEL_SELECTED   (1 << 2)
399 #define SEL_EMPHASIZED (1 << 3)
400 
401 /*
402  * a selection (text, string indices, state,...)
403  */
404 typedef struct {
405     /* a selection in the talk window */
406     struct {
407         bool    state;	/* current state of the selection */
408         size_t  x1;	/* string indices */
409         size_t  x2;
410         bool    incl_nl;/* include a '\n'? */
411     } talk ;
412     /* a selection in the draw window */
413     struct {
414         bool    state;
415         int     x1;	/* string indices (for TalkMsg[].txt) */
416         int     x2;	/* they are modified when the emphasized area */
417         int     y1;	/* is scrolled down by new messages coming in */
418         int     y2;
419     } draw;
420     char	*txt;   /* allocated when needed */
421     size_t	txt_size;	/* size of txt buffer */
422     size_t	len;
423     /* when a message 'jumps' from talk window to the player messages: */
424     bool	keep_emphasizing;
425 } selection_t;
426 
427 /* typedefs begin */
428 typedef enum {
429     BmsNone = 0,
430     BmsBall,
431     BmsSafe,
432     BmsCover,
433     BmsPop
434 } msg_bms_t;
435 
436 typedef struct {
437     char		txt[MSG_LEN];
438     size_t		len;
439     /*short		pixelLen;*/
440     double		lifeTime;
441     msg_bms_t		bmsinfo;
442 } message_t;
443 /* typedefs end */
444 
445 extern client_data_t	clData;
446 
447 extern bool		newbie;
448 extern char		*geometry;
449 extern xp_args_t	xpArgs;
450 extern Connect_param_t	connectParam;
451 extern message_t	*TalkMsg[];
452 extern message_t	*GameMsg[];
453 extern message_t	*TalkMsg_pending[];	/* store incoming messages */
454 extern message_t	*GameMsg_pending[];	/* while a cut is pending */
455 extern char		*HistoryMsg[];		/* talk window history */
456 
457 extern int		maxLinesInHistory;	/* lines to save in history */
458 extern selection_t	selection;		/* in talk/draw window */
459 extern int		maxMessages;
460 extern int		messagesToStdout;
461 
462 extern char		*talk_fast_msgs[];	/* talk macros */
463 
464 extern score_object_t	score_objects[MAX_SCORE_OBJECTS];
465 extern int		score_object;
466 
467 extern int      oldServer; /* Compatibility mode for old block-based servers */
468 extern ipos_t	selfPos;
469 extern ipos_t	selfVel;
470 extern short	heading;
471 extern short	nextCheckPoint;
472 extern u_byte	numItems[NUM_ITEMS];
473 extern u_byte	lastNumItems[NUM_ITEMS];
474 extern int	numItemsTime[NUM_ITEMS];
475 extern double	showItemsTime;
476 extern short	autopilotLight;
477 extern int	showScoreDecimals;
478 extern double   scoreObjectTime;        /* How long to show score objects */
479 
480 
481 extern short	lock_id;		/* Id of player locked onto */
482 extern short	lock_dir;		/* Direction of lock */
483 extern short	lock_dist;		/* Distance to player locked onto */
484 
485 extern int	eyesId;		        /* Player we get frame updates for */
486 extern other_t	*eyes;        		/* Player we get frame updates for */
487 extern bool	snooping;	        /* are we snooping on someone else? */
488 extern int	eyeTeam;	        /* Team of player we get updates for */
489 
490 extern other_t*	self;			/* Player info */
491 extern short	selfVisible;		/* Are we alive and playing? */
492 extern short	damaged;		/* Damaged by ECM */
493 extern short	destruct;		/* If self destructing */
494 extern short	shutdown_delay;
495 extern short	shutdown_count;
496 extern short	thrusttime;
497 extern short	thrusttimemax;
498 extern short	shieldtime;
499 extern short	shieldtimemax;
500 extern short	phasingtime;
501 extern short	phasingtimemax;
502 
503 extern int	roundDelay;
504 extern int	roundDelayMax;
505 
506 extern bool	UpdateRadar;
507 extern unsigned	RadarWidth;
508 extern unsigned	RadarHeight;
509 extern int	backgroundPointDist;	/* spacing of navigation points */
510 extern int	backgroundPointSize;	/* size of navigation points */
511 extern int	sparkSize;		/* size of sparks and debris */
512 extern int	shotSize;		/* size of shot */
513 extern int	teamShotSize;		/* size of team shot */
514 
515 extern double	controlTime;		/* Display control for how long? */
516 extern u_byte	spark_rand;		/* Sparkling effect */
517 extern u_byte	old_spark_rand;		/* previous value of spark_rand */
518 
519 extern double	fuelSum;		/* Sum of fuel in all tanks */
520 extern double	fuelMax;		/* How much fuel can you take? */
521 extern short	fuelCurrent;		/* Number of currently used tank */
522 extern short	numTanks;		/* Number of tanks */
523 extern double	fuelTime;		/* Display fuel for how long? */
524 extern double	fuelCritical;		/* Fuel critical level */
525 extern double	fuelWarning;		/* Fuel warning level */
526 extern double	fuelNotify;		/* Fuel notify level */
527 
528 extern char	*shipShape;		/* Shape of player's ship */
529 extern double	power;			/* Force of thrust */
530 extern double	power_s;		/* Saved power fiks */
531 extern double	turnspeed;		/* How fast player acc-turns */
532 extern double	turnspeed_s;		/* Saved turnspeed */
533 extern double	turnresistance;		/* How much is lost in % */
534 extern double	turnresistance_s;	/* Saved (see above) */
535 extern double	displayedPower;		/* What the server is sending us */
536 extern double	displayedTurnspeed;	/* What the server is sending us */
537 extern double	displayedTurnresistance;/* What the server is sending us */
538 extern double	sparkProb;		/* Sparkling effect configurable */
539 extern int	charsPerSecond;		/* Message output speed (config) */
540 
541 extern double	hud_move_fact;		/* scale the hud-movement (speed) */
542 extern double	ptr_move_fact;		/* scale the speed pointer length */
543 extern char	mods[MAX_CHARS];	/* Current modifiers in effect */
544 extern instruments_t	instruments;	/* Instruments on screen */
545 extern int	packet_size;		/* Current frame update packet size */
546 extern int	packet_loss;		/* lost packets per second */
547 extern int	packet_drop;		/* dropped packets per second */
548 extern int	packet_lag;		/* approximate lag in frames */
549 extern char	*packet_measure;	/* packet measurement in a second */
550 extern long	packet_loop;		/* start of measurement */
551 
552 extern bool	showUserName;		/* Show username instead of nickname */
553 extern char	servername[MAX_CHARS];	/* Name of server connecting to */
554 extern unsigned	version;		/* Version of the server */
555 extern bool	scoresChanged;
556 extern bool	toggle_shield;		/* Are shields toggled by a press? */
557 extern bool	shields;		/* When shields are considered up */
558 extern bool	auto_shield;            /* drops shield for fire */
559 
560 extern int	maxFPS;			/* Max FPS player wants from server */
561 extern int 	oldMaxFPS;
562 extern double	clientFPS;		/* FPS client is drawing at */
563 extern int	recordFPS;		/* What FPS to record at */
564 extern time_t	currentTime;	        /* Current value of time() */
565 extern bool	newSecond;              /* Did time() increment this frame? */
566 extern int	maxMouseTurnsPS;
567 extern int	mouseMovementInterval;
568 extern int	cumulativeMouseMovement;
569 
570 extern char	modBankStr[][MAX_CHARS];/* modifier banks strings */
571 
572 extern int	clientPortStart;	/* First UDP port for clients */
573 extern int	clientPortEnd;		/* Last one (these are for firewalls) */
574 extern int	baseWarningType;	/* Which type of base warning you prefer */
575 extern int	maxCharsInNames;
576 extern byte	lose_item;		/* flag and index to drop item */
577 extern int	lose_item_active;	/* one of the lose keys is pressed */
578 
579 /* mapdata accessible to outside world */
580 
581 extern int	        num_playing_teams;
582 
583 extern fuelstation_t	*fuels;
584 extern int		num_fuels;
585 extern homebase_t	*bases;
586 extern int		num_bases;
587 extern checkpoint_t	*checks;
588 extern int		num_checks;
589 extern xp_polygon_t	*polygons;
590 extern int		num_polygons, max_polygons;
591 extern edge_style_t	*edge_styles;
592 extern int		num_edge_styles, max_edge_styles;
593 extern polygon_style_t	*polygon_styles;
594 extern int		num_polygon_styles, max_polygon_styles;
595 
596 /* dynamic global game data */
597 
598 extern other_t          *Others;
599 extern int	        num_others, max_others;
600 extern refuel_t		*refuel_ptr;
601 extern int		 num_refuel, max_refuel;
602 extern connector_t	*connector_ptr;
603 extern int		 num_connector, max_connector;
604 extern laser_t		*laser_ptr;
605 extern int		 num_laser, max_laser;
606 extern missile_t	*missile_ptr;
607 extern int		 num_missile, max_missile;
608 extern ball_t		*ball_ptr;
609 extern int		 num_ball, max_ball;
610 extern ship_t		*ship_ptr;
611 extern int		 num_ship, max_ship;
612 extern mine_t		*mine_ptr;
613 extern int		 num_mine, max_mine;
614 extern itemtype_t	*itemtype_ptr;
615 extern int		 num_itemtype, max_itemtype;
616 extern ecm_t		*ecm_ptr;
617 extern int		 num_ecm, max_ecm;
618 extern trans_t		*trans_ptr;
619 extern int		 num_trans, max_trans;
620 extern paused_t		*paused_ptr;
621 extern int		 num_paused, max_paused;
622 extern appearing_t	*appearing_ptr;
623 extern int		 num_appearing, max_appearing;
624 extern radar_t		*radar_ptr;
625 extern int		 num_radar, max_radar;
626 extern vcannon_t	*vcannon_ptr;
627 extern int		 num_vcannon, max_vcannon;
628 extern vfuel_t		*vfuel_ptr;
629 extern int		 num_vfuel, max_vfuel;
630 extern vbase_t		*vbase_ptr;
631 extern int		 num_vbase, max_vbase;
632 extern debris_t		*debris_ptr[DEBRIS_TYPES];
633 extern int		 num_debris[DEBRIS_TYPES],
634 			 max_debris[DEBRIS_TYPES];
635 extern debris_t		*fastshot_ptr[DEBRIS_TYPES * 2];
636 extern int		 num_fastshot[DEBRIS_TYPES * 2],
637 			 max_fastshot[DEBRIS_TYPES * 2];
638 extern vdecor_t		*vdecor_ptr;
639 extern int		 num_vdecor, max_vdecor;
640 extern wreckage_t	*wreckage_ptr;
641 extern int		 num_wreckage, max_wreckage;
642 extern asteroid_t	*asteroid_ptr;
643 extern int		 num_asteroids, max_asteroids;
644 extern wormhole_t	*wormhole_ptr;
645 extern int		 num_wormholes, max_wormholes;
646 
647 extern long		start_loops, end_loops;
648 extern long		time_left;
649 
650 extern bool roundend;
651 extern bool played_this_round;
652 extern int protocolVersion;
653 
654 /*
655  * somewhere
656  */
657 const char *Program_name(void);
658 int Bitmap_add(const char *filename, int count, bool scalable);
659 void Pointer_control_newbie_message(void);
660 
661 /*
662  * Platform specific code needs to implement these.
663  */
664 void Platform_specific_pointer_control_set_state(bool on);
665 void Platform_specific_talk_set_state(bool on);
666 void Record_toggle(void);
667 void Toggle_fullscreen(void);
668 void Toggle_radar_and_scorelist(void);
669 
670 /*
671  * event.c
672  */
673 void Pointer_control_set_state(bool on);
674 void Talk_set_state(bool on);
675 
676 void Pointer_button_pressed(int button);
677 void Pointer_button_released(int button);
678 void Keyboard_button_pressed(xp_keysym_t ks);
679 void Keyboard_button_released(xp_keysym_t ks);
680 
681 int Key_init(void);
682 int Key_update(void);
683 void Key_clear_counts(void);
684 bool Key_press(keys_t key);
685 bool Key_release(keys_t key);
686 void Set_auto_shield(bool on);
687 void Set_toggle_shield(bool on);
688 
689 /*
690  * messages.c
691  */
692 bool Bms_test_state(msg_bms_t bms);
693 void Bms_set_state(msg_bms_t bms);
694 int Alloc_msgs(void);
695 void Free_msgs(void);
696 int Alloc_history(void);
697 void Free_selectionAndHistory(void);
698 void Add_message(const char *message);
699 void Add_newbie_message(const char *message);
700 extern void Add_alert_message(const char *message, double timeout);
701 extern void Clear_alert_messages(void);
702 void Add_pending_messages(void);
703 void Add_roundend_messages(other_t **order);
704 void Print_messages_to_stdout(void);
705 
706 /*
707  * client.c
708  */
709 double Fuel_by_pos(int x, int y);
710 int Target_alive(int x, int y, double *damage);
711 int Target_by_index(int ind, int *xp, int *yp, int *dead_time, double *damage);
712 int Handle_fuel(int ind, double fuel);
713 int Cannon_dead_time_by_pos(int x, int y, int *dot);
714 int Handle_cannon(int ind, int dead_time);
715 int Handle_target(int num, int dead_time, double damage);
716 int Base_info_by_pos(int x, int y, int *id, int *team);
717 int Handle_base(int id, int ind);
718 int Check_pos_by_index(int ind, int *xp, int *yp);
719 int Check_index_by_pos(int x, int y);
720 homebase_t *Homebase_by_id(int id);
721 other_t *Other_by_id(int id);
722 other_t *Other_by_name(const char *name, bool show_error_msg);
723 shipshape_t *Ship_by_id(int id);
724 int Handle_leave(int id);
725 int Handle_player(int id, int team, int mychar,
726 		  char *nick_name, char *user_name, char *host_name,
727 		  char *shape, int myself);
728 int Handle_team(int id, int pl_team);
729 int Handle_score(int id, double score, int life, int mychar, int alliance);
730 int Handle_score_object(double score, int x, int y, char *msg);
731 int Handle_team_score(int team, double score);
732 int Handle_timing(int id, int check, int round, long loops);
733 int Handle_seek(int programmer_id, int robot_id, int sought_id);
734 int Handle_start(long server_loops);
735 int Handle_end(long server_loops);
736 int Handle_self(int x, int y, int vx, int vy, int newHeading,
737 		double newPower, double newTurnspeed, double newTurnresistance,
738 		int newLockId, int newLockDist, int newLockBearing,
739 		int newNextCheckPoint, int newAutopilotLight,
740 		u_byte *newNumItems, int newCurrentTank,
741 		double newFuelSum, double newFuelMax, int newPacketSize,
742 		int status);
743 int Handle_self_items(u_byte *newNumItems);
744 int Handle_modifiers(char *m);
745 int Handle_damaged(int dam);
746 int Handle_destruct(int count);
747 int Handle_shutdown(int count, int delay);
748 int Handle_thrusttime(int count, int max);
749 int Handle_shieldtime(int count, int max);
750 int Handle_phasingtime(int count, int max);
751 int Handle_rounddelay(int count, int max);
752 int Handle_refuel(int x_0, int y_0, int x_1, int y_1);
753 int Handle_connector(int x_0, int y_0, int x_1, int y_1, int tractor);
754 int Handle_laser(int color, int x, int y, int len, int dir);
755 int Handle_missile(int x, int y, int dir, int len);
756 int Handle_ball(int x, int y, int id, int style);
757 int Handle_ship(int x, int y, int id, int dir, int shield, int cloak,
758 		int eshield, int phased, int deflector);
759 int Handle_mine(int x, int y, int teammine, int id);
760 int Handle_item(int x, int y, int type);
761 int Handle_fastshot(int type, u_byte *p, int n);
762 int Handle_debris(int type, u_byte *p, int n);
763 int Handle_wreckage(int x, int y, int wrecktype, int size, int rotation);
764 int Handle_asteroid(int x, int y, int type, int size, int rotation);
765 int Handle_wormhole(int x, int y);
766 int Handle_polystyle(int polyind, int newstyle);
767 int Handle_ecm(int x, int y, int size);
768 int Handle_trans(int x_1, int y_1, int x_2, int y_2);
769 int Handle_paused(int x, int y, int count);
770 int Handle_appearing(int x, int y, int id, int count);
771 int Handle_radar(int x, int y, int size);
772 int Handle_fastradar(int x, int y, int size);
773 int Handle_vcannon(int x, int y, int type);
774 int Handle_vfuel(int x, int y, double fuel);
775 int Handle_vbase(int x, int y, int xi, int yi, int type);
776 int Handle_vdecor(int x, int y, int xi, int yi, int type);
777 int Handle_message(char *msg);
778 int Handle_eyes(int id);
779 int Handle_time_left(long sec);
780 void Map_dots(void);
781 void Map_restore(int startx, int starty, int width, int height);
782 void Map_blue(int startx, int starty, int width, int height);
783 bool Using_score_decimals(void);
784 int Client_init(char *server, unsigned server_version);
785 int Client_setup(void);
786 void Client_cleanup(void);
787 int Client_start(void);
788 int Client_fps_request(void);
789 int Client_power(void);
790 int Client_pointer_move(int movement);
791 int Client_check_pointer_move_interval(void);
792 void Client_exit(int status);
793 
794 int Init_playing_windows(void);
795 void Raise_window(void);
796 void Reset_shields(void);
797 void Platform_specific_cleanup(void);
798 
799 #ifdef _WINDOWS
800 void MarkPlayersForRedraw(void);
801 #endif
802 
803 int Check_client_fps(void);
804 
805 /*
806  * about.c
807  */
808 extern int Handle_motd(long off, char *buf, int len, long filesize);
809 extern void aboutCleanup(void);
810 
811 #ifdef _WINDOWS
812 extern	void Motd_destroy(void);
813 extern	void Keys_destroy(void);
814 #endif
815 
816 extern int motd_viewer;		/* so Windows can clean him up */
817 extern int keys_viewer;
818 
819 
820 extern void Colors_init_style_colors(void);
821 
822 /*
823  * default.c
824  */
825 extern void Store_default_options(void);
826 extern void defaultCleanup(void);			/* memory cleanup */
827 
828 extern bool Set_scaleFactor(xp_option_t *opt, double val);
829 extern bool Set_altScaleFactor(xp_option_t *opt, double val);
830 
831 #ifdef _WINDOWS
832 extern char *Get_xpilotini_file(int level);
833 #endif
834 
835 /*
836  * event.c
837  */
838 extern void Store_key_options(void);
839 
840 /*
841  * join.c
842  */
843 extern int Join(Connect_param_t *conpar);
844 extern void xpilotShutdown(void);
845 
846 /*
847  * mapdata.c
848  */
849 extern int Mapdata_setup(const char *);
850 
851 
852 /*
853  * metaclient.c
854  */
855 extern int metaclient(int, char **);
856 
857 
858 /*
859  * paintdata.c
860  */
861 extern void paintdataCleanup(void);		/* memory cleanup */
862 
863 
864 /*
865  * paintobjects.c
866  */
867 extern int Init_wreckage(void);
868 extern int Init_asteroids(void);
869 
870 
871 /*
872  * query.c
873  */
874 extern int Query_all(sock_t *sockfd, int port, char *msg, size_t msglen);
875 
876 
877 
878 /*
879  * textinterface.c
880  */
881 extern int Connect_to_server(int auto_connect, int list_servers,
882 			     int auto_shutdown, char *shutdown_reason,
883 			     Connect_param_t *conpar);
884 extern int Contact_servers(int count, char **servers,
885 			   int auto_connect, int list_servers,
886 			   int auto_shutdown, char *shutdown_message,
887 			   int find_max, int *num_found,
888 			   char **server_addresses, char **server_names,
889 			   unsigned *server_versions,
890 			   Connect_param_t *conpar);
891 
892 /*
893  * usleep.c
894  */
895 extern int micro_delay(unsigned usec);
896 
897 /*
898  * welcome.c
899  */
900 extern int Welcome_screen(Connect_param_t *conpar);
901 
902 /*
903  * widget.c
904  */
905 extern void Widget_cleanup(void);
906 
907 /*
908  * xinit.c
909  */
910 #ifdef _WINDOWS
911 extern	void WinXCreateItemBitmaps();
912 #endif
913 
914 #endif
915