1 /*
2 * Copyright(c) 1997-2001 Id Software, Inc.
3 * Copyright(c) 2002 The Quakeforge Project.
4 * Copyright(c) 2006 Quetoo.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or(at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21 
22 #ifndef __Q_SHARED_H__
23 #define __Q_SHARED_H__
24 
25 #include "config.h"
26 
27 #include <assert.h>
28 #include <math.h>
29 #include <stdarg.h>
30 #include <stdio.h>
31 #include <stdlib.h>
32 
33 #ifdef HAVE_STRING_H
34 #include <string.h>
35 #endif
36 #ifdef HAVE_STRINGS_H
37 #include <strings.h>
38 #endif
39 
40 #include <time.h>
41 
42 typedef unsigned char byte;
43 typedef enum {false, true} qboolean;
44 
45 // angle indexes
46 #define PITCH				0  // up / down
47 #define YAW					1  // left / right
48 #define ROLL				2  // tilt / lean
49 
50 #define MAX_STRING_CHARS	1024  // max length of a string passed to Cmd_TokenizeString
51 #define MAX_STRING_TOKENS	80  // max tokens resulting from Cmd_TokenizeString
52 #define MAX_TOKEN_CHARS		128  // max length of an individual token
53 
54 #define MAX_QPATH			64  // max length of a quake game pathname
55 #define MAX_OSPATH			128  // max length of a filesystem pathname
56 
57 // per-level limits
58 #define MAX_CLIENTS			256  // absolute limit
59 #define MAX_EDICTS			1024  // must change protocol to increase more
60 #define MAX_LIGHTSTYLES		256
61 #define MAX_MODELS			256  // these are sent over the net as bytes
62 #define MAX_SOUNDS			256  // so they cannot be blindly increased
63 #define MAX_IMAGES			256
64 #define MAX_ITEMS			256
65 #define MAX_GENERAL			(MAX_CLIENTS*2)  // general config strings
66 
67 // game print flags
68 #define PRINT_LOW			0  // pickup messages
69 #define PRINT_MEDIUM		1  // death messages
70 #define PRINT_HIGH			2  // critical messages
71 #define PRINT_CHAT			3  // chat messages
72 
73 #define ERR_FATAL			0  // exit the entire game with a popup window
74 #define ERR_DROP			1  // print to console and disconnect from game
75 #define ERR_DISCONNECT		2  // don't kill server
76 
77 #define PRINT_ALL			0
78 #define PRINT_DEVELOPER		1  // only print when "developer 1"
79 
80 // destination class for gi.multicast()
81 typedef enum {
82 	MULTICAST_ALL,
83 	MULTICAST_PHS,
84 	MULTICAST_PVS,
85 	MULTICAST_ALL_R,
86 	MULTICAST_PHS_R,
87 	MULTICAST_PVS_R
88 } multicast_t;
89 
90 /*
91 
92 MATHLIB
93 
94 */
95 
96 typedef float vec_t;
97 typedef vec_t vec3_t[3];
98 typedef vec_t vec5_t[5];
99 
100 typedef	int fixed4_t;
101 typedef	int fixed8_t;
102 typedef	int fixed16_t;
103 
104 #ifndef M_PI
105 #define M_PI 3.14159265358979323846  // matches value in gcc v2 math.h
106 #endif
107 
108 struct cplane_s;
109 
110 extern vec3_t vec3_origin;
111 
112 /* FIXME: use the C99 functions instead */
113 #define Q_ftol(f)(long)(f)
114 #define DotProduct(x,y)			(x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
115 #define VectorSubtract(a,b,c)	(c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2])
116 #define VectorAdd(a,b,c)		(c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2])
117 #define VectorCopy(a,b)			(b[0]=a[0],b[1]=a[1],b[2]=a[2])
118 #define VectorClear(a)			(a[0]=a[1]=a[2]=0)
119 #define VectorNegate(a,b)		(b[0]=-a[0],b[1]=-a[1],b[2]=-a[2])
120 #define VectorSet(v, x, y, z)	(v[0]=(x), v[1]=(y), v[2]=(z))
121 
122 
123 void ClearBounds(vec3_t mins, vec3_t maxs);
124 void AddPointToBounds(vec3_t v, vec3_t mins, vec3_t maxs);
125 
126 int VectorCompare(vec3_t v1, vec3_t v2);
127 vec_t VectorNormalize(vec3_t v);  // returns vector length
128 vec_t VectorNormalize2(vec3_t v, vec3_t out);
129 void VectorMA(vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
130 void CrossProduct(vec3_t v1, vec3_t v2, vec3_t cross);
131 vec_t VectorLength(vec3_t v);
132 void VectorInverse(vec3_t v);
133 void VectorScale(vec3_t in, vec_t scale, vec3_t out);
134 int Q_log2(int val);
135 
136 int COM_GlobMatchStar(char *pattern, char *text);
137 int COM_GlobMatch(char *pattern, char *text);
138 
139 void R_ConcatRotations(float in1[3][3], float in2[3][3], float out[3][3]);
140 void R_ConcatTransforms(float in1[3][4], float in2[3][4], float out[3][4]);
141 
142 void AngleVectors(vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
143 int BoxOnPlaneSide(vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
144 float anglemod(float a);
145 float LerpAngle(float a1, float a2, float frac);
146 
147 #define BOX_ON_PLANE_SIDE(emins, emaxs, p)	\
148 	(((p)->type < 3)?						\
149 	(										\
150 		((p)->dist <=(emins)[(p)->type])?	\
151 			1								\
152 		:									\
153 		(									\
154 			((p)->dist >=(emaxs)[(p)->type])?\
155 				2							\
156 			:								\
157 				3							\
158 		)									\
159 	)										\
160 	:										\
161 		BoxOnPlaneSide((emins),(emaxs),(p)))
162 
163 void ProjectPointOnPlane(vec3_t dst, const vec3_t p, const vec3_t normal);
164 void PerpendicularVector(vec3_t dst, const vec3_t src);
165 void RotatePointAroundVector(vec3_t dst, const vec3_t dir, const vec3_t point, float degrees);
166 
167 char *COM_SkipPath(char *pathname);
168 void COM_StripExtension(char *in, char *out);
169 
170 char *COM_Parse(char **data_p);
171 // data is an in/out parm, returns a parsed out token
172 
173 void Com_sprintf(char *dest, int size, char *fmt, ...) __attribute__((format(printf, 3, 4)));
174 
175 // portable case insensitive compare
176 int Q_stricmp(char *s1, char *s2);
177 
178 char *va(char *format, ...) __attribute__((format(printf, 1, 2)));
179 
180 // key / value info strings
181 #define MAX_INFO_KEY	64
182 #define MAX_INFO_VALUE	64
183 #define MAX_INFO_STRING	512
184 
185 char *Info_ValueForKey(char *s, char *key);
186 void Info_RemoveKey(char *s, char *key);
187 void Info_SetValueForKey(char *s, char *key, char *value);
188 qboolean Info_Validate(char *s);
189 
190 // this is only here so the functions in q_shared.c and q_sh.c can link
191 void Sys_Error(char *fmt, ...) __attribute__((noreturn, format(printf, 1, 2)));
192 void Com_Printf(char *fmt, ...) __attribute__((format(printf, 1, 2)));
193 
194 /*
195 
196 CVARS (console variables)
197 
198 */
199 
200 #define CVAR_ARCHIVE	1  // set to cause it to be saved to vars.rc
201 #define CVAR_USERINFO	2  // added to userinfo  when changed
202 #define CVAR_SERVERINFO	4  // added to serverinfo when changed
203 #define CVAR_NOSET		8  // don't allow change from console at all
204 #define CVAR_LATCH		16  // save changes until server restart
205 
206 // nothing outside the Cvar_*() functions should modify these fields!
207 typedef struct cvar_s {
208 	char *name;
209 	char *string;
210 	char *latched_string;  // for CVAR_LATCH vars
211 	int flags;
212 	qboolean modified;  // set each time the cvar is changed
213 	float value;
214 	struct cvar_s *next;
215 } cvar_t;
216 
217 /*
218 
219 COLLISION DETECTION
220 
221 */
222 
223 // lower bits are stronger, and will eat weaker brushes completely
224 #define CONTENTS_SOLID			1  // an eye is never valid in a solid
225 #define CONTENTS_WINDOW			2  // translucent, but not watery
226 #define CONTENTS_AUX			4
227 #define CONTENTS_LAVA			8
228 #define CONTENTS_SLIME			16
229 #define CONTENTS_WATER			32
230 #define CONTENTS_MIST			64
231 #define LAST_VISIBLE_CONTENTS	64
232 
233 // remaining contents are non-visible, and don't eat brushes
234 
235 #define CONTENTS_AREAPORTAL		0x8000
236 
237 #define CONTENTS_PLAYERCLIP		0x10000
238 #define CONTENTS_MONSTERCLIP	0x20000
239 
240 // currents can be added to any other contents, and may be mixed
241 #define CONTENTS_CURRENT_0		0x40000
242 #define CONTENTS_CURRENT_90		0x80000
243 #define CONTENTS_CURRENT_180	0x100000
244 #define CONTENTS_CURRENT_270	0x200000
245 #define CONTENTS_CURRENT_UP		0x400000
246 #define CONTENTS_CURRENT_DOWN	0x800000
247 
248 #define CONTENTS_ORIGIN			0x1000000  // removed before bsping an entity
249 
250 #define CONTENTS_MONSTER		0x2000000  // should never be on a brush, only in game
251 #define CONTENTS_DEADMONSTER	0x4000000
252 
253 #define CONTENTS_DETAIL			0x8000000  // brushes to be added after vis leafs
254 #define CONTENTS_TRANSLUCENT	0x10000000  // auto set if any surface has trans
255 #define CONTENTS_LADDER			0x20000000
256 
257 
258 #define SURF_LIGHT		0x1  // value will hold the light strength
259 #define SURF_SLICK		0x2  // effects game physics
260 #define SURF_SKY		0x4  // don't draw, but add to skybox
261 #define SURF_WARP		0x8  // turbulent water warp
262 #define SURF_TRANS33	0x10
263 #define SURF_TRANS66	0x20
264 #define SURF_FLOWING	0x40  // scroll towards angle
265 #define SURF_NODRAW		0x80  // don't bother referencing the texture
266 
267 // content masks
268 #define MASK_ALL			(-1)
269 #define MASK_SOLID			(CONTENTS_SOLID|CONTENTS_WINDOW)
270 #define MASK_PLAYERSOLID	(CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
271 #define MASK_DEADSOLID		(CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW)
272 #define MASK_MONSTERSOLID	(CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
273 #define MASK_WATER			(CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)
274 #define MASK_OPAQUE			(CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)
275 #define MASK_SHOT			(CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER)
276 #define MASK_CURRENT		(CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|\
277 							CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
278 
279 // gi.BoxEdicts() can return a list of either solid or trigger entities
280 // FIXME: eliminate AREA_ distinction?
281 #define AREA_SOLID 1
282 #define AREA_TRIGGERS 2
283 
284 // plane_t structure
285 typedef struct cplane_s {
286 	vec3_t normal;
287 	float dist;
288 	byte type;  // for fast side tests
289 	byte signbits;  // signx + (signy<<1) + (signz<<1)
290 	byte pad[2];
291 } cplane_t;
292 
293 typedef struct cmodel_s {
294 	vec3_t mins, maxs;
295 	vec3_t origin;  // for sounds or lights
296 	int headnode;
297 } cmodel_t;
298 
299 typedef struct csurface_s {
300 	char name[16];
301 	int flags;
302 	int value;
303 } csurface_t;
304 
305 // used internally due to name len probs //ZOID
306 typedef struct mapsurface_s {
307 	csurface_t c;
308 	char rname[32];
309 } mapsurface_t;
310 
311 // a trace is returned when a box is swept through the world
312 typedef struct {
313 	qboolean allsolid;  // if true, plane is not valid
314 	qboolean startsolid;  // if true, the initial point was in a solid area
315 	float fraction;  // time completed, 1.0 = didn't hit anything
316 	vec3_t endpos;  // final position
317 	cplane_t plane;  // surface normal at impact
318 	csurface_t *surface;  // surface hit
319 	int contents;  // contents on other side of surface hit
320 	struct edict_s *ent;  // not set by CM_*() functions
321 } trace_t;
322 
323 // pmove_state_t is the information necessary for client side movement prediction
324 typedef enum {
325 	// can accelerate and turn
326 	PM_NORMAL,
327 	PM_SPECTATOR,
328 	// no acceleration or turning
329 	PM_DEAD,
330 	PM_GIB,   // different bounding box
331 	PM_FREEZE
332 } pmtype_t;
333 
334 // pmove->pm_flags
335 #define PMF_DUCKED			1
336 #define PMF_JUMP_HELD		2
337 #define PMF_ON_GROUND		4
338 #define PMF_TIME_WATERJUMP	8  // pm_time is waterjump
339 #define PMF_TIME_LAND		16  // pm_time is time before rejump
340 #define PMF_TIME_TELEPORT	32  // pm_time is non-moving time
341 #define PMF_NO_PREDICTION	64  // temporarily disables prediction(used for grappling hook)
342 
343 // this structure needs to be communicated bit-accurate
344 // from the server to the client to guarantee that
345 // prediction stays in sync, so no floats are used.
346 // if any part of the game code modifies this struct, it
347 // will result in a prediction error of some degree.
348 typedef struct {
349 	pmtype_t pm_type;
350 
351 	short origin[3];  // 12.3
352 	short velocity[3];  // 12.3
353 	byte pm_flags;  // ducked, jump_held, etc
354 	byte pm_time;  // each unit = 8 ms
355 	short gravity;
356 	short delta_angles[3];  // add to command angles to get view direction
357 	// changed by spawns, rotating objects, and teleporters
358 } pmove_state_t;
359 
360 // button bits
361 #define BUTTON_ATTACK		1
362 #define BUTTON_USE			2
363 #define BUTTON_ANY			128  // any key whatsoever
364 
365 // usercmd_t is sent to the server each client frame
366 typedef struct usercmd_s {
367 	byte msec;
368 	byte buttons;
369 	short angles[3];
370 	short forwardmove, sidemove, upmove;
371 	byte impulse;  // remove?
372 	byte lightlevel;  // light level the player is standing on, no longer used
373 } usercmd_t;
374 
375 #define MAXTOUCH 32
376 typedef struct {
377 	pmove_state_t s;  // state (in / out)
378 
379 	usercmd_t cmd;  // command (in)
380 	qboolean snapinitial;  // if s has been changed outside pmove
381 
382 	int numtouch;  // results (out)
383 	struct edict_s *touchents[MAXTOUCH];
384 
385 	vec3_t viewangles;  // clamped
386 	float viewheight;
387 
388 	vec3_t mins, maxs;  // bounding box size
389 
390 	struct edict_s *groundentity;
391 	int watertype;
392 	int waterlevel;
393 
394 	// callbacks to test the world
395 	trace_t (*trace)(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
396 	int (*pointcontents)(vec3_t point);
397 } pmove_t;
398 
399 
400 /*
401 pmove_new_t is now used by the engine and extends pmove_t via SV_Pmove
402 to maintain compatibility with game mods
403 */
404 typedef struct {
405 	pmove_state_t s;  // state (in / out)
406 
407 	usercmd_t cmd;  // command (in)
408 	qboolean snapinitial;  // if s has been changed outside pmove
409 
410 	int numtouch;  // results (out)
411 	struct edict_s *touchents[MAXTOUCH];
412 
413 	vec3_t viewangles;  // clamped
414 	float viewheight;
415 
416 	vec3_t mins, maxs;  // bounding box size
417 
418 	struct edict_s *groundentity;
419 	int watertype;
420 	int waterlevel;
421 
422 	// callbacks to test the world
423 	trace_t (*trace)(vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
424 	int (*pointcontents)(vec3_t point);
425 
426 	float multiplier;  // r1q2 extensions
427 	qboolean strafehack;
428 	qboolean enhanced;
429 } pmove_new_t;
430 
431 
432 // entity_state_t->effects
433 // Effects are things handled on the client side(lights, particles, frame animations)
434 // that happen constantly on the given entity.
435 // An entity that has effects will be sent to the client
436 // even if it has a zero index model.
437 #define EF_ROTATE			0x00000001  // rotate(bonus items)
438 #define EF_GIB				0x00000002  // leave a trail
439 #define EF_BLASTER			0x00000008  // redlight + trail
440 #define EF_ROCKET			0x00000010  // redlight + trail
441 #define EF_GRENADE			0x00000020
442 #define EF_HYPERBLASTER		0x00000040
443 #define EF_BFG				0x00000080
444 #define EF_COLOR_SHELL		0x00000100
445 #define EF_POWERSCREEN		0x00000200
446 #define EF_ANIM01			0x00000400  // automatically cycle between frames 0 and 1 at 2 hz
447 #define EF_ANIM23			0x00000800  // automatically cycle between frames 2 and 3 at 2 hz
448 #define EF_ANIM_ALL			0x00001000  // automatically cycle through all frames at 2hz
449 #define EF_ANIM_ALLFAST		0x00002000  // automatically cycle through all frames at 10hz
450 #define EF_FLIES			0x00004000
451 #define EF_QUAD				0x00008000
452 #define EF_PENT				0x00010000
453 #define EF_TELEPORTER		0x00020000  // particle fountain
454 #define EF_FLAG1			0x00040000
455 #define EF_FLAG2			0x00080000
456 
457 // entity_state_t->renderfx flags
458 #define RF_MINLIGHT			1  // allways have some light
459 #define RF_VIEWERMODEL		2  // don't draw through eyes, only mirrors
460 #define RF_WEAPONMODEL		4  // only draw through eyes, no longer used
461 #define RF_FULLBRIGHT		8  // allways draw full intensity
462 #define RF_DEPTHHACK		16  // for view weapon Z crunching, no longer used
463 #define RF_TRANSLUCENT		32
464 #define RF_FRAMELERP		64
465 #define RF_BEAM				128
466 #define RF_CUSTOMSKIN		256  // skin is an index in image_precache
467 #define RF_GLOW				512  // pulse lighting for bonus items
468 #define RF_SHELL_RED		1024
469 #define RF_SHELL_GREEN		2048
470 #define RF_SHELL_BLUE		4096
471 #define RF_NOSHADOW			8192  // no longer used
472 
473 // player_state_t->viewdef flags
474 #define RDF_UNDERWATER		1  // warp the screen as apropriate
475 #define RDF_NOWORLDMODEL	2  // used for player configuration screen
476 
477 // muzzle flashes / player effects
478 #define MZ_BLASTER			0
479 #define MZ_MACHINEGUN		1
480 #define MZ_SHOTGUN			2
481 #define MZ_CHAINGUN1		3
482 #define MZ_CHAINGUN2		4
483 #define MZ_CHAINGUN3		5
484 #define MZ_RAILGUN			6
485 #define MZ_ROCKET			7
486 #define MZ_GRENADE			8
487 #define MZ_LOGIN			9
488 #define MZ_LOGOUT			10
489 #define MZ_RESPAWN			11
490 #define MZ_BFG				12
491 #define MZ_SSHOTGUN			13
492 #define MZ_HYPERBLASTER		14
493 #define MZ_ITEMRESPAWN		15
494 #define MZ_SILENCED 128
495 
496 // monster muzzle flashes
497 #define MZ2_TANK_BLASTER_1				1
498 #define MZ2_TANK_BLASTER_2				2
499 #define MZ2_TANK_BLASTER_3				3
500 #define MZ2_TANK_MACHINEGUN_1			4
501 #define MZ2_TANK_MACHINEGUN_2			5
502 #define MZ2_TANK_MACHINEGUN_3			6
503 #define MZ2_TANK_MACHINEGUN_4			7
504 #define MZ2_TANK_MACHINEGUN_5			8
505 #define MZ2_TANK_MACHINEGUN_6			9
506 #define MZ2_TANK_MACHINEGUN_7			10
507 #define MZ2_TANK_MACHINEGUN_8			11
508 #define MZ2_TANK_MACHINEGUN_9			12
509 #define MZ2_TANK_MACHINEGUN_10			13
510 #define MZ2_TANK_MACHINEGUN_11			14
511 #define MZ2_TANK_MACHINEGUN_12			15
512 #define MZ2_TANK_MACHINEGUN_13			16
513 #define MZ2_TANK_MACHINEGUN_14			17
514 #define MZ2_TANK_MACHINEGUN_15			18
515 #define MZ2_TANK_MACHINEGUN_16			19
516 #define MZ2_TANK_MACHINEGUN_17			20
517 #define MZ2_TANK_MACHINEGUN_18			21
518 #define MZ2_TANK_MACHINEGUN_19			22
519 #define MZ2_TANK_ROCKET_1				23
520 #define MZ2_TANK_ROCKET_2				24
521 #define MZ2_TANK_ROCKET_3				25
522 
523 #define MZ2_INFANTRY_MACHINEGUN_1		26
524 #define MZ2_INFANTRY_MACHINEGUN_2		27
525 #define MZ2_INFANTRY_MACHINEGUN_3		28
526 #define MZ2_INFANTRY_MACHINEGUN_4		29
527 #define MZ2_INFANTRY_MACHINEGUN_5		30
528 #define MZ2_INFANTRY_MACHINEGUN_6		31
529 #define MZ2_INFANTRY_MACHINEGUN_7		32
530 #define MZ2_INFANTRY_MACHINEGUN_8		33
531 #define MZ2_INFANTRY_MACHINEGUN_9		34
532 #define MZ2_INFANTRY_MACHINEGUN_10		35
533 #define MZ2_INFANTRY_MACHINEGUN_11		36
534 #define MZ2_INFANTRY_MACHINEGUN_12		37
535 #define MZ2_INFANTRY_MACHINEGUN_13		38
536 
537 #define MZ2_SOLDIER_BLASTER_1			39
538 #define MZ2_SOLDIER_BLASTER_2			40
539 #define MZ2_SOLDIER_SHOTGUN_1			41
540 #define MZ2_SOLDIER_SHOTGUN_2			42
541 #define MZ2_SOLDIER_MACHINEGUN_1		43
542 #define MZ2_SOLDIER_MACHINEGUN_2		44
543 
544 #define MZ2_GUNNER_MACHINEGUN_1			45
545 #define MZ2_GUNNER_MACHINEGUN_2			46
546 #define MZ2_GUNNER_MACHINEGUN_3			47
547 #define MZ2_GUNNER_MACHINEGUN_4			48
548 #define MZ2_GUNNER_MACHINEGUN_5			49
549 #define MZ2_GUNNER_MACHINEGUN_6			50
550 #define MZ2_GUNNER_MACHINEGUN_7			51
551 #define MZ2_GUNNER_MACHINEGUN_8			52
552 #define MZ2_GUNNER_GRENADE_1			53
553 #define MZ2_GUNNER_GRENADE_2			54
554 #define MZ2_GUNNER_GRENADE_3			55
555 #define MZ2_GUNNER_GRENADE_4			56
556 
557 #define MZ2_CHICK_ROCKET_1				57
558 
559 #define MZ2_FLYER_BLASTER_1				58
560 #define MZ2_FLYER_BLASTER_2				59
561 
562 #define MZ2_MEDIC_BLASTER_1				60
563 
564 #define MZ2_GLADIATOR_RAILGUN_1			61
565 
566 #define MZ2_HOVER_BLASTER_1				62
567 
568 #define MZ2_ACTOR_MACHINEGUN_1			63
569 
570 #define MZ2_SUPERTANK_MACHINEGUN_1		64
571 #define MZ2_SUPERTANK_MACHINEGUN_2		65
572 #define MZ2_SUPERTANK_MACHINEGUN_3		66
573 #define MZ2_SUPERTANK_MACHINEGUN_4		67
574 #define MZ2_SUPERTANK_MACHINEGUN_5		68
575 #define MZ2_SUPERTANK_MACHINEGUN_6		69
576 #define MZ2_SUPERTANK_ROCKET_1			70
577 #define MZ2_SUPERTANK_ROCKET_2			71
578 #define MZ2_SUPERTANK_ROCKET_3			72
579 
580 #define MZ2_BOSS2_MACHINEGUN_L1			73
581 #define MZ2_BOSS2_MACHINEGUN_L2			74
582 #define MZ2_BOSS2_MACHINEGUN_L3			75
583 #define MZ2_BOSS2_MACHINEGUN_L4			76
584 #define MZ2_BOSS2_MACHINEGUN_L5			77
585 #define MZ2_BOSS2_ROCKET_1				78
586 #define MZ2_BOSS2_ROCKET_2				79
587 #define MZ2_BOSS2_ROCKET_3				80
588 #define MZ2_BOSS2_ROCKET_4				81
589 
590 #define MZ2_FLOAT_BLASTER_1				82
591 
592 #define MZ2_SOLDIER_BLASTER_3			83
593 #define MZ2_SOLDIER_SHOTGUN_3			84
594 #define MZ2_SOLDIER_MACHINEGUN_3		85
595 #define MZ2_SOLDIER_BLASTER_4			86
596 #define MZ2_SOLDIER_SHOTGUN_4			87
597 #define MZ2_SOLDIER_MACHINEGUN_4		88
598 #define MZ2_SOLDIER_BLASTER_5			89
599 #define MZ2_SOLDIER_SHOTGUN_5			90
600 #define MZ2_SOLDIER_MACHINEGUN_5		91
601 #define MZ2_SOLDIER_BLASTER_6			92
602 #define MZ2_SOLDIER_SHOTGUN_6			93
603 #define MZ2_SOLDIER_MACHINEGUN_6		94
604 #define MZ2_SOLDIER_BLASTER_7			95
605 #define MZ2_SOLDIER_SHOTGUN_7			96
606 #define MZ2_SOLDIER_MACHINEGUN_7		97
607 #define MZ2_SOLDIER_BLASTER_8			98
608 #define MZ2_SOLDIER_SHOTGUN_8			99
609 #define MZ2_SOLDIER_MACHINEGUN_8		100
610 
611 // --- Xian shit below ---
612 #define MZ2_MAKRON_BFG					101
613 #define MZ2_MAKRON_BLASTER_1			102
614 #define MZ2_MAKRON_BLASTER_2			103
615 #define MZ2_MAKRON_BLASTER_3			104
616 #define MZ2_MAKRON_BLASTER_4			105
617 #define MZ2_MAKRON_BLASTER_5			106
618 #define MZ2_MAKRON_BLASTER_6			107
619 #define MZ2_MAKRON_BLASTER_7			108
620 #define MZ2_MAKRON_BLASTER_8			109
621 #define MZ2_MAKRON_BLASTER_9			110
622 #define MZ2_MAKRON_BLASTER_10			111
623 #define MZ2_MAKRON_BLASTER_11			112
624 #define MZ2_MAKRON_BLASTER_12			113
625 #define MZ2_MAKRON_BLASTER_13			114
626 #define MZ2_MAKRON_BLASTER_14			115
627 #define MZ2_MAKRON_BLASTER_15			116
628 #define MZ2_MAKRON_BLASTER_16			117
629 #define MZ2_MAKRON_BLASTER_17			118
630 #define MZ2_MAKRON_RAILGUN_1			119
631 #define MZ2_JORG_MACHINEGUN_L1			120
632 #define MZ2_JORG_MACHINEGUN_L2			121
633 #define MZ2_JORG_MACHINEGUN_L3			122
634 #define MZ2_JORG_MACHINEGUN_L4			123
635 #define MZ2_JORG_MACHINEGUN_L5			124
636 #define MZ2_JORG_MACHINEGUN_L6			125
637 #define MZ2_JORG_MACHINEGUN_R1			126
638 #define MZ2_JORG_MACHINEGUN_R2			127
639 #define MZ2_JORG_MACHINEGUN_R3			128
640 #define MZ2_JORG_MACHINEGUN_R4			129
641 #define MZ2_JORG_MACHINEGUN_R5			130
642 #define MZ2_JORG_MACHINEGUN_R6			131
643 #define MZ2_JORG_BFG_1					132
644 #define MZ2_BOSS2_MACHINEGUN_R1			133
645 #define MZ2_BOSS2_MACHINEGUN_R2			134
646 #define MZ2_BOSS2_MACHINEGUN_R3			135
647 #define MZ2_BOSS2_MACHINEGUN_R4			136
648 #define MZ2_BOSS2_MACHINEGUN_R5			137
649 
650 extern	vec3_t monster_flash_offset [];
651 
652 // temp entity events
653 // Temp entity events are for things that happen
654 // at a location seperate from any existing entity.
655 // Temporary entity messages are explicitly constructed
656 // and broadcast.
657 typedef enum {
658 	TE_GUNSHOT,
659 	TE_BLOOD,
660 	TE_BLASTER,
661 	TE_RAILTRAIL,
662 	TE_SHOTGUN,
663 	TE_EXPLOSION1,
664 	TE_EXPLOSION2,
665 	TE_ROCKET_EXPLOSION,
666 	TE_GRENADE_EXPLOSION,
667 	TE_SPARKS,
668 	TE_SPLASH,
669 	TE_BUBBLETRAIL,
670 	TE_SCREEN_SPARKS,
671 	TE_SHIELD_SPARKS,
672 	TE_BULLET_SPARKS,
673 	TE_LASER_SPARKS,
674 	TE_PARASITE_ATTACK,
675 	TE_ROCKET_EXPLOSION_WATER,
676 	TE_GRENADE_EXPLOSION_WATER,
677 	TE_MEDIC_CABLE_ATTACK,
678 	TE_BFG_EXPLOSION,
679 	TE_BFG_BIGEXPLOSION,
680 	TE_BOSSTPORT,   // used as '22' in a map, so DON'T RENUMBER!!!
681 	TE_BFG_LASER,
682 	TE_GRAPPLE_CABLE,
683 } temp_event_t;
684 
685 #define SPLASH_UNKNOWN		0
686 #define SPLASH_SPARKS		1
687 #define SPLASH_BLUE_WATER	2
688 #define SPLASH_BROWN_WATER	3
689 #define SPLASH_SLIME		4
690 #define SPLASH_LAVA			5
691 #define SPLASH_BLOOD		6
692 
693 // sound channels
694 // channel 0 never willingly overrides
695 // other channels(1-7) allways override a playing sound on that channel
696 #define CHAN_AUTO			0
697 #define CHAN_WEAPON			1
698 #define CHAN_VOICE			2
699 #define CHAN_ITEM			3
700 #define CHAN_BODY			4
701 #define CHAN_NO_PHS_ADD		8  // send to all clients, not just ones in PHS(ATTN 0 will also do this)
702 #define CHAN_RELIABLE  		16  // send by reliable message, not datagram
703 
704 // sound attenuation values
705 #define ATTN_NONE  			0  // full volume the entire level
706 #define ATTN_NORM  			1
707 #define ATTN_IDLE  			2
708 #define ATTN_STATIC  		3  // diminish very rapidly with distance
709 
710 // player_state->stats[] indexes
711 #define STAT_HEALTH_ICON	0
712 #define STAT_HEALTH			1
713 #define STAT_AMMO_ICON		2
714 #define STAT_AMMO			3
715 #define STAT_ARMOR_ICON		4
716 #define STAT_ARMOR			5
717 #define STAT_SELECTED_ICON	6
718 #define STAT_PICKUP_ICON	7
719 #define STAT_PICKUP_STRING	8
720 #define STAT_TIMER_ICON		9
721 #define STAT_TIMER			10
722 #define STAT_HELPICON		11
723 #define STAT_SELECTED_ITEM	12
724 #define STAT_LAYOUTS		13
725 #define STAT_FRAGS			14
726 #define STAT_FLASHES		15  // cleared each frame, 1 = health, 2 = armor
727 #define STAT_CHASE			16
728 #define STAT_SPECTATOR		17
729 
730 #define MAX_STATS			32
731 
732 // dmflags->value flags
733 #define DF_NO_HEALTH		0x00000001  // 1
734 #define DF_NO_ITEMS			0x00000002  // 2
735 #define DF_WEAPONS_STAY		0x00000004  // 4
736 #define DF_NO_FALLING		0x00000008  // 8
737 #define DF_INSTANT_ITEMS	0x00000010  // 16
738 #define DF_SAME_LEVEL		0x00000020  // 32
739 #define DF_SKINTEAMS		0x00000040  // 64
740 #define DF_MODELTEAMS		0x00000080  // 128
741 #define DF_NO_FRIENDLY_FIRE	0x00000100  // 256
742 #define DF_SPAWN_FARTHEST	0x00000200  // 512
743 #define DF_FORCE_RESPAWN	0x00000400  // 1024
744 #define DF_NO_ARMOR			0x00000800  // 2048
745 #define DF_ALLOW_EXIT		0x00001000  // 4096
746 #define DF_INFINITE_AMMO	0x00002000  // 8192
747 #define DF_QUAD_DROP		0x00004000  // 16384
748 #define DF_FIXED_FOV		0x00008000  // 32768
749 
750 
751 /*
752 
753   ELEMENTS COMMUNICATED ACROSS THE NET
754 
755 */
756 
757 #define ANGLE2SHORT(x)	((int)((x)*65536/360) & 65535)
758 #define SHORT2ANGLE(x)	((x)*(360.0/65536))
759 
760 // config strings are a general means of communication from
761 // the server to all connected clients.
762 // Each config string can be at most MAX_QPATH characters.
763 #define CS_NAME				0
764 #define CS_CDTRACK			1
765 #define CS_SKY				2
766 #define CS_SKYAXIS			3  // %f %f %f format
767 #define CS_SKYROTATE		4
768 #define CS_STATUSBAR		5  // display program string
769 
770 #define CS_AIRACCEL			29  // air acceleration control
771 #define CS_MAXCLIENTS		30
772 #define CS_MAPCHECKSUM		31  // for catching cheater maps
773 
774 #define CS_MODELS			32
775 #define CS_SOUNDS			(CS_MODELS+MAX_MODELS)
776 #define CS_IMAGES			(CS_SOUNDS+MAX_SOUNDS)
777 #define CS_LIGHTS			(CS_IMAGES+MAX_IMAGES)
778 #define CS_ITEMS			(CS_LIGHTS+MAX_LIGHTSTYLES)
779 #define CS_PLAYERSKINS		(CS_ITEMS+MAX_ITEMS)
780 #define CS_GENERAL			(CS_PLAYERSKINS+MAX_CLIENTS)
781 
782 #define MAX_CONFIGSTRINGS	(CS_GENERAL+MAX_GENERAL)
783 
784 // entity_state_t->event values
785 // ertity events are for effects that take place reletive
786 // to an existing entities origin.  Very network efficient.
787 // All muzzle flashes really should be converted to events...
788 typedef enum {
789 	EV_NONE,
790 	EV_ITEM_RESPAWN,
791 	EV_FOOTSTEP,
792 	EV_FALLSHORT,
793 	EV_FALL,
794 	EV_FALLFAR,
795 	EV_PLAYER_TELEPORT,
796 	EV_OTHER_TELEPORT
797 } entity_event_t;
798 
799 // entity_state_t is the information conveyed from the server
800 // in an update message about entities that the client will
801 // need to render in some way
802 typedef struct entity_state_s {
803 	int number;  // edict index
804 
805 	vec3_t origin;
806 	vec3_t angles;
807 	vec3_t old_origin;  // for lerping
808 	int modelindex;
809 	int modelindex2, modelindex3, modelindex4;  // weapons, CTF flags, etc
810 	int frame;
811 	int skinnum;
812 	unsigned int effects;  // PGM - we're filling it, so it needs to be unsigned
813 	int renderfx;
814 	int solid;  // for client side prediction, 8*(bits 0-4) is x/y radius
815 	// 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
816 	// gi.linkentity sets this properly
817 	int sound;  // for looping sounds, to guarantee shutoff
818 	int event;  // impulse events -- muzzle flashes, footsteps, etc
819 	// events only go out for a single frame, they
820 	// are automatically cleared each frame
821 } entity_state_t;
822 
823 // player_state_t is the information needed in addition to pmove_state_t
824 // to rendered a view.  There will only be 10 player_state_t sent each second,
825 // but the number of pmove_state_t changes will be reletive to client
826 // frame rates
827 typedef struct {
828 	pmove_state_t pmove;  // for prediction
829 	// these fields do not need to be communicated bit-precise
830 	vec3_t viewangles;  // for fixed views
831 	vec3_t viewoffset;  // add to pmovestate->origin
832 	vec3_t kick_angles;  // add to view direction to get render angles
833 	// set by weapon kicks, pain effects, etc
834 	vec3_t gunangles;
835 	vec3_t gunoffset;
836 	int gunindex;
837 	int gunframe;
838 	float blend[4];  // rgba full screen effect
839 	float fov;  // horizontal field of view
840 	int rdflags;  // viewdef flags
841 	short stats[MAX_STATS];  // fast status bar updates
842 	vec3_t mins;  // r1q2 stuff
843 	vec3_t maxs;
844 } player_state_t;
845 
846 /* error save versions of fread and fwrite */
847 size_t verify_fread(void *, size_t, size_t, FILE *);
848 size_t verify_fwrite(void *, size_t, size_t, FILE *);
849 
850 #endif /* __Q_SHARED_H__ */
851