1 /*
2 ===========================================================================
3 Copyright (C) 1999 - 2005, Id Software, Inc.
4 Copyright (C) 2000 - 2013, Raven Software, Inc.
5 Copyright (C) 2001 - 2013, Activision, Inc.
6 Copyright (C) 2005 - 2015, ioquake3 contributors
7 Copyright (C) 2013 - 2015, OpenJK contributors
8 
9 This file is part of the OpenJK source code.
10 
11 OpenJK is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License version 2 as
13 published by the Free Software Foundation.
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, see <http://www.gnu.org/licenses/>.
22 ===========================================================================
23 */
24 
25 #pragma once
26 
27 // q_shared.h -- included first by ALL program modules.
28 // A user mod should never modify this file
29 
30 #define PRODUCT_NAME			"openjk"
31 
32 #define CLIENT_WINDOW_TITLE "OpenJK (MP)"
33 #define CLIENT_CONSOLE_TITLE "OpenJK Console (MP)"
34 #define HOMEPATH_NAME_UNIX "openjk"
35 #define HOMEPATH_NAME_WIN "OpenJK"
36 #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
37 
38 #define	BASEGAME "base"
39 #define OPENJKGAME "OpenJK"
40 
41 //NOTENOTE: Only change this to re-point ICARUS to a new script directory
42 #define Q3_SCRIPT_DIR	"scripts"
43 
44 #define MAX_TEAMNAME 32
45 #define MAX_MASTER_SERVERS      5	// number of supported master servers
46 
47 #define BASE_COMPAT // some unused and leftover code has been stripped out, but this breaks compatibility
48 					//	between base<->modbase clients and servers (mismatching events, powerups, etc)
49 					// leave this defined to ensure compatibility
50 
51 #include "qcommon/q_math.h"
52 #include "qcommon/q_color.h"
53 #include "qcommon/q_string.h"
54 #include "qcommon/disablewarnings.h"
55 
56 #include "game/teams.h" //npc team stuff
57 
58 #define MAX_WORLD_COORD		( 64 * 1024 )
59 #define MIN_WORLD_COORD		( -64 * 1024 )
60 #define WORLD_SIZE			( MAX_WORLD_COORD - MIN_WORLD_COORD )
61 
62 //Pointer safety utilities
63 #define VALID( a )		( a != NULL )
64 #define	VALIDATE( a )	( assert( a ) )
65 
66 #define	VALIDATEV( a )	if ( a == NULL ) {	assert(0);	return;			}
67 #define	VALIDATEB( a )	if ( a == NULL ) {	assert(0);	return qfalse;	}
68 #define VALIDATEP( a )	if ( a == NULL ) {	assert(0);	return NULL;	}
69 
70 #define VALIDSTRING( a )	( ( a != NULL ) && ( a[0] != '\0' ) )
71 #define VALIDENT( e )		( ( e != NULL ) && ( (e)->inuse ) )
72 
73 #define ARRAY_LEN( x ) ( sizeof( x ) / sizeof( *(x) ) )
74 #define STRING( a ) #a
75 #define XSTRING( a ) STRING( a )
76 /*
77 #define G2_EHNANCEMENTS
78 
79 #ifdef G2_EHNANCEMENTS
80 //these two will probably explode if they're defined independent of one another.
81 //rww - RAGDOLL_BEGIN
82 #define JK2_RAGDOLL
83 //rww - RAGDOLL_END
84 //rww - Bone cache for multiplayer base.
85 #define MP_BONECACHE
86 #endif
87 */
88 
89 #ifndef FINAL_BUILD
90 	// may want to enable timing and leak checking again. requires G2API changes.
91 //	#define G2_PERFORMANCE_ANALYSIS
92 //	#define _FULL_G2_LEAK_CHECKING
93 //	extern int g_Ghoul2Allocations;
94 //	extern int g_G2ServerAlloc;
95 //	extern int g_G2ClientAlloc;
96 //	extern int g_G2AllocServer;
97 #endif
98 
99 #include <assert.h>
100 #include <math.h>
101 #include <float.h>
102 #include <stdio.h>
103 #include <stdarg.h>
104 #include <string.h>
105 #include <stdlib.h>
106 #include <time.h>
107 #include <ctype.h>
108 #include <limits.h>
109 #include <errno.h>
110 #include <stddef.h>
111 
112 //Ignore __attribute__ on non-gcc platforms
113 #if !defined(__GNUC__) && !defined(__attribute__)
114 	#define __attribute__(x)
115 #endif
116 
117 #if defined(__GNUC__)
118 	#define UNUSED_VAR __attribute__((unused))
119 #else
120 	#define UNUSED_VAR
121 #endif
122 
123 #if (defined _MSC_VER)
124 	#define Q_EXPORT __declspec(dllexport)
125 #elif (defined __SUNPRO_C)
126 	#define Q_EXPORT __global
127 #elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
128 	#define Q_EXPORT __attribute__((visibility("default")))
129 #else
130 	#define Q_EXPORT
131 #endif
132 
133 // this is the define for determining if we have an asm version of a C function
134 #if (defined(_M_IX86) || defined(__i386__)) && !defined(__sun__)
135 	#define id386	1
136 #else
137 	#define id386	0
138 #endif
139 
140 #if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
141 	#define idppc	1
142 #else
143 	#define idppc	0
144 #endif
145 
146 #include "qcommon/q_platform.h"
147 
148 typedef union fileBuffer_u {
149 	void *v;
150 	char *c;
151 	byte *b;
152 } fileBuffer_t;
153 
154 typedef int32_t qhandle_t, thandle_t, fxHandle_t, sfxHandle_t, fileHandle_t, clipHandle_t;
155 
156 #define NULL_HANDLE ((qhandle_t)0)
157 #define NULL_SOUND ((sfxHandle_t)0)
158 #define NULL_FX ((fxHandle_t)0)
159 #define NULL_SFX ((sfxHandle_t)0)
160 #define NULL_FILE ((fileHandle_t)0)
161 #define NULL_CLIP ((clipHandle_t)0)
162 
163 #define PAD(base, alignment)	(((base)+(alignment)-1) & ~((alignment)-1))
164 #define PADLEN(base, alignment)	(PAD((base), (alignment)) - (base))
165 
166 #define PADP(base, alignment)	((void *) PAD((intptr_t) (base), (alignment)))
167 
168 #ifdef __GNUC__
169 #define QALIGN(x) __attribute__((aligned(x)))
170 #else
171 #define QALIGN(x)
172 #endif
173 
174 #ifndef NULL
175 #define NULL ((void *)0)
176 #endif
177 
178 #define INT_ID( a, b, c, d ) (uint32_t)((((a) & 0xff) << 24) | (((b) & 0xff) << 16) | (((c) & 0xff) << 8) | ((d) & 0xff))
179 
180 // the game guarantees that no string from the network will ever
181 // exceed MAX_STRING_CHARS
182 #define	MAX_STRING_CHARS	1024	// max length of a string passed to Cmd_TokenizeString
183 #define	MAX_STRING_TOKENS	1024	// max tokens resulting from Cmd_TokenizeString
184 #define	MAX_TOKEN_CHARS		1024	// max length of an individual token
185 
186 #define	MAX_INFO_STRING		1024
187 #define	MAX_INFO_KEY		1024
188 #define	MAX_INFO_VALUE		1024
189 
190 #define	BIG_INFO_STRING		8192  // used for system info key only
191 #define	BIG_INFO_KEY		  8192
192 #define	BIG_INFO_VALUE		8192
193 
194 #define NET_ADDRSTRMAXLEN 48 // maximum length of an IPv6 address string including trailing '\0'
195 
196 // moved these from ui_local.h so we can access them everywhere
197 #define MAX_ADDRESSLENGTH		256//64
198 #define MAX_HOSTNAMELENGTH		256//22
199 #define MAX_MAPNAMELENGTH		256//16
200 #define MAX_STATUSLENGTH		256//64
201 
202 #define	MAX_QPATH			64		// max length of a quake game pathname
203 #ifdef PATH_MAX
204 #define MAX_OSPATH			PATH_MAX
205 #else
206 #define	MAX_OSPATH			256		// max length of a filesystem pathname
207 #endif
208 
209 #define	MAX_NAME_LENGTH		32		// max length of a client name
210 #define MAX_NETNAME			36
211 
212 #define	MAX_SAY_TEXT	150
213 
214 // paramters for command buffer stuffing
215 typedef enum {
216 	EXEC_NOW,			// don't return until completed, a VM should NEVER use this,
217 						// because some commands might cause the VM to be unloaded...
218 	EXEC_INSERT,		// insert at current position, but don't run yet
219 	EXEC_APPEND			// add to end of the command buffer (normal case)
220 } cbufExec_t;
221 
222 
223 //
224 // these aren't needed by any of the VMs.  put in another header?
225 //
226 #define	MAX_MAP_AREA_BYTES		32		// bit vector of area visibility
227 
228 
229 #define LS_STYLES_START			0
230 #define LS_NUM_STYLES			32
231 #define	LS_SWITCH_START			(LS_STYLES_START+LS_NUM_STYLES)
232 #define LS_NUM_SWITCH			32
233 #if !defined MAX_LIGHT_STYLES
234 #define MAX_LIGHT_STYLES		64
235 #endif
236 
237 //For system-wide prints
238 enum WL_e {
239 	WL_ERROR=1,
240 	WL_WARNING,
241 	WL_VERBOSE,
242 	WL_DEBUG
243 };
244 
245 extern float forceSpeedLevels[4];
246 
247 // print levels from renderer (FIXME: set up for game / cgame?)
248 typedef enum {
249 	PRINT_ALL,
250 	PRINT_DEVELOPER,		// only print when "developer 1"
251 	PRINT_WARNING,
252 	PRINT_ERROR
253 } printParm_t;
254 
255 
256 #ifdef ERR_FATAL
257 #undef ERR_FATAL			// this is be defined in malloc.h
258 #endif
259 
260 // parameters to the main Error routine
261 typedef enum {
262 	ERR_FATAL,					// exit the entire game with a popup window
263 	ERR_DROP,					// print to console and disconnect from game
264 	ERR_SERVERDISCONNECT,		// don't kill server
265 	ERR_DISCONNECT,				// client disconnected from the server
266 	ERR_NEED_CD					// pop up the need-cd dialog
267 } errorParm_t;
268 
269 
270 // font rendering values used by ui and cgame
271 
272 /*#define PROP_GAP_WIDTH			3
273 #define PROP_SPACE_WIDTH		8
274 #define PROP_HEIGHT				27
275 #define PROP_SMALL_SIZE_SCALE	0.75*/
276 
277 #define PROP_GAP_WIDTH			2 // 3
278 #define PROP_SPACE_WIDTH		4
279 #define PROP_HEIGHT				16
280 
281 #define PROP_TINY_SIZE_SCALE	1
282 #define PROP_SMALL_SIZE_SCALE	1
283 #define PROP_BIG_SIZE_SCALE		1
284 #define PROP_GIANT_SIZE_SCALE	2
285 
286 #define PROP_TINY_HEIGHT		10
287 #define PROP_GAP_TINY_WIDTH		1
288 #define PROP_SPACE_TINY_WIDTH	3
289 
290 #define PROP_BIG_HEIGHT			24
291 #define PROP_GAP_BIG_WIDTH		3
292 #define PROP_SPACE_BIG_WIDTH	6
293 
294 #define BLINK_DIVISOR			200
295 #define PULSE_DIVISOR			75
296 
297 #define UI_LEFT			0x00000000	// default
298 #define UI_CENTER		0x00000001
299 #define UI_RIGHT		0x00000002
300 #define UI_FORMATMASK	0x00000007
301 #define UI_SMALLFONT	0x00000010
302 #define UI_BIGFONT		0x00000020	// default
303 
304 #define UI_DROPSHADOW	0x00000800
305 #define UI_BLINK		0x00001000
306 #define UI_INVERSE		0x00002000
307 #define UI_PULSE		0x00004000
308 
309 #if defined(_DEBUG) && !defined(BSPC)
310 	#define HUNK_DEBUG
311 #endif
312 
313 typedef enum {
314 	h_high,
315 	h_low,
316 	h_dontcare
317 } ha_pref;
318 
319 void *Hunk_Alloc( int size, ha_pref preference );
320 
321 #define Com_Memset memset
322 #define Com_Memcpy memcpy
323 
324 #define CIN_system	1
325 #define CIN_loop	2
326 #define	CIN_hold	4
327 #define CIN_silent	8
328 #define CIN_shader	16
329 
330 typedef enum {
331 	BLK_NO,
332 	BLK_TIGHT,		// Block only attacks and shots around the saber itself, a bbox of around 12x12x12
333 	BLK_WIDE		// Block all attacks in an area around the player in a rough arc of 180 degrees
334 } saberBlockType_t;
335 
336 typedef enum {
337 	BLOCKED_NONE,
338 	BLOCKED_BOUNCE_MOVE,
339 	BLOCKED_PARRY_BROKEN,
340 	BLOCKED_ATK_BOUNCE,
341 	BLOCKED_UPPER_RIGHT,
342 	BLOCKED_UPPER_LEFT,
343 	BLOCKED_LOWER_RIGHT,
344 	BLOCKED_LOWER_LEFT,
345 	BLOCKED_TOP,
346 	BLOCKED_UPPER_RIGHT_PROJ,
347 	BLOCKED_UPPER_LEFT_PROJ,
348 	BLOCKED_LOWER_RIGHT_PROJ,
349 	BLOCKED_LOWER_LEFT_PROJ,
350 	BLOCKED_TOP_PROJ
351 } saberBlockedType_t;
352 
353 typedef enum
354 {
355 	SABER_RED,
356 	SABER_ORANGE,
357 	SABER_YELLOW,
358 	SABER_GREEN,
359 	SABER_BLUE,
360 	SABER_PURPLE,
361 	NUM_SABER_COLORS
362 } saber_colors_t;
363 
364 typedef enum
365 {
366 	FP_FIRST = 0,//marker
367 	FP_HEAL = 0,//instant
368 	FP_LEVITATION,//hold/duration
369 	FP_SPEED,//duration
370 	FP_PUSH,//hold/duration
371 	FP_PULL,//hold/duration
372 	FP_TELEPATHY,//instant
373 	FP_GRIP,//hold/duration
374 	FP_LIGHTNING,//hold/duration
375 	FP_RAGE,//duration
376 	FP_PROTECT,
377 	FP_ABSORB,
378 	FP_TEAM_HEAL,
379 	FP_TEAM_FORCE,
380 	FP_DRAIN,
381 	FP_SEE,
382 	FP_SABER_OFFENSE,
383 	FP_SABER_DEFENSE,
384 	FP_SABERTHROW,
385 	NUM_FORCE_POWERS
386 } forcePowers_t;
387 
388 typedef enum forcePowerLevels_e {
389 	FORCE_LEVEL_0,
390 	FORCE_LEVEL_1,
391 	FORCE_LEVEL_2,
392 	FORCE_LEVEL_3,
393 	NUM_FORCE_POWER_LEVELS
394 } forcePowerLevels_t;
395 
396 #define	FORCE_LEVEL_4 (FORCE_LEVEL_3+1)
397 #define	FORCE_LEVEL_5 (FORCE_LEVEL_4+1)
398 
399 //rww - a C-ified structure version of the class which fires off callbacks and gives arguments to update ragdoll status.
400 enum sharedERagPhase
401 {
402 	RP_START_DEATH_ANIM,
403 	RP_END_DEATH_ANIM,
404 	RP_DEATH_COLLISION,
405 	RP_CORPSE_SHOT,
406 	RP_GET_PELVIS_OFFSET,  // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
407 	RP_SET_PELVIS_OFFSET,  // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
408 	RP_DISABLE_EFFECTORS  // this removes effectors given by the effectorsToTurnOff member
409 };
410 
411 enum sharedERagEffector
412 {
413 	RE_MODEL_ROOT=			0x00000001, //"model_root"
414 	RE_PELVIS=				0x00000002, //"pelvis"
415 	RE_LOWER_LUMBAR=		0x00000004, //"lower_lumbar"
416 	RE_UPPER_LUMBAR=		0x00000008, //"upper_lumbar"
417 	RE_THORACIC=			0x00000010, //"thoracic"
418 	RE_CRANIUM=				0x00000020, //"cranium"
419 	RE_RHUMEROUS=			0x00000040, //"rhumerus"
420 	RE_LHUMEROUS=			0x00000080, //"lhumerus"
421 	RE_RRADIUS=				0x00000100, //"rradius"
422 	RE_LRADIUS=				0x00000200, //"lradius"
423 	RE_RFEMURYZ=			0x00000400, //"rfemurYZ"
424 	RE_LFEMURYZ=			0x00000800, //"lfemurYZ"
425 	RE_RTIBIA=				0x00001000, //"rtibia"
426 	RE_LTIBIA=				0x00002000, //"ltibia"
427 	RE_RHAND=				0x00004000, //"rhand"
428 	RE_LHAND=				0x00008000, //"lhand"
429 	RE_RTARSAL=				0x00010000, //"rtarsal"
430 	RE_LTARSAL=				0x00020000, //"ltarsal"
431 	RE_RTALUS=				0x00040000, //"rtalus"
432 	RE_LTALUS=				0x00080000, //"ltalus"
433 	RE_RRADIUSX=			0x00100000, //"rradiusX"
434 	RE_LRADIUSX=			0x00200000, //"lradiusX"
435 	RE_RFEMURX=				0x00400000, //"rfemurX"
436 	RE_LFEMURX=				0x00800000, //"lfemurX"
437 	RE_CEYEBROW=			0x01000000 //"ceyebrow"
438 };
439 
440 typedef struct sharedRagDollParams_s {
441 	vec3_t angles;
442 	vec3_t position;
443 	vec3_t scale;
444 	vec3_t pelvisAnglesOffset;    // always set on return, an argument for RP_SET_PELVIS_OFFSET
445 	vec3_t pelvisPositionOffset; // always set on return, an argument for RP_SET_PELVIS_OFFSET
446 
447 	float fImpactStrength; //should be applicable when RagPhase is RP_DEATH_COLLISION
448 	float fShotStrength; //should be applicable for setting velocity of corpse on shot (probably only on RP_CORPSE_SHOT)
449 	int me; //index of entity giving this update
450 
451 	//rww - we have convenient animation/frame access in the game, so just send this info over from there.
452 	int startFrame;
453 	int endFrame;
454 
455 	int collisionType; // 1 = from a fall, 0 from effectors, this will be going away soon, hence no enum
456 
457 	qboolean CallRagDollBegin; // a return value, means that we are now begininng ragdoll and the NPC stuff needs to happen
458 
459 	int RagPhase;
460 
461 // effector control, used for RP_DISABLE_EFFECTORS call
462 
463 	int effectorsToTurnOff;  // set this to an | of the above flags for a RP_DISABLE_EFFECTORS
464 
465 } sharedRagDollParams_t;
466 
467 //And one for updating during model animation.
468 typedef struct sharedRagDollUpdateParams_s {
469 	vec3_t angles;
470 	vec3_t position;
471 	vec3_t scale;
472 	vec3_t velocity;
473 	int	me;
474 	int settleFrame;
475 } sharedRagDollUpdateParams_t;
476 
477 //rww - update parms for ik bone stuff
478 typedef struct sharedIKMoveParams_s {
479 	char boneName[512]; //name of bone
480 	vec3_t desiredOrigin; //world coordinate that this bone should be attempting to reach
481 	vec3_t origin; //world coordinate of the entity who owns the g2 instance that owns the bone
482 	float movementSpeed; //how fast the bone should move toward the destination
483 } sharedIKMoveParams_t;
484 
485 
486 typedef struct sharedSetBoneIKStateParams_s {
487 	vec3_t pcjMins; //ik joint limit
488 	vec3_t pcjMaxs; //ik joint limit
489 	vec3_t origin; //origin of caller
490 	vec3_t angles; //angles of caller
491 	vec3_t scale; //scale of caller
492 	float radius; //bone rad
493 	int blendTime; //bone blend time
494 	int pcjOverrides; //override ik bone flags
495 	int startFrame; //base pose start
496 	int endFrame; //base pose end
497 	qboolean forceAnimOnBone; //normally if the bone has specified start/end frames already it will leave it alone.. if this is true, then the animation will be restarted on the bone with the specified frames anyway.
498 } sharedSetBoneIKStateParams_t;
499 
500 enum sharedEIKMoveState
501 {
502 	IKS_NONE = 0,
503 	IKS_DYNAMIC
504 };
505 
506 //material stuff needs to be shared
507 typedef enum //# material_e
508 {
509 	MAT_METAL = 0,	// scorched blue-grey metal
510 	MAT_GLASS,		// not a real chunk type, just plays an effect with glass sprites
511 	MAT_ELECTRICAL,	// sparks only
512 	MAT_ELEC_METAL,	// sparks/electrical type metal
513 	MAT_DRK_STONE,	// brown
514 	MAT_LT_STONE,	// tan
515 	MAT_GLASS_METAL,// glass sprites and METAl chunk
516 	MAT_METAL2,		// electrical metal type
517 	MAT_NONE,		// no chunks
518 	MAT_GREY_STONE,	// grey
519 	MAT_METAL3,		// METAL and METAL2 chunks
520 	MAT_CRATE1,		// yellow multi-colored crate chunks
521 	MAT_GRATE1,		// grate chunks
522 	MAT_ROPE,		// for yavin trial...no chunks, just wispy bits
523 	MAT_CRATE2,		// read multi-colored crate chunks
524 	MAT_WHITE_METAL,// white angular chunks
525 	MAT_SNOWY_ROCK,	// gray & brown chunks
526 
527 	NUM_MATERIALS
528 } material_t;
529 
530 //rww - bot stuff that needs to be shared
531 #define MAX_WPARRAY_SIZE 4096
532 #define MAX_NEIGHBOR_SIZE 32
533 
534 #define MAX_NEIGHBOR_LINK_DISTANCE 128
535 #define MAX_NEIGHBOR_FORCEJUMP_LINK_DISTANCE 400
536 
537 #define DEFAULT_GRID_SPACING 400
538 
539 typedef struct wpneighbor_s
540 {
541 	int num;
542 	int forceJumpTo;
543 } wpneighbor_t;
544 
545 typedef struct wpobject_s
546 {
547 	vec3_t origin;
548 	int inuse;
549 	int index;
550 	float weight;
551 	float disttonext;
552 	int flags;
553 	int associated_entity;
554 
555 	int forceJumpTo;
556 
557 	int neighbornum;
558 	wpneighbor_t neighbors[MAX_NEIGHBOR_SIZE];
559 } wpobject_t;
560 
561 // all drawing is done to a 640*480 virtual screen size
562 // and will be automatically scaled to the real resolution
563 #define	SCREEN_WIDTH		640
564 #define	SCREEN_HEIGHT		480
565 
566 #define TINYCHAR_WIDTH		(SMALLCHAR_WIDTH)
567 #define TINYCHAR_HEIGHT		(SMALLCHAR_HEIGHT/2)
568 
569 #define SMALLCHAR_WIDTH		8
570 #define SMALLCHAR_HEIGHT	16
571 
572 #define BIGCHAR_WIDTH		16
573 #define BIGCHAR_HEIGHT		16
574 
575 #define	GIANTCHAR_WIDTH		32
576 #define	GIANTCHAR_HEIGHT	48
577 
578 //=============================================
579 
580 char	*COM_SkipPath( char *pathname );
581 const char	*COM_GetExtension( const char *name );
582 void	COM_StripExtension( const char *in, char *out, int destsize );
583 qboolean COM_CompareExtension(const char *in, const char *ext);
584 void	COM_DefaultExtension( char *path, int maxSize, const char *extension );
585 
586 void	COM_BeginParseSession( const char *name );
587 int		COM_GetCurrentParseLine( void );
588 const char	*SkipWhitespace( const char *data, qboolean *hasNewLines );
589 char	*COM_Parse( const char **data_p );
590 char	*COM_ParseExt( const char **data_p, qboolean allowLineBreak );
591 int		COM_Compress( char *data_p );
592 void	COM_ParseError( char *format, ... );
593 void	COM_ParseWarning( char *format, ... );
594 qboolean COM_ParseString( const char **data, const char **s );
595 qboolean COM_ParseInt( const char **data, int *i );
596 qboolean COM_ParseFloat( const char **data, float *f );
597 qboolean COM_ParseVec4( const char **buffer, vec4_t *c);
598 //int		COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
599 
600 #define MAX_TOKENLENGTH		1024
601 
602 #ifndef TT_STRING
603 //token types
604 #define TT_STRING					1			// string
605 #define TT_LITERAL					2			// literal
606 #define TT_NUMBER					3			// number
607 #define TT_NAME						4			// name
608 #define TT_PUNCTUATION				5			// punctuation
609 #endif
610 
611 typedef struct pc_token_s
612 {
613 	int type;
614 	int subtype;
615 	int intvalue;
616 	float floatvalue;
617 	char string[MAX_TOKENLENGTH];
618 } pc_token_t;
619 
620 // data is an in/out parm, returns a parsed out token
621 
622 void	COM_MatchToken( const char**buf_p, char *match );
623 
624 qboolean SkipBracedSection (const char **program, int depth);
625 void SkipRestOfLine ( const char **data );
626 
627 void Parse1DMatrix (const char **buf_p, int x, float *m);
628 void Parse2DMatrix (const char **buf_p, int y, int x, float *m);
629 void Parse3DMatrix (const char **buf_p, int z, int y, int x, float *m);
630 int Com_HexStrToInt( const char *str );
631 
632 int	QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
633 
634 char *Com_SkipTokens( char *s, int numTokens, char *sep );
635 char *Com_SkipCharset( char *s, char *sep );
636 
637 void Com_RandomBytes( byte *string, int len );
638 
639 // mode parm for FS_FOpenFile
640 typedef enum {
641 	FS_READ,
642 	FS_WRITE,
643 	FS_APPEND,
644 	FS_APPEND_SYNC
645 } fsMode_t;
646 
647 typedef enum {
648 	FS_SEEK_CUR,
649 	FS_SEEK_END,
650 	FS_SEEK_SET
651 } fsOrigin_t;
652 
653 //=============================================
654 
655 // 64-bit integers for global rankings interface
656 // implemented as a struct for qvm compatibility
657 typedef struct qint64_s {
658 	byte	b0;
659 	byte	b1;
660 	byte	b2;
661 	byte	b3;
662 	byte	b4;
663 	byte	b5;
664 	byte	b6;
665 	byte	b7;
666 } qint64;
667 
668 int FloatAsInt( float f );
669 
670 char	* QDECL va(const char *format, ...);
671 
672 #define TRUNCATE_LENGTH	64
673 void Com_TruncateLongString( char *buffer, const char *s );
674 
675 //=============================================
676 
677 //
678 // key / value info strings
679 //
680 char *Info_ValueForKey( const char *s, const char *key );
681 void Info_RemoveKey( char *s, const char *key );
682 void Info_RemoveKey_Big( char *s, const char *key );
683 void Info_SetValueForKey( char *s, const char *key, const char *value );
684 void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
685 qboolean Info_Validate( const char *s );
686 qboolean Info_NextPair( const char **s, char *key, char *value );
687 
688 // this is only here so the functions in q_shared.c and bg_*.c can link
689 #if defined( _GAME ) || defined( _CGAME ) || defined( UI_BUILD )
690 	extern NORETURN_PTR void (*Com_Error)( int level, const char *error, ... );
691 	extern void (*Com_Printf)( const char *msg, ... );
692 #else
693 	void NORETURN QDECL Com_Error( int level, const char *error, ... );
694 	void QDECL Com_Printf( const char *msg, ... );
695 #endif
696 
697 
698 /*
699 ==========================================================
700 
701 CVARS (console variables)
702 
703 Many variables can be used for cheating purposes, so when cheats is zero,
704 	force all unspecified variables to their cefault values.
705 
706 ==========================================================
707 */
708 
709 #define	CVAR_NONE			(0x00000000u)
710 #define	CVAR_ARCHIVE		(0x00000001u)	// set to cause it to be saved to configuration file. used for system variables,
711 											//	not for player specific configurations
712 #define	CVAR_USERINFO		(0x00000002u)	// sent to server on connect or change
713 #define	CVAR_SERVERINFO		(0x00000004u)	// sent in response to front end requests
714 #define	CVAR_SYSTEMINFO		(0x00000008u)	// these cvars will be duplicated on all clients
715 #define	CVAR_INIT			(0x00000010u)	// don't allow change from console at all, but can be set from the command line
716 #define	CVAR_LATCH			(0x00000020u)	// will only change when C code next does a Cvar_Get(), so it can't be changed
717 											//	without proper initialization. modified will be set, even though the value
718 											//	hasn't changed yet
719 #define	CVAR_ROM			(0x00000040u)	// display only, cannot be set by user at all (can be set by code)
720 #define	CVAR_USER_CREATED	(0x00000080u)	// created by a set command
721 #define	CVAR_TEMP			(0x00000100u)	// can be set even when cheats are disabled, but is not archived
722 #define CVAR_CHEAT			(0x00000200u)	// can not be changed if cheats are disabled
723 #define CVAR_NORESTART		(0x00000400u)	// do not clear when a cvar_restart is issued
724 #define CVAR_INTERNAL		(0x00000800u)	// cvar won't be displayed, ever (for passwords and such)
725 #define	CVAR_PARENTAL		(0x00001000u)	// lets cvar system know that parental stuff needs to be updated
726 #define CVAR_SERVER_CREATED	(0x00002000u)	// cvar was created by a server the client connected to.
727 #define CVAR_VM_CREATED		(0x00004000u)	// cvar was created exclusively in one of the VMs.
728 #define CVAR_PROTECTED		(0x00008000u)	// prevent modifying this var from VMs or the server
729 #define CVAR_NODEFAULT		(0x00010000u)	// do not write to config if matching with default value
730 
731 #define CVAR_ARCHIVE_ND		(CVAR_ARCHIVE | CVAR_NODEFAULT)
732 // These flags are only returned by the Cvar_Flags() function
733 #define CVAR_MODIFIED		(0x40000000u)	// Cvar was modified
734 #define CVAR_NONEXISTENT	(0x80000000u)	// Cvar doesn't exist.
735 
736 // nothing outside the Cvar_*() functions should modify these fields!
737 typedef struct cvar_s {
738 	char			*name;
739 	char			*description;
740 	char			*string;
741 	char			*resetString;		// cvar_restart will reset to this value
742 	char			*latchedString;		// for CVAR_LATCH vars
743 	uint32_t		flags;
744 	qboolean		modified;			// set each time the cvar is changed
745 	int				modificationCount;	// incremented each time the cvar is changed
746 	float			value;				// atof( string )
747 	int				integer;			// atoi( string )
748 	qboolean		validate;
749 	qboolean		integral;
750 	float			min, max;
751 
752 	struct cvar_s	*next, *prev;
753 	struct cvar_s	*hashNext, *hashPrev;
754 	int				hashIndex;
755 } cvar_t;
756 
757 #define	MAX_CVAR_VALUE_STRING	256
758 
759 typedef int	cvarHandle_t;
760 
761 // the modules that run in the virtual machine can't access the cvar_t directly,
762 // so they must ask for structured updates
763 typedef struct vmCvar_s {
764 	cvarHandle_t	handle;
765 	int			modificationCount;
766 	float		value;
767 	int			integer;
768 	char		string[MAX_CVAR_VALUE_STRING];
769 } vmCvar_t;
770 
771 /*
772 ==============================================================
773 
774 COLLISION DETECTION
775 
776 ==============================================================
777 */
778 
779 #include "game/surfaceflags.h"			// shared with the q3map utility
780 
781 /*
782 Ghoul2 Insert Start
783 */
784 typedef struct CollisionRecord_s {
785 	float		mDistance;
786 	int			mEntityNum;
787 	int			mModelIndex;
788 	int			mPolyIndex;
789 	int			mSurfaceIndex;
790 	vec3_t		mCollisionPosition;
791 	vec3_t		mCollisionNormal;
792 	int			mFlags;
793 	int			mMaterial;
794 	int			mLocation;
795 	float		mBarycentricI; // two barycentic coodinates for the hit point
796 	float		mBarycentricJ; // K = 1-I-J
797 } CollisionRecord_t;
798 
799 #define MAX_G2_COLLISIONS 16
800 
801 typedef CollisionRecord_t G2Trace_t[MAX_G2_COLLISIONS];	// map that describes all of the parts of ghoul2 models that got hit
802 
803 /*
804 Ghoul2 Insert End
805 */
806 // a trace is returned when a box is swept through the world
807 typedef struct trace_s {
808 	byte		allsolid;	// if true, plane is not valid
809 	byte		startsolid;	// if true, the initial point was in a solid area
810 	short		entityNum;	// entity the contacted sirface is a part of
811 
812 	float		fraction;	// time completed, 1.0 = didn't hit anything
813 	vec3_t		endpos;		// final position
814 	cplane_t	plane;		// surface normal at impact, transformed to world space
815 	int			surfaceFlags;	// surface hit
816 	int			contents;	// contents on other side of surface hit
817 /*
818 Ghoul2 Insert Start
819 */
820 	//rww - removed this for now, it's just wasting space in the trace structure.
821 //	CollisionRecord_t G2CollisionMap[MAX_G2_COLLISIONS];	// map that describes all of the parts of ghoul2 models that got hit
822 /*
823 Ghoul2 Insert End
824 */
825 } trace_t;
826 
827 // trace->entityNum can also be 0 to (MAX_GENTITIES-1)
828 // or ENTITYNUM_NONE, ENTITYNUM_WORLD
829 
830 
831 // markfragments are returned by CM_MarkFragments()
832 typedef struct markFragment_s {
833 	int		firstPoint;
834 	int		numPoints;
835 } markFragment_t;
836 
837 
838 
839 typedef struct orientation_s {
840 	vec3_t		origin;
841 	matrix3_t	axis;
842 } orientation_t;
843 
844 //=====================================================================
845 
846 
847 // in order from highest priority to lowest
848 // if none of the catchers are active, bound key strings will be executed
849 #define KEYCATCH_CONSOLE		0x0001
850 #define	KEYCATCH_UI					0x0002
851 #define	KEYCATCH_MESSAGE		0x0004
852 #define	KEYCATCH_CGAME			0x0008
853 
854 
855 // sound channels
856 // channel 0 never willingly overrides
857 // other channels will allways override a playing sound on that channel
858 typedef enum {
859 	CHAN_AUTO,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # Auto-picks an empty channel to play sound on
860 	CHAN_LOCAL,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # menu sounds, etc
861 	CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3"
862 	CHAN_VOICE, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Voice sounds cause mouth animation
863 	CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff
864 	CHAN_ITEM,  //## %s !!"W:\game\base\!!sound\*.wav;*.mp3"
865 	CHAN_BODY,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3"
866 	CHAN_AMBIENT,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # added for ambient sounds
867 	CHAN_LOCAL_SOUND,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #chat messages, etc
868 	CHAN_ANNOUNCER,		//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #announcer voices, etc
869 	CHAN_LESS_ATTEN,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #attenuates similar to chan_voice, but uses empty channel auto-pick behaviour
870 	CHAN_MENU1,		//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #menu stuff, etc
871 	CHAN_VOICE_GLOBAL,  //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation and is broadcast, like announcer
872 	CHAN_MUSIC,	//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #music played as a looping sound - added by BTO (VV)
873 } soundChannel_t;
874 
875 
876 /*
877 ========================================================================
878 
879   ELEMENTS COMMUNICATED ACROSS THE NET
880 
881 ========================================================================
882 */
883 
884 #define	ANGLE2SHORT(x)	((int)((x)*65536/360) & 65535)
885 #define	SHORT2ANGLE(x)	((x)*(360.0/65536))
886 
887 #define	SNAPFLAG_RATE_DELAYED	1
888 #define	SNAPFLAG_NOT_ACTIVE		2	// snapshot used during connection and for zombies
889 #define SNAPFLAG_SERVERCOUNT	4	// toggled every map_restart so transitions can be detected
890 
891 //
892 // per-level limits
893 //
894 #define	MAX_CLIENTS			32		// absolute limit
895 #define MAX_RADAR_ENTITIES	MAX_GENTITIES
896 #define MAX_TERRAINS		1//32 //rwwRMG: inserted
897 #define MAX_LOCATIONS		64
898 
899 #define	GENTITYNUM_BITS	10		// don't need to send any more
900 #define	MAX_GENTITIES	(1<<GENTITYNUM_BITS)
901 
902 //I am reverting. I guess. For now.
903 /*
904 #define	GENTITYNUM_BITS		11
905 							//rww - I am raising this 1 bit. SP actually has room for 1024 ents - none - world - 1 client.
906 							//Which means 1021 useable entities. However we have 32 clients.. so if we keep our limit
907 							//at 1024 we are not going to be able to load any SP levels at the edge of the ent limit.
908 #define		MAX_GENTITIES	(1024+(MAX_CLIENTS-1))
909 							//rww - we do have enough room to send over 2048 ents now. However, I cannot live with the guilt of
910 							//actually increasing the entity limit to 2048 (as it would slow down countless things, and
911 							//there are tons of ent list traversals all over the place). So I am merely going to give enough
912 							//to compensate for our larger maxclients.
913 */
914 
915 // entitynums are communicated with GENTITY_BITS, so any reserved
916 // values thatare going to be communcated over the net need to
917 // also be in this range
918 #define	ENTITYNUM_NONE		(MAX_GENTITIES-1)
919 #define	ENTITYNUM_WORLD		(MAX_GENTITIES-2)
920 #define	ENTITYNUM_MAX_NORMAL	(MAX_GENTITIES-2)
921 
922 
923 // these are also in be_aas_def.h - argh (rjr)
924 #define	MAX_MODELS			512		// these are sent over the net as -12 bits
925 #define	MAX_SOUNDS			256		// so they cannot be blindly increased
926 #define MAX_ICONS			64		// max registered icons you can have per map
927 #define MAX_FX				64		// max effects strings, I'm hoping that 64 will be plenty
928 
929 #define MAX_SUB_BSP			32 //rwwRMG - added
930 
931 /*
932 Ghoul2 Insert Start
933 */
934 #define	MAX_G2BONES		64		//rww - changed from MAX_CHARSKINS to MAX_G2BONES. value still equal.
935 /*
936 Ghoul2 Insert End
937 */
938 
939 #define MAX_AMBIENT_SETS		256 //rww - ambient soundsets must be sent over in config strings.
940 
941 #define	MAX_CONFIGSTRINGS	1700 //this is getting pretty high. Try not to raise it anymore than it already is.
942 
943 // these are the only configstrings that the system reserves, all the
944 // other ones are strictly for servergame to clientgame communication
945 #define	CS_SERVERINFO		0		// an info string with all the serverinfo cvars
946 #define	CS_SYSTEMINFO		1		// an info string for server system to client system configuration (timescale, etc)
947 
948 #define	RESERVED_CONFIGSTRINGS	2	// game can't modify below this, only the system can
949 
950 #define	MAX_GAMESTATE_CHARS	16000
951 typedef struct gameState_s {
952 	int			stringOffsets[MAX_CONFIGSTRINGS];
953 	char		stringData[MAX_GAMESTATE_CHARS];
954 	int			dataCount;
955 } gameState_t;
956 
957 //=========================================================
958 
959 // all the different tracking "channels"
960 typedef enum {
961 	TRACK_CHANNEL_NONE = 50,
962 	TRACK_CHANNEL_1,
963 	TRACK_CHANNEL_2, // force speed
964 	TRACK_CHANNEL_3, // force rage
965 	TRACK_CHANNEL_4,
966 	TRACK_CHANNEL_5, // force sight
967 	NUM_TRACK_CHANNELS
968 } trackchan_t;
969 
970 #define TRACK_CHANNEL_MAX (NUM_TRACK_CHANNELS-50)
971 
972 typedef struct forcedata_s {
973 	int			forcePowerDebounce[NUM_FORCE_POWERS];	//for effects that must have an interval
974 	int			forcePowersKnown;
975 	int			forcePowersActive;
976 	int			forcePowerSelected;
977 	int			forceButtonNeedRelease;
978 	int			forcePowerDuration[NUM_FORCE_POWERS];
979 	int			forcePower;
980 	int			forcePowerMax;
981 	int			forcePowerRegenDebounceTime;
982 	int			forcePowerLevel[NUM_FORCE_POWERS];		//so we know the max forceJump power you have
983 	int			forcePowerBaseLevel[NUM_FORCE_POWERS];
984 	int			forceUsingAdded;
985 	float		forceJumpZStart;					//So when you land, you don't get hurt as much
986 	float		forceJumpCharge;					//you're current forceJump charge-up level, increases the longer you hold the force jump button down
987 	int			forceJumpSound;
988 	int			forceJumpAddTime;
989 	int			forceGripEntityNum;					//what entity I'm gripping
990 	int			forceGripDamageDebounceTime;		//debounce for grip damage
991 	float		forceGripBeingGripped;				//if > level.time then client is in someone's grip
992 	int			forceGripCripple;					//if != 0 then make it so this client can't move quickly (he's being gripped)
993 	int			forceGripUseTime;					//can't use if > level.time
994 	float		forceGripSoundTime;
995 	float		forceGripStarted;					//level.time when the grip was activated
996 	int			forceHealTime;
997 	int			forceHealAmount;
998 
999 	//This hurts me somewhat to do, but there's no other real way to allow completely "dynamic" mindtricking.
1000 	int			forceMindtrickTargetIndex; //0-15
1001 	int			forceMindtrickTargetIndex2; //16-32
1002 	int			forceMindtrickTargetIndex3; //33-48
1003 	int			forceMindtrickTargetIndex4; //49-64
1004 
1005 	int			forceRageRecoveryTime;
1006 	int			forceDrainEntNum;
1007 	float		forceDrainTime;
1008 
1009 	int			forceDoInit;
1010 
1011 	int			forceSide;
1012 	int			forceRank;
1013 
1014 	int			forceDeactivateAll;
1015 
1016 	int			killSoundEntIndex[TRACK_CHANNEL_MAX]; //this goes here so it doesn't get wiped over respawn
1017 
1018 	qboolean	sentryDeployed;
1019 
1020 	int			saberAnimLevelBase;//sigh...
1021 	int			saberAnimLevel;
1022 	int			saberDrawAnimLevel;
1023 
1024 	int			suicides;
1025 
1026 	int			privateDuelTime;
1027 } forcedata_t;
1028 
1029 
1030 typedef enum {
1031 	SENTRY_NOROOM = 1,
1032 	SENTRY_ALREADYPLACED,
1033 	SHIELD_NOROOM,
1034 	SEEKER_ALREADYDEPLOYED
1035 } itemUseFail_t;
1036 
1037 // bit field limits
1038 #define	MAX_STATS				16
1039 #define	MAX_PERSISTANT			16
1040 #define	MAX_POWERUPS			16
1041 #define	MAX_WEAPONS				19
1042 #define MAX_AMMO_TRANSMIT		16 // This is needed because the ammo array is 19 but only 16 sized array is networked
1043 #define MAX_AMMO				MAX_WEAPONS
1044 
1045 #define	MAX_PS_EVENTS			2
1046 
1047 #define PS_PMOVEFRAMECOUNTBITS	6
1048 
1049 #define FORCE_LIGHTSIDE			1
1050 #define FORCE_DARKSIDE			2
1051 
1052 #define MAX_FORCE_RANK			7
1053 
1054 #define FALL_FADE_TIME			3000
1055 
1056 //#define _ONEBIT_COMBO
1057 //Crazy optimization attempt to take all those 1 bit values and shove them into a single
1058 //send. May help us not have to send so many 1/0 bits to acknowledge modified values. -rww
1059 
1060 #define _OPTIMIZED_VEHICLE_NETWORKING
1061 //Instead of sending 2 full playerStates for the pilot and the vehicle, send a smaller,
1062 //specialized pilot playerState and vehicle playerState.  Also removes some vehicle
1063 //fields from the normal playerState -mcg
1064 
1065 // playerState_t is the information needed by both the client and server
1066 // to predict player motion and actions
1067 // nothing outside of pmove should modify these, or some degree of prediction error
1068 // will occur
1069 
1070 // you can't add anything to this without modifying the code in msg.c
1071 
1072 // playerState_t is a full superset of entityState_t as it is used by players,
1073 // so if a playerState_t is transmitted, the entityState_t can be fully derived
1074 // from it.
1075 typedef struct playerState_s {
1076 	int			commandTime;	// cmd->serverTime of last executed command
1077 	int			pm_type;
1078 	int			bobCycle;		// for view bobbing and footstep generation
1079 	int			pm_flags;		// ducked, jump_held, etc
1080 	int			pm_time;
1081 
1082 	vec3_t		origin;
1083 	vec3_t		velocity;
1084 
1085 	vec3_t		moveDir; //NOT sent over the net - nor should it be.
1086 
1087 	int			weaponTime;
1088 	int			weaponChargeTime;
1089 	int			weaponChargeSubtractTime;
1090 	int			gravity;
1091 	float		speed;
1092 	int			basespeed; //used in prediction to know base server g_speed value when modifying speed between updates
1093 	int			delta_angles[3];	// add to command angles to get view direction
1094 									// changed by spawns, rotating objects, and teleporters
1095 
1096 	int			slopeRecalcTime; //this is NOT sent across the net and is maintained seperately on game and cgame in pmove code.
1097 
1098 	int			useTime;
1099 
1100 	int			groundEntityNum;// ENTITYNUM_NONE = in air
1101 
1102 	int			legsTimer;		// don't change low priority animations until this runs out
1103 	int			legsAnim;
1104 
1105 	int			torsoTimer;		// don't change low priority animations until this runs out
1106 	int			torsoAnim;
1107 
1108 	qboolean	legsFlip; //set to opposite when the same anim needs restarting, sent over in only 1 bit. Cleaner and makes porting easier than having that god forsaken ANIM_TOGGLEBIT.
1109 	qboolean	torsoFlip;
1110 
1111 	int			movementDir;	// a number 0 to 7 that represents the reletive angle
1112 								// of movement to the view angle (axial and diagonals)
1113 								// when at rest, the value will remain unchanged
1114 								// used to twist the legs during strafing
1115 
1116 	int			eFlags;			// copied to entityState_t->eFlags
1117 	int			eFlags2;		// copied to entityState_t->eFlags2, EF2_??? used much less frequently
1118 
1119 	int			eventSequence;	// pmove generated events
1120 	int			events[MAX_PS_EVENTS];
1121 	int			eventParms[MAX_PS_EVENTS];
1122 
1123 	int			externalEvent;	// events set on player from another source
1124 	int			externalEventParm;
1125 	int			externalEventTime;
1126 
1127 	int			clientNum;		// ranges from 0 to MAX_CLIENTS-1
1128 	int			weapon;			// copied to entityState_t->weapon
1129 	int			weaponstate;
1130 
1131 	vec3_t		viewangles;		// for fixed views
1132 	int			viewheight;
1133 
1134 	// damage feedback
1135 	int			damageEvent;	// when it changes, latch the other parms
1136 	int			damageYaw;
1137 	int			damagePitch;
1138 	int			damageCount;
1139 	int			damageType;
1140 
1141 	int			painTime;		// used for both game and client side to process the pain twitch - NOT sent across the network
1142 	int			painDirection;	// NOT sent across the network
1143 	float		yawAngle;		// NOT sent across the network
1144 	qboolean	yawing;			// NOT sent across the network
1145 	float		pitchAngle;		// NOT sent across the network
1146 	qboolean	pitching;		// NOT sent across the network
1147 
1148 	int			stats[MAX_STATS];
1149 	int			persistant[MAX_PERSISTANT];	// stats that aren't cleared on death
1150 	int			powerups[MAX_POWERUPS];	// level.time that the powerup runs out
1151 	int			ammo[MAX_AMMO];
1152 
1153 	int			generic1;
1154 	int			loopSound;
1155 	int			jumppad_ent;	// jumppad entity hit this frame
1156 
1157 	// not communicated over the net at all
1158 	int			ping;			// server to game info for scoreboard
1159 	int			pmove_framecount;	// FIXME: don't transmit over the network
1160 	int			jumppad_frame;
1161 	int			entityEventSequence;
1162 
1163 	int			lastOnGround;	//last time you were on the ground
1164 
1165 	qboolean	saberInFlight;
1166 
1167 	int			saberMove;
1168 	int			saberBlocking;
1169 	int			saberBlocked;
1170 
1171 	int			saberLockTime;
1172 	int			saberLockEnemy;
1173 	int			saberLockFrame; //since we don't actually have the ability to get the current anim frame
1174 	int			saberLockHits; //every x number of buttons hits, allow one push forward in a saber lock (server only)
1175 	int			saberLockHitCheckTime; //so we don't allow more than 1 push per server frame
1176 	int			saberLockHitIncrementTime; //so we don't add a hit per attack button press more than once per server frame
1177 	qboolean	saberLockAdvance; //do an advance (sent across net as 1 bit)
1178 
1179 	int			saberEntityNum;
1180 	float		saberEntityDist;
1181 	int			saberEntityState;
1182 	int			saberThrowDelay;
1183 	qboolean	saberCanThrow;
1184 	int			saberDidThrowTime;
1185 	int			saberDamageDebounceTime;
1186 	int			saberHitWallSoundDebounceTime;
1187 	int			saberEventFlags;
1188 
1189 	int			rocketLockIndex;
1190 	float		rocketLastValidTime;
1191 	float		rocketLockTime;
1192 	float		rocketTargetTime;
1193 
1194 	int			emplacedIndex;
1195 	float		emplacedTime;
1196 
1197 	qboolean	isJediMaster;
1198 	qboolean	forceRestricted;
1199 	qboolean	trueJedi;
1200 	qboolean	trueNonJedi;
1201 	int			saberIndex;
1202 
1203 	int			genericEnemyIndex;
1204 	float		droneFireTime;
1205 	float		droneExistTime;
1206 
1207 	int			activeForcePass;
1208 
1209 	qboolean	hasDetPackPlanted; //better than taking up an eFlag isn't it?
1210 
1211 	float		holocronsCarried[NUM_FORCE_POWERS];
1212 	int			holocronCantTouch;
1213 	float		holocronCantTouchTime; //for keeping track of the last holocron that just popped out of me (if any)
1214 	int			holocronBits;
1215 
1216 	int			electrifyTime;
1217 
1218 	int			saberAttackSequence;
1219 	int			saberIdleWound;
1220 	int			saberAttackWound;
1221 	int			saberBlockTime;
1222 
1223 	int			otherKiller;
1224 	int			otherKillerTime;
1225 	int			otherKillerDebounceTime;
1226 
1227 	forcedata_t	fd;
1228 	qboolean	forceJumpFlip;
1229 	int			forceHandExtend;
1230 	int			forceHandExtendTime;
1231 
1232 	int			forceRageDrainTime;
1233 
1234 	int			forceDodgeAnim;
1235 	qboolean	quickerGetup;
1236 
1237 	int			groundTime;		// time when first left ground
1238 
1239 	int			footstepTime;
1240 
1241 	int			otherSoundTime;
1242 	float		otherSoundLen;
1243 
1244 	int			forceGripMoveInterval;
1245 	int			forceGripChangeMovetype;
1246 
1247 	int			forceKickFlip;
1248 
1249 	int			duelIndex;
1250 	int			duelTime;
1251 	qboolean	duelInProgress;
1252 
1253 	int			saberAttackChainCount;
1254 
1255 	int			saberHolstered;
1256 
1257 	int			forceAllowDeactivateTime;
1258 
1259 	// zoom key
1260 	int			zoomMode;		// 0 - not zoomed, 1 - disruptor weapon
1261 	int			zoomTime;
1262 	qboolean	zoomLocked;
1263 	float		zoomFov;
1264 	int			zoomLockTime;
1265 
1266 	int			fallingToDeath;
1267 
1268 	int			useDelay;
1269 
1270 	qboolean	inAirAnim;
1271 
1272 	vec3_t		lastHitLoc;
1273 
1274 	int			heldByClient; //can only be a client index - this client should be holding onto my arm using IK stuff.
1275 
1276 	int			ragAttach; //attach to ent while ragging
1277 
1278 	int			iModelScale;
1279 
1280 	int			brokenLimbs;
1281 
1282 	//for looking at an entity's origin (NPCs and players)
1283 	qboolean	hasLookTarget;
1284 	int			lookTarget;
1285 
1286 	int			customRGBA[4];
1287 
1288 	int			standheight;
1289 	int			crouchheight;
1290 
1291 	//If non-0, this is the index of the vehicle a player/NPC is riding.
1292 	int			m_iVehicleNum;
1293 
1294 	//lovely hack for keeping vehicle orientation in sync with prediction
1295 	vec3_t		vehOrientation;
1296 	qboolean	vehBoarding;
1297 	int			vehSurfaces;
1298 
1299 	//vehicle turnaround stuff (need this in ps so it doesn't jerk too much in prediction)
1300 	int			vehTurnaroundIndex;
1301 	int			vehTurnaroundTime;
1302 
1303 	//vehicle has weapons linked
1304 	qboolean	vehWeaponsLinked;
1305 
1306 	//when hyperspacing, you just go forward really fast for HYPERSPACE_TIME
1307 	int			hyperSpaceTime;
1308 	vec3_t		hyperSpaceAngles;
1309 
1310 	//hacking when > time
1311 	int			hackingTime;
1312 	//actual hack amount - only for the proper percentage display when
1313 	//drawing progress bar (is there a less bandwidth-eating way to do
1314 	//this without a lot of hassle?)
1315 	int			hackingBaseTime;
1316 
1317 	//keeps track of jetpack fuel
1318 	int			jetpackFuel;
1319 
1320 	//keeps track of cloak fuel
1321 	int			cloakFuel;
1322 
1323 	//rww - spare values specifically for use by mod authors.
1324 	//See psf_overrides.txt if you want to increase the send
1325 	//amount of any of these above 1 bit.
1326 	int			userInt1;
1327 	int			userInt2;
1328 	int			userInt3;
1329 	float		userFloat1;
1330 	float		userFloat2;
1331 	float		userFloat3;
1332 	vec3_t		userVec1;
1333 	vec3_t		userVec2;
1334 
1335 #ifdef _ONEBIT_COMBO
1336 	int			deltaOneBits;
1337 	int			deltaNumBits;
1338 #endif
1339 } playerState_t;
1340 
1341 typedef struct siegePers_s
1342 {
1343 	qboolean	beatingTime;
1344 	int			lastTeam;
1345 	int			lastTime;
1346 } siegePers_t;
1347 
1348 //====================================================================
1349 
1350 
1351 //
1352 // usercmd_t->button bits, many of which are generated by the client system,
1353 // so they aren't game/cgame only definitions
1354 //
1355 #define	BUTTON_ATTACK			1
1356 #define	BUTTON_TALK				2			// displays talk balloon and disables actions
1357 #define	BUTTON_USE_HOLDABLE		4
1358 #define	BUTTON_GESTURE			8
1359 #define	BUTTON_WALKING			16			// walking can't just be infered from MOVE_RUN
1360 										// because a key pressed late in the frame will
1361 										// only generate a small move value for that frame
1362 										// walking will use different animations and
1363 										// won't generate footsteps
1364 #define	BUTTON_USE				32			// the ol' use key returns!
1365 #define BUTTON_FORCEGRIP		64			//
1366 #define BUTTON_ALT_ATTACK		128
1367 
1368 #define	BUTTON_ANY				256			// any key whatsoever
1369 
1370 #define BUTTON_FORCEPOWER		512			// use the "active" force power
1371 
1372 #define BUTTON_FORCE_LIGHTNING	1024
1373 
1374 #define BUTTON_FORCE_DRAIN		2048
1375 
1376 // Here's an interesting bit.  The bots in TA used buttons to do additional gestures.
1377 // I ripped them out because I didn't want too many buttons given the fact that I was already adding some for JK2.
1378 // We can always add some back in if we want though.
1379 /*
1380 #define BUTTON_AFFIRMATIVE	32
1381 #define	BUTTON_NEGATIVE		64
1382 
1383 #define BUTTON_GETFLAG		128
1384 #define BUTTON_GUARDBASE	256
1385 #define BUTTON_PATROL		512
1386 #define BUTTON_FOLLOWME		1024
1387 */
1388 
1389 #define	MOVE_RUN			120			// if forwardmove or rightmove are >= MOVE_RUN,
1390 										// then BUTTON_WALKING should be set
1391 
1392 typedef enum
1393 {
1394 	GENCMD_SABERSWITCH = 1,
1395 	GENCMD_ENGAGE_DUEL,
1396 	GENCMD_FORCE_HEAL,
1397 	GENCMD_FORCE_SPEED,
1398 	GENCMD_FORCE_THROW,
1399 	GENCMD_FORCE_PULL,
1400 	GENCMD_FORCE_DISTRACT,
1401 	GENCMD_FORCE_RAGE,
1402 	GENCMD_FORCE_PROTECT,
1403 	GENCMD_FORCE_ABSORB,
1404 	GENCMD_FORCE_HEALOTHER,
1405 	GENCMD_FORCE_FORCEPOWEROTHER,
1406 	GENCMD_FORCE_SEEING,
1407 	GENCMD_USE_SEEKER,
1408 	GENCMD_USE_FIELD,
1409 	GENCMD_USE_BACTA,
1410 	GENCMD_USE_ELECTROBINOCULARS,
1411 	GENCMD_ZOOM,
1412 	GENCMD_USE_SENTRY,
1413 	GENCMD_USE_JETPACK,
1414 	GENCMD_USE_BACTABIG,
1415 	GENCMD_USE_HEALTHDISP,
1416 	GENCMD_USE_AMMODISP,
1417 	GENCMD_USE_EWEB,
1418 	GENCMD_USE_CLOAK,
1419 	GENCMD_SABERATTACKCYCLE,
1420 	GENCMD_TAUNT,
1421 	GENCMD_BOW,
1422 	GENCMD_MEDITATE,
1423 	GENCMD_FLOURISH,
1424 	GENCMD_GLOAT
1425 } genCmds_t;
1426 
1427 // usercmd_t is sent to the server each client frame
1428 typedef struct usercmd_s {
1429 	int				serverTime;
1430 	int				angles[3];
1431 	int 			buttons;
1432 	byte			weapon;           // weapon
1433 	byte			forcesel;
1434 	byte			invensel;
1435 	byte			generic_cmd;
1436 	signed char	forwardmove, rightmove, upmove;
1437 } usercmd_t;
1438 
1439 //===================================================================
1440 
1441 //rww - unsightly hack to allow us to make an FX call that takes a horrible amount of args
1442 typedef struct addpolyArgStruct_s {
1443 	vec3_t				p[4];
1444 	vec2_t				ev[4];
1445 	int					numVerts;
1446 	vec3_t				vel;
1447 	vec3_t				accel;
1448 	float				alpha1;
1449 	float				alpha2;
1450 	float				alphaParm;
1451 	vec3_t				rgb1;
1452 	vec3_t				rgb2;
1453 	float				rgbParm;
1454 	vec3_t				rotationDelta;
1455 	float				bounce;
1456 	int					motionDelay;
1457 	int					killTime;
1458 	qhandle_t			shader;
1459 	int					flags;
1460 } addpolyArgStruct_t;
1461 
1462 typedef struct addbezierArgStruct_s {
1463 	vec3_t start;
1464 	vec3_t end;
1465 	vec3_t control1;
1466 	vec3_t control1Vel;
1467 	vec3_t control2;
1468 	vec3_t control2Vel;
1469 	float size1;
1470 	float size2;
1471 	float sizeParm;
1472 	float alpha1;
1473 	float alpha2;
1474 	float alphaParm;
1475 	vec3_t sRGB;
1476 	vec3_t eRGB;
1477 	float rgbParm;
1478 	int killTime;
1479 	qhandle_t shader;
1480 	int flags;
1481 } addbezierArgStruct_t;
1482 
1483 typedef struct addspriteArgStruct_s
1484 {
1485 	vec3_t origin;
1486 	vec3_t vel;
1487 	vec3_t accel;
1488 	float scale;
1489 	float dscale;
1490 	float sAlpha;
1491 	float eAlpha;
1492 	float rotation;
1493 	float bounce;
1494 	int life;
1495 	qhandle_t shader;
1496 	int flags;
1497 } addspriteArgStruct_t;
1498 
1499 typedef struct effectTrailVertStruct_s {
1500 	vec3_t	origin;
1501 
1502 	// very specifc case, we can modulate the color and the alpha
1503 	vec3_t	rgb;
1504 	vec3_t	destrgb;
1505 	vec3_t	curRGB;
1506 
1507 	float	alpha;
1508 	float	destAlpha;
1509 	float	curAlpha;
1510 
1511 	// this is a very specific case thing...allow interpolating the st coords so we can map the texture
1512 	//	properly as this segement progresses through it's life
1513 	float	ST[2];
1514 	float	destST[2];
1515 	float	curST[2];
1516 } effectTrailVertStruct_t;
1517 
1518 typedef struct effectTrailArgStruct_s {
1519 	effectTrailVertStruct_t		mVerts[4];
1520 	qhandle_t					mShader;
1521 	int							mSetFlags;
1522 	int							mKillTime;
1523 } effectTrailArgStruct_t;
1524 
1525 typedef struct addElectricityArgStruct_s {
1526 	vec3_t start;
1527 	vec3_t end;
1528 	float size1;
1529 	float size2;
1530 	float sizeParm;
1531 	float alpha1;
1532 	float alpha2;
1533 	float alphaParm;
1534 	vec3_t sRGB;
1535 	vec3_t eRGB;
1536 	float rgbParm;
1537 	float chaos;
1538 	int killTime;
1539 	qhandle_t shader;
1540 	int flags;
1541 } addElectricityArgStruct_t;
1542 
1543 // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
1544 #define	SOLID_BMODEL	0xffffff
1545 
1546 typedef enum {
1547 	TR_STATIONARY,
1548 	TR_INTERPOLATE,				// non-parametric, but interpolate between snapshots
1549 	TR_LINEAR,
1550 	TR_LINEAR_STOP,
1551 	TR_NONLINEAR_STOP,
1552 	TR_SINE,					// value = base + sin( time / duration ) * delta
1553 	TR_GRAVITY
1554 } trType_t;
1555 
1556 typedef struct trajectory_s {
1557 	trType_t	trType;
1558 	int		trTime;
1559 	int		trDuration;			// if non 0, trTime + trDuration = stop time
1560 	vec3_t	trBase;
1561 	vec3_t	trDelta;			// velocity, etc
1562 } trajectory_t;
1563 
1564 // entityState_t is the information conveyed from the server
1565 // in an update message about entities that the client will
1566 // need to render in some way
1567 // Different eTypes may use the information in different ways
1568 // The messages are delta compressed, so it doesn't really matter if
1569 // the structure size is fairly large
1570 typedef struct entityState_s {
1571 	int		number;			// entity index
1572 	int		eType;			// entityType_t
1573 	int		eFlags;
1574 	int		eFlags2;		// EF2_??? used much less frequently
1575 
1576 	trajectory_t	pos;	// for calculating position
1577 	trajectory_t	apos;	// for calculating angles
1578 
1579 	int		time;
1580 	int		time2;
1581 
1582 	vec3_t	origin;
1583 	vec3_t	origin2;
1584 
1585 	vec3_t	angles;
1586 	vec3_t	angles2;
1587 
1588 	//rww - these were originally because we shared g2 info client and server side. Now they
1589 	//just get used as generic values everywhere.
1590 	int		bolt1;
1591 	int		bolt2;
1592 
1593 	//rww - this is necessary for determining player visibility during a jedi mindtrick
1594 	int		trickedentindex; //0-15
1595 	int		trickedentindex2; //16-32
1596 	int		trickedentindex3; //33-48
1597 	int		trickedentindex4; //49-64
1598 
1599 	float	speed;
1600 
1601 	int		fireflag;
1602 
1603 	int		genericenemyindex;
1604 
1605 	int		activeForcePass;
1606 
1607 	int		emplacedOwner;
1608 
1609 	int		otherEntityNum;	// shotgun sources, etc
1610 	int		otherEntityNum2;
1611 
1612 	int		groundEntityNum;	// ENTITYNUM_NONE = in air
1613 
1614 	int		constantLight;	// r + (g<<8) + (b<<16) + (intensity<<24)
1615 	int		loopSound;		// constantly loop this sound
1616 	qboolean	loopIsSoundset; //qtrue if the loopSound index is actually a soundset index
1617 
1618 	int		soundSetIndex;
1619 
1620 	int		modelGhoul2;
1621 	int		g2radius;
1622 	int		modelindex;
1623 	int		modelindex2;
1624 	int		clientNum;		// 0 to (MAX_CLIENTS - 1), for players and corpses
1625 	int		frame;
1626 
1627 	qboolean	saberInFlight;
1628 	int			saberEntityNum;
1629 	int			saberMove;
1630 	int			forcePowersActive;
1631 	int			saberHolstered;//sent in only only 2 bits - should be 0, 1 or 2
1632 
1633 	qboolean	isJediMaster;
1634 
1635 	qboolean	isPortalEnt; //this needs to be seperate for all entities I guess, which is why I couldn't reuse another value.
1636 
1637 	int		solid;			// for client side prediction, trap_linkentity sets this properly
1638 
1639 	int		event;			// impulse events -- muzzle flashes, footsteps, etc
1640 	int		eventParm;
1641 
1642 	// so crosshair knows what it's looking at
1643 	int			owner;
1644 	int			teamowner;
1645 	qboolean	shouldtarget;
1646 
1647 	// for players
1648 	int		powerups;		// bit flags
1649 	int		weapon;			// determines weapon and flash model, etc
1650 	int		legsAnim;
1651 	int		torsoAnim;
1652 
1653 	qboolean	legsFlip; //set to opposite when the same anim needs restarting, sent over in only 1 bit. Cleaner and makes porting easier than having that god forsaken ANIM_TOGGLEBIT.
1654 	qboolean	torsoFlip;
1655 
1656 	int		forceFrame;		//if non-zero, force the anim frame
1657 
1658 	int		generic1;
1659 
1660 	int		heldByClient; //can only be a client index - this client should be holding onto my arm using IK stuff.
1661 
1662 	int		ragAttach; //attach to ent while ragging
1663 
1664 	int		iModelScale; //rww - transfer a percentage of the normal scale in a single int instead of 3 x-y-z scale values
1665 
1666 	int		brokenLimbs;
1667 
1668 	int		boltToPlayer; //set to index of a real client+1 to bolt the ent to that client. Must be a real client, NOT an NPC.
1669 
1670 	//for looking at an entity's origin (NPCs and players)
1671 	qboolean	hasLookTarget;
1672 	int			lookTarget;
1673 
1674 	int			customRGBA[4];
1675 
1676 	//I didn't want to do this, but I.. have no choice. However, we aren't setting this for all ents or anything,
1677 	//only ones we want health knowledge about on cgame (like siege objective breakables) -rww
1678 	int			health;
1679 	int			maxhealth; //so I know how to draw the stupid health bar
1680 
1681 	//NPC-SPECIFIC FIELDS
1682 	//------------------------------------------------------------
1683 	int		npcSaber1;
1684 	int		npcSaber2;
1685 
1686 	//index values for each type of sound, gets the folder the sounds
1687 	//are in. I wish there were a better way to do this,
1688 	int		csSounds_Std;
1689 	int		csSounds_Combat;
1690 	int		csSounds_Extra;
1691 	int		csSounds_Jedi;
1692 
1693 	int		surfacesOn; //a bitflag of corresponding surfaces from a lookup table. These surfaces will be forced on.
1694 	int		surfacesOff; //same as above, but forced off instead.
1695 
1696 	//Allow up to 4 PCJ lookup values to be stored here.
1697 	//The resolve to configstrings which contain the name of the
1698 	//desired bone.
1699 	int		boneIndex1;
1700 	int		boneIndex2;
1701 	int		boneIndex3;
1702 	int		boneIndex4;
1703 
1704 	//packed with x, y, z orientations for bone angles
1705 	int		boneOrient;
1706 
1707 	//I.. feel bad for doing this, but NPCs really just need to
1708 	//be able to control this sort of thing from the server sometimes.
1709 	//At least it's at the end so this stuff is never going to get sent
1710 	//over for anything that isn't an NPC.
1711 	vec3_t	boneAngles1; //angles of boneIndex1
1712 	vec3_t	boneAngles2; //angles of boneIndex2
1713 	vec3_t	boneAngles3; //angles of boneIndex3
1714 	vec3_t	boneAngles4; //angles of boneIndex4
1715 
1716 	int		NPC_class; //we need to see what it is on the client for a few effects.
1717 
1718 	//If non-0, this is the index of the vehicle a player/NPC is riding.
1719 	int		m_iVehicleNum;
1720 
1721 	//rww - spare values specifically for use by mod authors.
1722 	//See netf_overrides.txt if you want to increase the send
1723 	//amount of any of these above 1 bit.
1724 	int			userInt1;
1725 	int			userInt2;
1726 	int			userInt3;
1727 	float		userFloat1;
1728 	float		userFloat2;
1729 	float		userFloat3;
1730 	vec3_t		userVec1;
1731 	vec3_t		userVec2;
1732 } entityState_t;
1733 
1734 typedef enum {
1735 	CA_UNINITIALIZED,
1736 	CA_DISCONNECTED, 	// not talking to a server
1737 	CA_AUTHORIZING,		// not used any more, was checking cd key
1738 	CA_CONNECTING,		// sending request packets to the server
1739 	CA_CHALLENGING,		// sending challenge packets to the server
1740 	CA_CONNECTED,		// netchan_t established, getting gamestate
1741 	CA_LOADING,			// only during cgame initialization, never during main loop
1742 	CA_PRIMED,			// got gamestate, waiting for first frame
1743 	CA_ACTIVE,			// game views should be displayed
1744 	CA_CINEMATIC		// playing a cinematic or a static pic, not connected to a server
1745 } connstate_t;
1746 
1747 
1748 #define Square(x) ((x)*(x))
1749 
1750 // real time
1751 //=============================================
1752 
1753 
1754 typedef struct qtime_s {
1755 	int tm_sec;     /* seconds after the minute - [0,59] */
1756 	int tm_min;     /* minutes after the hour - [0,59] */
1757 	int tm_hour;    /* hours since midnight - [0,23] */
1758 	int tm_mday;    /* day of the month - [1,31] */
1759 	int tm_mon;     /* months since January - [0,11] */
1760 	int tm_year;    /* years since 1900 */
1761 	int tm_wday;    /* days since Sunday - [0,6] */
1762 	int tm_yday;    /* days since January 1 - [0,365] */
1763 	int tm_isdst;   /* daylight savings time flag */
1764 } qtime_t;
1765 
1766 
1767 // server browser sources
1768 #define AS_LOCAL			0
1769 #define AS_GLOBAL			1
1770 #define AS_FAVORITES		2
1771 
1772 #define AS_MPLAYER			3 // (Obsolete)
1773 
1774 // cinematic states
1775 typedef enum {
1776 	FMV_IDLE,
1777 	FMV_PLAY,		// play
1778 	FMV_EOF,		// all other conditions, i.e. stop/EOF/abort
1779 	FMV_ID_BLT,
1780 	FMV_ID_IDLE,
1781 	FMV_LOOPED,
1782 	FMV_ID_WAIT
1783 } e_status;
1784 
1785 #define	MAX_GLOBAL_SERVERS			2048
1786 #define	MAX_OTHER_SERVERS			128
1787 #define MAX_PINGREQUESTS			32
1788 #define MAX_SERVERSTATUSREQUESTS	16
1789 
1790 #define SAY_ALL		0
1791 #define SAY_TEAM	1
1792 #define SAY_TELL	2
1793 
1794 /*
1795 Ghoul2 Insert Start
1796 */
1797 
1798 typedef struct mdxaBone_s {
1799 	float		matrix[3][4];
1800 } mdxaBone_t;
1801 
1802 // For ghoul2 axis use
1803 
1804 typedef enum Eorientations
1805 {
1806 	ORIGIN = 0,
1807 	POSITIVE_X,
1808 	POSITIVE_Z,
1809 	POSITIVE_Y,
1810 	NEGATIVE_X,
1811 	NEGATIVE_Z,
1812 	NEGATIVE_Y
1813 } orientations_t;
1814 /*
1815 Ghoul2 Insert End
1816 */
1817 
1818 // define the new memory tags for the zone, used by all modules now
1819 //
1820 #define TAGDEF(blah) TAG_ ## blah
1821 typedef enum {
1822 	#include "qcommon/tags.h"
1823 } memtag;
1824 typedef unsigned memtag_t;
1825 
1826 //rww - conveniently toggle "gore" code, for model decals and stuff.
1827 #define _G2_GORE
1828 
1829 typedef struct SSkinGoreData_s
1830 {
1831 	vec3_t			angles;
1832 	vec3_t			position;
1833 	int				currentTime;
1834 	int				entNum;
1835 	vec3_t			rayDirection;	// in world space
1836 	vec3_t			hitLocation;	// in world space
1837 	vec3_t			scale;
1838 	float			SSize;			// size of splotch in the S texture direction in world units
1839 	float			TSize;			// size of splotch in the T texture direction in world units
1840 	float			theta;			// angle to rotate the splotch
1841 
1842 	// growing stuff
1843 	int				growDuration;			// time over which we want this to scale up, set to -1 for no scaling
1844 	float			goreScaleStartFraction; // fraction of the final size at which we want the gore to initially appear
1845 
1846 	qboolean		frontFaces;
1847 	qboolean		backFaces;
1848 	qboolean		baseModelOnly;
1849 	int				lifeTime;				// effect expires after this amount of time
1850 	int				fadeOutTime;			//specify the duration of fading, from the lifeTime (e.g. 3000 will start fading 3 seconds before removal and be faded entirely by removal)
1851 	int				shrinkOutTime;			// unimplemented
1852 	float			alphaModulate;			// unimplemented
1853 	vec3_t			tint;					// unimplemented
1854 	float			impactStrength;			// unimplemented
1855 
1856 	int				shader; // shader handle
1857 
1858 	int				myIndex; // used internally
1859 
1860 	qboolean		fadeRGB; //specify fade method to modify RGB (by default, the alpha is set instead)
1861 } SSkinGoreData;
1862 
1863 /*
1864 ========================================================================
1865 
1866 String ID Tables
1867 
1868 ========================================================================
1869 */
1870 #define ENUM2STRING(arg)   { #arg, arg }
1871 typedef struct stringID_table_s
1872 {
1873 	const char	*name;
1874 	int		id;
1875 } stringID_table_t;
1876 
1877 int GetIDForString ( stringID_table_t *table, const char *string );
1878 const char *GetStringForID( stringID_table_t *table, int id );
1879 
1880 
1881 // stuff to help out during development process, force reloading/uncacheing of certain filetypes...
1882 //
1883 typedef enum
1884 {
1885 	eForceReload_NOTHING,
1886 //	eForceReload_BSP,	// not used in MP codebase
1887 	eForceReload_MODELS,
1888 	eForceReload_ALL
1889 
1890 } ForceReload_e;
1891 
1892 
1893 enum {
1894 	FONT_NONE,
1895 	FONT_SMALL=1,
1896 	FONT_MEDIUM,
1897 	FONT_LARGE,
1898 	FONT_SMALL2
1899 };
1900 
1901 void NET_AddrToString( char *out, size_t size, void *addr );
1902 
1903 qboolean Q_InBitflags( const uint32_t *bits, int index, uint32_t bitsPerByte );
1904 void Q_AddToBitflags( uint32_t *bits, int index, uint32_t bitsPerByte );
1905 void Q_RemoveFromBitflags( uint32_t *bits, int index, uint32_t bitsPerByte );
1906 
1907 typedef int( *cmpFunc_t )(const void *a, const void *b);
1908 
1909 void *Q_LinearSearch( const void *key, const void *ptr, size_t count,
1910 	size_t size, cmpFunc_t cmp );
1911