1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 
21 // q_shared.h -- included first by ALL program modules
22 
23 #ifdef _MSC_VER
24 // unknown pragmas are SUPPOSED to be ignored, but....
25 #pragma warning(disable : 4244)     // MIPS
26 #pragma warning(disable : 4136)     // X86
27 #pragma warning(disable : 4051)     // ALPHA
28 
29 #pragma warning(disable : 4018)     // signed/unsigned mismatch
30 #pragma warning(disable : 4305)		// truncation from const double to float
31 #endif
32 
33 #include <assert.h>
34 #include <math.h>
35 #include <ctype.h>
36 #include <stdio.h>
37 #include <stdarg.h>
38 #include <string.h>
39 #include <stdlib.h>
40 #include <time.h>
41 
42 #if ( defined _MSC_VER )
43 #define QALIGN( x )	__declspec( align( x ) )
44 #elif ( defined __GNUC__ ) /* _MSC_VER */
45 #define QALIGN( x )	__attribute__ ( ( aligned( x ) ) )
46 #else /* __GNUC__ */
47 #define QALIGN( x )
48 #endif /* !__GNUC__ */
49 
50 #ifndef __GNUC__
51 #define __attribute__( dummy )
52 #endif
53 
54 #if ( defined _WIN32_WCE )
55 
56 #define BUILDSTRING "WinCE"
57 
58 #if( defined ARM )
59 #define	CPUSTRING	"ARM"
60 #else
61 #define CPUSTRING "Unknown"
62 #endif
63 
64 #elif( defined _WIN32 )  /* _WIN32_WCE */
65 
66 #define BUILDSTRING "Win32"
67 
68 #if( defined _M_IX86 || defined __i386__ )
69 #define	CPUSTRING	"x86"
70 #elif( defined _M_ALPHA || defined __alpha__ )
71 #define	CPUSTRING	"AXP"
72 #else
73 #define CPUSTRING "Unknown"
74 #endif
75 
76 #elif( defined __linux__ ) /* WIN32 */
77 
78 #define BUILDSTRING "Linux"
79 
80 #ifdef __i686__
81 #define CPUSTRING "i686"
82 #elif defined __i386__
83 #define CPUSTRING "i386"
84 #elif defined __alpha__
85 #define CPUSTRING "axp"
86 #else
87 #define CPUSTRING "Unknown"
88 #endif
89 
90 #elif( defined __FreeBSD__ ) /* __linux__ */
91 
92 #define BUILDSTRING "FreeBSD"
93 
94 #ifdef __i386__
95 #define CPUSTRING "i386"
96 #elif defined __alpha__
97 #define CPUSTRING "axp"
98 #else
99 #define CPUSTRING "Unknown"
100 #endif
101 
102 #elif( defined __sun__ )  /* __FreeBSD__ */
103 
104 #define BUILDSTRING "Solaris"
105 
106 #ifdef __i386__
107 #define CPUSTRING "i386"
108 #else
109 #define CPUSTRING "sparc"
110 //#else
111 //#define CPUSTRING "Unknown"
112 #endif
113 
114 #else	/* __sun__ */
115 
116 #define BUILDSTRING "Unknown"
117 #define	CPUSTRING	"Unknown"
118 
119 #endif	/* !__sun__ */
120 
121 #if( defined _M_IX86 || defined __i386__ ) && ( !defined C_ONLY ) && ( !defined __sun__ )
122 #define id386	1
123 #else
124 #define id386	0
125 #endif
126 
127 #if( defined _M_ALPHA ) && ( !defined C_ONLY )
128 #define idaxp	1
129 #else
130 #define idaxp	0
131 #endif
132 
133 #ifdef _WIN32
134 #define PATH_SEP_CHAR		'\\'
135 #define PATH_SEP_STRING		"\\"
136 #else
137 #define PATH_SEP_CHAR		'/'
138 #define PATH_SEP_STRING		"/"
139 #endif
140 
141 typedef unsigned char 		byte;
142 typedef enum { qfalse, qtrue }	qboolean;
143 typedef int qhandle_t;
144 typedef int fileHandle_t;
145 
146 typedef unsigned char	uint8;
147 typedef unsigned short	uint16;
148 typedef unsigned int	uint32;
149 
150 #ifndef NULL
151 #define NULL ((void *)0)
152 #endif
153 
154 // angle indexes
155 #define	PITCH				0		// up / down
156 #define	YAW					1		// left / right
157 #define	ROLL				2		// fall over
158 
159 #define	MAX_STRING_CHARS	1024	// max length of a string passed to Cmd_TokenizeString
160 #define	MAX_STRING_TOKENS	256		// max tokens resulting from Cmd_TokenizeString
161 #define	MAX_TOKEN_CHARS		1024	// max length of an individual token
162 #define MAX_NET_STRING		2048	// max length of a string used in network protocol
163 
164 #define	MAX_QPATH			64		// max length of a quake game pathname
165 #define	MAX_OSPATH			128		// max length of a filesystem pathname
166 
167 //
168 // per-level limits
169 //
170 #define	MAX_CLIENTS			256		// absolute limit
171 #define	MAX_EDICTS			1024	// must change protocol to increase more
172 #define	MAX_LIGHTSTYLES		256
173 #define	MAX_MODELS			256		// these are sent over the net as bytes
174 #define	MAX_SOUNDS			256		// so they cannot be blindly increased
175 #define	MAX_IMAGES			256
176 #define	MAX_ITEMS			256
177 #define MAX_GENERAL			(MAX_CLIENTS*2)	// general config strings
178 
179 #define MAX_CLIENT_NAME		32
180 
181 typedef enum comErrorType_e {
182 	ERR_FATAL,			// exit the entire game with a popup window
183 	ERR_DROP,			// print to console and disconnect from game
184 	ERR_DISCONNECT,		// don't kill server
185 	ERR_SILENT
186 } comErrorType_t;
187 
188 typedef enum comPrintType_e {
189 	PRINT_ALL,			// general messages
190 	PRINT_DEVELOPER,	// only print when "developer 1"
191 	PRINT_WARNING,		// print in yellow color
192 	PRINT_ERROR			// print in red color
193 } comPrintType_t;
194 
195 // FIXME: move these to com_public.h?
196 void 		Com_Printf( const char *fmt, ... )
197     __attribute__(( format ( printf, 1, 2 ) ));
198 void 		Com_DPrintf( const char *fmt, ... )
199     __attribute__(( format ( printf, 1, 2 ) ));
200 void		Com_WPrintf( const char *fmt, ... )
201     __attribute__(( format ( printf, 1, 2 ) ));
202 void		Com_EPrintf( const char *fmt, ... )
203     __attribute__(( format ( printf, 1, 2 ) ));
204 void 		Com_Error( comErrorType_t code, const char *fmt, ... )
205     __attribute__(( noreturn, format ( printf, 2, 3 ) ));
206 
207 // game print flags
208 #define	PRINT_LOW			0		// pickup messages
209 #define	PRINT_MEDIUM		1		// death messages
210 #define	PRINT_HIGH			2		// critical messages
211 #define	PRINT_CHAT			3		// chat messages
212 
213 // destination class for gi.multicast()
214 typedef enum multicast_e {
215 	MULTICAST_ALL,
216 	MULTICAST_PHS,
217 	MULTICAST_PVS,
218 	MULTICAST_ALL_R,
219 	MULTICAST_PHS_R,
220 	MULTICAST_PVS_R
221 } multicast_t;
222 
223 /*
224 ==============================================================
225 
226 MATHLIB
227 
228 ==============================================================
229 */
230 
231 typedef float vec_t;
232 typedef vec_t vec2_t[2];
233 typedef vec_t vec3_t[3];
234 typedef vec_t vec4_t[4];
235 typedef vec_t vec5_t[5];
236 
237 typedef float mat4_t[16];
238 
239 typedef byte color_t[4];
240 
241 typedef	int	fixed4_t;
242 typedef	int	fixed8_t;
243 typedef	int	fixed16_t;
244 
245 #ifndef M_PI
246 #define M_PI		3.14159265358979323846	// matches value in gcc v2 math.h
247 #endif
248 
249 struct cplane_s;
250 
251 extern vec3_t vec3_origin;
252 
253 #define NUMVERTEXNORMALS	162
254 
255 extern vec3_t bytedirs[NUMVERTEXNORMALS];
256 
257 extern const color_t colorBlack;
258 extern const color_t colorRed;
259 extern const color_t colorGreen;
260 extern const color_t colorYellow;
261 extern const color_t colorBlue;
262 extern const color_t colorCyan;
263 extern const color_t colorMagenta;
264 extern const color_t colorWhite;
265 
266 extern const color_t colorTable[8];
267 
268 typedef struct vrect_s {
269 	int				x, y, width, height;
270 } vrect_t;
271 
272 #define	nanmask (255<<23)
273 
274 #define	IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
275 
276 // microsoft's fabs seems to be ungodly slow...
277 float Q_fabs( float f );
278 
279 #if id386 && ( defined _MSC_VER )
280 extern long Q_ftol( float f );
281 #else
282 #define Q_ftol( f ) ( long ) (f)
283 #endif
284 
285 #define DEG2RAD( a ) ( a * M_PI ) / 180.0F
286 
287 #define DotProduct(x,y)			((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
288 #define CrossProduct(v1,v2,cross) \
289 		((cross)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1], \
290 		 (cross)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2], \
291 		 (cross)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0])
292 #define VectorSubtract(a,b,c) \
293 		((c)[0]=(a)[0]-(b)[0], \
294 		 (c)[1]=(a)[1]-(b)[1], \
295 		 (c)[2]=(a)[2]-(b)[2])
296 #define VectorAdd(a,b,c) \
297 		((c)[0]=(a)[0]+(b)[0], \
298 		 (c)[1]=(a)[1]+(b)[1], \
299 		 (c)[2]=(a)[2]+(b)[2])
300 #define VectorCopy(a,b)		((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
301 #define VectorClear(a)		((a)[0]=(a)[1]=(a)[2]=0)
302 #define VectorNegate(a,b)	((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
303 #define VectorInverse(a)	((a)[0]=-(a)[0],(a)[1]=-(a)[1],(a)[2]=-(a)[2])
304 #define VectorSet(v, x, y, z)	((v)[0]=(x),(v)[1]=(y),(v)[2]=(z))
305 #define VectorAvg(a,b,c) \
306 		((c)[0]=((a)[0]+(b)[0])*0.5f, \
307 		 (c)[1]=((a)[1]+(b)[1])*0.5f, \
308 		 (c)[2]=((a)[2]+(b)[2])*0.5f)
309 #define VectorMA(a,b,c,d) \
310 		((d)[0]=(a)[0]+(b)*(c)[0], \
311 	 	 (d)[1]=(a)[1]+(b)*(c)[1], \
312 		 (d)[2]=(a)[2]+(b)*(c)[2])
313 #define VectorVectorMA(a,b,c,d) \
314 		((d)[0]=(a)[0]+(b)[0]*(c)[0], \
315 	 	 (d)[1]=(a)[1]+(b)[1]*(c)[1], \
316 		 (d)[2]=(a)[2]+(b)[2]*(c)[2])
317 #define VectorCompare(v1,v2)	((v1)[0]==(v2)[0]&&(v1)[1]==(v2)[1]&&(v1)[2]==(v2)[2])
318 #define VectorLength(v)		(sqrt(DotProduct((v),(v))))
319 #define VectorLengthSquared(v)		(DotProduct((v),(v)))
320 #define VectorScale(in,scale,out) \
321 		((out)[0]=(in)[0]*(scale), \
322 		 (out)[1]=(in)[1]*(scale), \
323 		 (out)[2]=(in)[2]*(scale))
324 #define VectorVectorScale(in,scale,out) \
325 		((out)[0]=(in)[0]*(scale)[0], \
326 		 (out)[1]=(in)[1]*(scale)[1], \
327 		 (out)[2]=(in)[2]*(scale)[2])
328 #define DistanceSquared(v1,v2) \
329 		(((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+ \
330 		((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])+ \
331 		((v1)[2]-(v2)[2])*((v1)[2]-(v2)[2]))
332 #define Distance(v1,v2) (sqrt(DistanceSquared(v1,v2)))
333 
334 #define Vector4Subtract(a,b,c)	(c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2],c[3]=a[3]-b[3])
335 #define Vector4Add(a,b,c)		(c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2],c[3]=a[3]+b[3])
336 #define Vector4Copy(a,b)			(b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3])
337 #define Vector4Clear(a)			(a[0]=a[1]=a[2]=a[3]=0)
338 #define Vector4Negate(a,b)		(b[0]=-a[0],b[1]=-a[1],b[2]=-a[2],b[3]=-a[3])
339 #define Vector4Set(v, a, b, c, d)	(v[0]=(a),v[1]=(b),v[2]=(c),v[3]=(d))
340 
341 
342 
343 // just in case you do't want to use the macros
344 /*vec_t _DotProduct (vec3_t v1, vec3_t v2);
345 void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out);
346 void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out);
347 void _VectorCopy (vec3_t in, vec3_t out);
348 void _VectorScale (vec3_t in, vec_t scale, vec3_t out);
349 void _VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc);
350 void _CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross);*/
351 
352 void ClearBounds (vec3_t mins, vec3_t maxs);
353 void AddPointToBounds (const vec3_t v, vec3_t mins, vec3_t maxs);
354 vec_t RadiusFromBounds (const vec3_t mins, const vec3_t maxs);
355 void UnionBounds( vec3_t a[2], vec3_t b[2], vec3_t c[2] );
356 /*vec_t VectorLength (vec3_t v);*/
357 vec_t VectorNormalize (vec3_t v);		// returns vector length
358 vec_t VectorNormalize2 (vec3_t v, vec3_t out);
359 
360 int Q_log2(int val);
361 int Q_CeilPowerOfTwo( int value );
362 float Com_CalcFov( float fov_x, float width, float height );
363 
364 void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
365 void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
366 
367 void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
368 int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
369 float	anglemod(float a);
370 float LerpAngle (float a1, float a2, float frac);
371 
372 void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
373 void PerpendicularVector( vec3_t dst, const vec3_t src );
374 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
375 
376 int DirToByte( const vec3_t dir );
377 void ByteToDir( int index, vec3_t dir );
378 
379 #define clamp(a,b,c) ((b)>=(c)?(a)=(b):(a)<(b)?(a)=(b):(a)>(c)?(a)=(c):(a))
380 
381 #ifndef max
382 #define max(a,b) ((a)>(b)?(a):(b))
383 #endif
384 
385 #ifndef min
386 #define min(a,b) ((a)<(b)?(a):(b))
387 #endif
388 
389 #define frand()		( ( rand() & 32767 ) * ( 1.0 / 32767 ) )
390 #define crand()		( ( rand() & 32767 ) * ( 2.0 / 32767 ) - 1 )
391 
392 #define Q_rint(x)	((x) < 0 ? ((int)((x) - 0.5f)) : ((int)((x) + 0.5f)))
393 
394 #define Q_IsBitSet( data, bit )		( ( (data)[(bit) >> 3] & ( 1 << ( (bit) & 7 ) ) ) != 0 )
395 #define Q_SetBit( data, bit )		( (data)[(bit) >> 3] |= ( 1 << ( (bit) & 7 ) ) )
396 #define Q_ClearBit( data, bit )		( (data)[(bit) >> 3] &= ~( 1 << ( (bit) & 7 ) ) )
397 
398 /* use escape character server will never send */
399 #define Q_COLOR_ESCAPE	'\x7F'
400 #define Q_COLOR_ESCAPE_STRING	"\x7F"
401 #define Q_IsColorString(p)	( *(p) == Q_COLOR_ESCAPE && *( (p) + 1 ) )
402 
403 #define COLOR_BLACK		'0'
404 #define COLOR_RED		'1'
405 #define COLOR_GREEN		'2'
406 #define COLOR_YELLOW	'3'
407 #define COLOR_BLUE		'4'
408 #define COLOR_CYAN		'5'
409 #define COLOR_MAGENTA	'6'
410 #define COLOR_WHITE		'7'
411 #define ColorIndex(c)	( ( (c) - '0' ) & 7 )
412 
413 #define COLOR_ALT		'8'
414 #define COLOR_RESET		'9'
415 
416 #define S_COLOR_BLACK		Q_COLOR_ESCAPE_STRING "0"
417 #define S_COLOR_RED			Q_COLOR_ESCAPE_STRING "1"
418 #define S_COLOR_GREEN		Q_COLOR_ESCAPE_STRING "2"
419 #define S_COLOR_YELLOW		Q_COLOR_ESCAPE_STRING "3"
420 #define S_COLOR_BLUE		Q_COLOR_ESCAPE_STRING "4"
421 #define S_COLOR_CYAN		Q_COLOR_ESCAPE_STRING "5"
422 #define S_COLOR_MAGENTA		Q_COLOR_ESCAPE_STRING "6"
423 #define S_COLOR_WHITE		Q_COLOR_ESCAPE_STRING "7"
424 
425 #define S_COLOR_ALT			Q_COLOR_ESCAPE_STRING "8"
426 #define S_COLOR_RESET		Q_COLOR_ESCAPE_STRING "9"
427 
428 #define MAKERGB(v,r,g,b)	((v)[0]=(r),(v)[1]=(g),(v)[2]=(b))
429 #define MAKERGBA(v,r,g,b,a)	((v)[0]=(r),(v)[1]=(g),(v)[2]=(b),(v)[3]=(a))
430 
431 #define SCREEN_WIDTH	640
432 #define SCREEN_HEIGHT	480
433 
434 #define UI_LEFT				0x00000001
435 #define UI_RIGHT			0x00000002
436 #define UI_CENTER			(UI_LEFT|UI_RIGHT)
437 #define UI_BOTTOM			0x00000004
438 #define UI_TOP				0x00000008
439 #define UI_MIDDLE			(UI_BOTTOM|UI_TOP)
440 #define UI_DROPSHADOW		0x00000010
441 #define UI_ALTCOLOR			0x00000020
442 #define UI_IGNORECOLOR		0x00000040
443 #define UI_ALTESCAPES		0x00000080
444 #define UI_AUTOWRAP			0x00000100
445 #define UI_MULTILINE		0x00000200
446 #define UI_DRAWCURSOR		0x00000400
447 
448 #define TINYCHAR_WIDTH	8
449 #define TINYCHAR_HEIGHT	8
450 
451 int Q_DrawStrlen( const char *string );
452 int Q_DrawStrlenTo( const char *string, int maxChars );
453 int Q_CleanColorStr( const char *string, char *buffer, int bufferSize );
454 int Q_CleanStr( const char *string, char *buffer, int bufferSize );
455 qboolean Q_IsWhiteSpace( const char *string );
456 char *Q_FormatString( const char *string );
457 char *Q_UnescapeString( const char *string );
458 
459 //=============================================
460 
461 #define Q_isupper( c )	( c >= 'A' && c <= 'Z' )
462 #define Q_islower( c )	 ( c >= 'a' && c <= 'z' )
463 #define Q_isdigit( c )	 ( c >= '0' && c <= '9' )
464 #define Q_isalpha( c )	( Q_isupper( c ) || Q_islower( c ) )
465 #define Q_isalnum( c )	( Q_isalpha( c ) || Q_isdigit( c ) )
466 
467 // tests if specified character is valid quake path character
468 #define Q_ispath( c )	( Q_isalnum( c ) || c == '_' || c == '-' )
469 
470 int Q_tolower( int c );
471 int Q_toupper( int c );
472 
473 // portable case insensitive compare
474 int Q_strcasecmp( const char *s1, const char *s2 );
475 int Q_strncasecmp( const char *s1, const char *s2, int n );
476 
477 #define Q_stricmp	Q_strcasecmp
478 #define Q_stricmpn	Q_strncasecmp
479 
480 char *Q_strlwr( char *s );
481 char *Q_strupr( char *s );
482 
483 int SortStrcmp( const void *p1, const void *p2 );
484 
485 char *COM_SkipPath( const char *pathname );
486 void COM_StripExtension( const char *in, char *out, int outSize );
487 void COM_FileBase (char *in, char *out);
488 void COM_FilePath( const char *in, char *out, int outSize );
489 void COM_DefaultExtension( char *path, const char *extension, int pathSize );
490 char *COM_FileExtension( const char *in );
491 
492 qboolean COM_IsNumeric( const char *string );
493 
494 char *COM_Parse( const char **data_p );
495 // data is an in/out parm, returns a parsed out token
496 
497 int Com_WildCmp( const char *filter, const char *string, qboolean ignoreCase );
498 int SortStrcmp( const void *p1, const void *p2 );
499 
500 uint32 Com_HashString( const char *string, int hashSize );
501 uint32 Com_HashPath( const char *string, int hashSize );
502 
503 char *Com_ReplaceSeparators( char *s, int separator );
504 
505 // buffer safe operations
506 void Q_strncpyz( char *dest, const char *src, int destsize );
507 void Q_strcat( char *dest, int destsize, const char *src );
508 int Com_sprintf( char *dest, int destsize, const char *fmt, ... )
509 	__attribute__(( format ( printf, 3, 4 ) ));
510 int Q_vsnprintf( char *dest, int destsize, const char *fmt, va_list argptr );
511 
512 void Com_PageInMemory (byte *buffer, int size);
513 
514 uint32 COM_ParseHex( const char *string );
515 
516 //=============================================
517 
518 short	ShortSwap( short l );
519 int		LongSwap( int l );
520 float	FloatSwap( float f );
521 
522 #ifdef BIGENDIAN_TARGET
523  #define BigShort
524  #define BigLong
525  #define BigFloat
526  #define LittleShort	ShortSwap
527  #define LittleLong		LongSwap
528  #define LittleFloat	FloatSwap
529  #define MakeLittleLong( b1, b2, b3, b4 ) \
530 	( ( ( b1 ) << 24 ) + ( ( b2 ) << 16 ) + ( ( b3 ) << 8 ) + ( b4 ) )
531  #define MakeBigLong( b1, b2, b3, b4 ) \
532 	( ( ( b4 ) << 24 ) + ( ( b3 ) << 16 ) + ( ( b2 ) << 8 ) + ( b1 ) )
533 #else
534  #define BigShort	ShortSwap
535  #define BigLong	LongSwap
536  #define BigFloat	FloatSwap
537  #define LittleShort
538  #define LittleLong
539  #define LittleFloat
540  #define MakeLittleLong( b1, b2, b3, b4 ) \
541 	( ( ( b4 ) << 24 ) + ( ( b3 ) << 16 ) + ( ( b2 ) << 8 ) + ( b1 ) )
542  #define MakeBigLong( b1, b2, b3, b4 ) \
543 	( ( ( b1 ) << 24 ) + ( ( b2 ) << 16 ) + ( ( b3 ) << 8 ) + ( b4 ) )
544 #endif
545 
546 
547 char	*va( const char *format, ... );
548 
549 //=============================================
550 
551 //
552 // key / value info strings
553 //
554 #define	MAX_INFO_KEY		64
555 #define	MAX_INFO_VALUE		64
556 #define	MAX_INFO_STRING		512
557 
558 char	*Info_ValueForKey( const char *s, const char *key );
559 void	Info_RemoveKey( char *s, const char *key );
560 void	Info_SetValueForKey( char *s, const char *key, const char *value );
561 qboolean Info_AttemptSetValueForKey( char *s, const char *key, const char *value );
562 qboolean	Info_Validate( const char *s );
563 qboolean	Info_ValidateSubstring( const char *s );
564 void	Info_NextPair( const char **string, char *key, char *value );
565 void	Info_Print( const char *infostring );
566 
567 //=============================================
568 
569 typedef struct tm	qtime_t;
570 
571 void Com_LocalTime( qtime_t *time );
572 
573 /*
574 ==========================================================
575 
576 CVARS (console variables)
577 
578 ==========================================================
579 */
580 
581 #ifndef CVAR
582 #define	CVAR
583 
584 #define	CVAR_ARCHIVE	1	// set to cause it to be saved to vars.rc
585 #define	CVAR_USERINFO	2	// added to userinfo  when changed
586 #define	CVAR_SERVERINFO	4	// added to serverinfo when changed
587 #define	CVAR_NOSET		8	// don't allow change from console at all,
588 							// but can be set from the command line
589 #define	CVAR_LATCH		16	// save changes until server restart
590 
591 // nothing outside the cvar.*() functions should modify these fields!
592 typedef struct cvar_s {
593 	char		*name;
594 	char		*string;
595 	char		*latched_string;	// for CVAR_LATCH vars
596 	int			flags;
597 	qboolean	modified;	// set each time the cvar is changed
598 	float		value;
599 	struct cvar_s *next;
600 
601 // ------ new stuff ------
602 	int		integer;
603 	void	(*changedFunc)( struct cvar_s *self, void *arg );	// WARNING: points to static variable
604 	void	*changedArg;
605 
606 	char		*defaultString;
607 	const char	*description;		// WARNING: points to static variable
608 	uint32		subsystem;
609 
610 	struct cvar_s *hashNext;
611 } cvar_t;
612 
613 #endif		// CVAR
614 
615 /*
616 ==============================================================
617 
618 COLLISION DETECTION
619 
620 ==============================================================
621 */
622 
623 // lower bits are stronger, and will eat weaker brushes completely
624 #define	CONTENTS_SOLID			1		// an eye is never valid in a solid
625 #define	CONTENTS_WINDOW			2		// translucent, but not watery
626 #define	CONTENTS_AUX			4
627 #define	CONTENTS_LAVA			8
628 #define	CONTENTS_SLIME			16
629 #define	CONTENTS_WATER			32
630 #define	CONTENTS_MIST			64
631 #define	LAST_VISIBLE_CONTENTS	64
632 
633 // remaining contents are non-visible, and don't eat brushes
634 
635 #define	CONTENTS_AREAPORTAL		0x8000
636 
637 #define	CONTENTS_PLAYERCLIP		0x10000
638 #define	CONTENTS_MONSTERCLIP	0x20000
639 
640 // currents can be added to any other contents, and may be mixed
641 #define	CONTENTS_CURRENT_0		0x40000
642 #define	CONTENTS_CURRENT_90		0x80000
643 #define	CONTENTS_CURRENT_180	0x100000
644 #define	CONTENTS_CURRENT_270	0x200000
645 #define	CONTENTS_CURRENT_UP		0x400000
646 #define	CONTENTS_CURRENT_DOWN	0x800000
647 
648 #define	CONTENTS_ORIGIN			0x1000000	// removed before bsping an entity
649 
650 #define	CONTENTS_MONSTER		0x2000000	// should never be on a brush, only in game
651 #define	CONTENTS_DEADMONSTER	0x4000000
652 #define	CONTENTS_DETAIL			0x8000000	// brushes to be added after vis leafs
653 #define	CONTENTS_TRANSLUCENT	0x10000000	// auto set if any surface has trans
654 #define	CONTENTS_LADDER			0x20000000
655 
656 
657 
658 #define	SURF_LIGHT		0x1		// value will hold the light strength
659 
660 #define	SURF_SLICK		0x2		// effects game physics
661 
662 #define	SURF_SKY		0x4		// don't draw, but add to skybox
663 #define	SURF_WARP		0x8		// turbulent water warp
664 #define	SURF_TRANS33	0x10
665 #define	SURF_TRANS66	0x20
666 #define	SURF_FLOWING	0x40	// scroll towards angle
667 #define	SURF_NODRAW		0x80	// don't bother referencing the texture
668 
669 
670 
671 // content masks
672 #define	MASK_ALL				(-1)
673 #define	MASK_SOLID				(CONTENTS_SOLID|CONTENTS_WINDOW)
674 #define	MASK_PLAYERSOLID		(CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
675 #define	MASK_DEADSOLID			(CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW)
676 #define	MASK_MONSTERSOLID		(CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER)
677 #define	MASK_WATER				(CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME)
678 #define	MASK_OPAQUE				(CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA)
679 #define	MASK_SHOT				(CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER)
680 #define MASK_CURRENT			(CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN)
681 
682 
683 // gi.BoxEdicts() can return a list of either solid or trigger entities
684 // FIXME: eliminate AREA_ distinction?
685 #define	AREA_SOLID		1
686 #define	AREA_TRIGGERS	2
687 
688 
689 // plane_t structure
690 // !!! if this is changed, it must be changed in asm code too !!!
691 typedef struct cplane_s
692 {
693 	vec3_t	normal;
694 	float	dist;
695 	byte	type;			// for fast side tests
696 	byte	signbits;		// signx + (signy<<1) + (signz<<1)
697 	byte	pad[2];
698 } cplane_t;
699 
700 // 0-2 are axial planes
701 #define	PLANE_X			0
702 #define	PLANE_Y			1
703 #define	PLANE_Z			2
704 
705 // 3-5 are non-axial planes snapped to the nearest
706 #define	PLANE_ANYX		3
707 #define	PLANE_ANYY		4
708 #define	PLANE_ANYZ		5
709 
710 // planes (x&~1) and (x&~1)+1 are always opposites
711 
712 #define PLANE_NON_AXIAL 6
713 
714 // structure offset for asm code
715 #define CPLANE_NORMAL_X			0
716 #define CPLANE_NORMAL_Y			4
717 #define CPLANE_NORMAL_Z			8
718 #define CPLANE_DIST				12
719 #define CPLANE_TYPE				16
720 #define CPLANE_SIGNBITS			17
721 #define CPLANE_PAD0				18
722 #define CPLANE_PAD1				19
723 
724 void SetPlaneType( cplane_t *plane );
725 void SetPlaneSignbits( cplane_t *plane );
726 
727 #define BOX_INFRONT     1
728 #define BOX_BEHIND      2
729 #define BOX_INTERSECTS  3
730 
731 int BoxOnPlaneSide( vec3_t emins, vec3_t emaxs, cplane_t *p );
732 
733 typedef struct csurface_s
734 {
735 	char		name[16];
736 	int			flags;
737 	int			value;
738 } csurface_t;
739 
740 // a trace is returned when a box is swept through the world
741 typedef struct
742 {
743 	qboolean	allsolid;	// if qtrue, plane is not valid
744 	qboolean	startsolid;	// if qtrue, the initial point was in a solid area
745 	float		fraction;	// time completed, 1.0 = didn't hit anything
746 	vec3_t		endpos;		// final position
747 	cplane_t	plane;		// surface normal at impact
748 	csurface_t	*surface;	// surface hit
749 	int			contents;	// contents on other side of surface hit
750 	struct edict_s	*ent;		// not set by CM_*() functions
751 } trace_t;
752 
753 
754 
755 // pmove_state_t is the information necessary for client side movement
756 // prediction
757 typedef enum
758 {
759 	// can accelerate and turn
760 	PM_NORMAL,
761 	PM_SPECTATOR,
762 	// no acceleration or turning
763 	PM_DEAD,
764 	PM_GIB,		// different bounding box
765 	PM_FREEZE
766 } pmtype_t;
767 
768 // pmove->pm_flags
769 #define	PMF_DUCKED			1
770 #define	PMF_JUMP_HELD		2
771 #define	PMF_ON_GROUND		4
772 #define	PMF_TIME_WATERJUMP	8	// pm_time is waterjump
773 #define	PMF_TIME_LAND		16	// pm_time is time before rejump
774 #define	PMF_TIME_TELEPORT	32	// pm_time is non-moving time
775 #define PMF_NO_PREDICTION	64	// temporarily disables prediction (used for grappling hook)
776 #define PMF_TELEPORT_BIT	128 // used by q2pro
777 
778 // this structure needs to be communicated bit-accurate
779 // from the server to the client to guarantee that
780 // prediction stays in sync, so no floats are used.
781 // if any part of the game code modifies this struct, it
782 // will result in a prediction error of some degree.
783 typedef struct
784 {
785 	pmtype_t	pm_type;
786 
787 	short		origin[3];		// 12.3
788 	short		velocity[3];	// 12.3
789 	byte		pm_flags;		// ducked, jump_held, etc
790 	byte		pm_time;		// each unit = 8 ms
791 	short		gravity;
792 	short		delta_angles[3];	// add to command angles to get view direction
793 									// changed by spawns, rotating objects, and teleporters
794 } pmove_state_t;
795 
796 
797 //
798 // button bits
799 //
800 #define	BUTTON_ATTACK		1
801 #define	BUTTON_USE			2
802 #define	BUTTON_ANY			128			// any key whatsoever
803 
804 
805 // usercmd_t is sent to the server each client frame
806 typedef struct usercmd_s
807 {
808 	byte	msec;
809 	byte	buttons;
810 	short	angles[3];
811 	short	forwardmove, sidemove, upmove;
812 	byte	impulse;		// remove?
813 	byte	lightlevel;		// light level the player is standing on
814 } usercmd_t;
815 
816 
817 #define	MAXTOUCH	32
818 typedef struct
819 {
820 	// state (in / out)
821 	pmove_state_t	s;
822 
823 	// command (in)
824 	usercmd_t		cmd;
825 	qboolean		snapinitial;	// if s has been changed outside pmove
826 
827 	// results (out)
828 	int			numtouch;
829 	struct edict_s	*touchents[MAXTOUCH];
830 
831 	vec3_t		viewangles;			// clamped
832 	float		viewheight;
833 
834 	vec3_t		mins, maxs;			// bounding box size
835 
836 	struct edict_s	*groundentity;
837 	int			watertype;
838 	int			waterlevel;
839 
840 	// callbacks to test the world
841 	trace_t		(*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end);
842 	int			(*pointcontents) (vec3_t point);
843 } pmove_t;
844 
845 
846 // entity_state_t->effects
847 // Effects are things handled on the client side (lights, particles, frame animations)
848 // that happen constantly on the given entity.
849 // An entity that has effects will be sent to the client
850 // even if it has a zero index model.
851 #define	EF_ROTATE			0x00000001		// rotate (bonus items)
852 #define	EF_GIB				0x00000002		// leave a trail
853 #define	EF_BLASTER			0x00000008		// redlight + trail
854 #define	EF_ROCKET			0x00000010		// redlight + trail
855 #define	EF_GRENADE			0x00000020
856 #define	EF_HYPERBLASTER		0x00000040
857 #define	EF_BFG				0x00000080
858 #define EF_COLOR_SHELL		0x00000100
859 #define EF_POWERSCREEN		0x00000200
860 #define	EF_ANIM01			0x00000400		// automatically cycle between frames 0 and 1 at 2 hz
861 #define	EF_ANIM23			0x00000800		// automatically cycle between frames 2 and 3 at 2 hz
862 #define EF_ANIM_ALL			0x00001000		// automatically cycle through all frames at 2hz
863 #define EF_ANIM_ALLFAST		0x00002000		// automatically cycle through all frames at 10hz
864 #define	EF_FLIES			0x00004000
865 #define	EF_QUAD				0x00008000
866 #define	EF_PENT				0x00010000
867 #define	EF_TELEPORTER		0x00020000		// particle fountain
868 #define EF_FLAG1			0x00040000
869 #define EF_FLAG2			0x00080000
870 // RAFAEL
871 #define EF_IONRIPPER		0x00100000
872 #define EF_GREENGIB			0x00200000
873 #define	EF_BLUEHYPERBLASTER 0x00400000
874 #define EF_SPINNINGLIGHTS	0x00800000
875 #define EF_PLASMA			0x01000000
876 #define EF_TRAP				0x02000000
877 
878 //ROGUE
879 #define EF_TRACKER			0x04000000
880 #define	EF_DOUBLE			0x08000000
881 #define	EF_SPHERETRANS		0x10000000
882 #define EF_TAGTRAIL			0x20000000
883 #define EF_HALF_DAMAGE		0x40000000
884 #define EF_TRACKERTRAIL		0x80000000
885 //ROGUE
886 
887 // entity_state_t->renderfx flags
888 #define	RF_MINLIGHT			1		// allways have some light (viewmodel)
889 #define	RF_VIEWERMODEL		2		// don't draw through eyes, only mirrors
890 #define	RF_WEAPONMODEL		4		// only draw through eyes
891 #define	RF_FULLBRIGHT		8		// allways draw full intensity
892 #define	RF_DEPTHHACK		16		// for view weapon Z crunching
893 #define	RF_TRANSLUCENT		32
894 #define	RF_FRAMELERP		64
895 #define RF_BEAM				128
896 #define	RF_CUSTOMSKIN		256		// skin is an index in image_precache
897 #define	RF_GLOW				512		// pulse lighting for bonus items
898 #define RF_SHELL_RED		1024
899 #define	RF_SHELL_GREEN		2048
900 #define RF_SHELL_BLUE		4096
901 
902 //ROGUE
903 #define RF_IR_VISIBLE		0x00008000		// 32768
904 #define	RF_SHELL_DOUBLE		0x00010000		// 65536
905 #define	RF_SHELL_HALF_DAM	0x00020000
906 #define RF_USE_DISGUISE		0x00040000
907 //ROGUE
908 
909 // player_state_t->refdef flags
910 #define	RDF_UNDERWATER		1		// warp the screen as apropriate
911 #define RDF_NOWORLDMODEL	2		// used for player configuration screen
912 
913 //ROGUE
914 #define	RDF_IRGOGGLES		4
915 #define RDF_UVGOGGLES		8
916 //ROGUE
917 
918 //
919 // muzzle flashes / player effects
920 //
921 #define	MZ_BLASTER			0
922 #define MZ_MACHINEGUN		1
923 #define	MZ_SHOTGUN			2
924 #define	MZ_CHAINGUN1		3
925 #define	MZ_CHAINGUN2		4
926 #define	MZ_CHAINGUN3		5
927 #define	MZ_RAILGUN			6
928 #define	MZ_ROCKET			7
929 #define	MZ_GRENADE			8
930 #define	MZ_LOGIN			9
931 #define	MZ_LOGOUT			10
932 #define	MZ_RESPAWN			11
933 #define	MZ_BFG				12
934 #define	MZ_SSHOTGUN			13
935 #define	MZ_HYPERBLASTER		14
936 #define	MZ_ITEMRESPAWN		15
937 // RAFAEL
938 #define MZ_IONRIPPER		16
939 #define MZ_BLUEHYPERBLASTER 17
940 #define MZ_PHALANX			18
941 #define MZ_SILENCED			128		// bit flag ORed with one of the above numbers
942 
943 //ROGUE
944 #define MZ_ETF_RIFLE		30
945 #define MZ_UNUSED			31
946 #define MZ_SHOTGUN2			32
947 #define MZ_HEATBEAM			33
948 #define MZ_BLASTER2			34
949 #define	MZ_TRACKER			35
950 #define	MZ_NUKE1			36
951 #define	MZ_NUKE2			37
952 #define	MZ_NUKE4			38
953 #define	MZ_NUKE8			39
954 //ROGUE
955 
956 //
957 // monster muzzle flashes
958 //
959 #define MZ2_TANK_BLASTER_1				1
960 #define MZ2_TANK_BLASTER_2				2
961 #define MZ2_TANK_BLASTER_3				3
962 #define MZ2_TANK_MACHINEGUN_1			4
963 #define MZ2_TANK_MACHINEGUN_2			5
964 #define MZ2_TANK_MACHINEGUN_3			6
965 #define MZ2_TANK_MACHINEGUN_4			7
966 #define MZ2_TANK_MACHINEGUN_5			8
967 #define MZ2_TANK_MACHINEGUN_6			9
968 #define MZ2_TANK_MACHINEGUN_7			10
969 #define MZ2_TANK_MACHINEGUN_8			11
970 #define MZ2_TANK_MACHINEGUN_9			12
971 #define MZ2_TANK_MACHINEGUN_10			13
972 #define MZ2_TANK_MACHINEGUN_11			14
973 #define MZ2_TANK_MACHINEGUN_12			15
974 #define MZ2_TANK_MACHINEGUN_13			16
975 #define MZ2_TANK_MACHINEGUN_14			17
976 #define MZ2_TANK_MACHINEGUN_15			18
977 #define MZ2_TANK_MACHINEGUN_16			19
978 #define MZ2_TANK_MACHINEGUN_17			20
979 #define MZ2_TANK_MACHINEGUN_18			21
980 #define MZ2_TANK_MACHINEGUN_19			22
981 #define MZ2_TANK_ROCKET_1				23
982 #define MZ2_TANK_ROCKET_2				24
983 #define MZ2_TANK_ROCKET_3				25
984 
985 #define MZ2_INFANTRY_MACHINEGUN_1		26
986 #define MZ2_INFANTRY_MACHINEGUN_2		27
987 #define MZ2_INFANTRY_MACHINEGUN_3		28
988 #define MZ2_INFANTRY_MACHINEGUN_4		29
989 #define MZ2_INFANTRY_MACHINEGUN_5		30
990 #define MZ2_INFANTRY_MACHINEGUN_6		31
991 #define MZ2_INFANTRY_MACHINEGUN_7		32
992 #define MZ2_INFANTRY_MACHINEGUN_8		33
993 #define MZ2_INFANTRY_MACHINEGUN_9		34
994 #define MZ2_INFANTRY_MACHINEGUN_10		35
995 #define MZ2_INFANTRY_MACHINEGUN_11		36
996 #define MZ2_INFANTRY_MACHINEGUN_12		37
997 #define MZ2_INFANTRY_MACHINEGUN_13		38
998 
999 #define MZ2_SOLDIER_BLASTER_1			39
1000 #define MZ2_SOLDIER_BLASTER_2			40
1001 #define MZ2_SOLDIER_SHOTGUN_1			41
1002 #define MZ2_SOLDIER_SHOTGUN_2			42
1003 #define MZ2_SOLDIER_MACHINEGUN_1		43
1004 #define MZ2_SOLDIER_MACHINEGUN_2		44
1005 
1006 #define MZ2_GUNNER_MACHINEGUN_1			45
1007 #define MZ2_GUNNER_MACHINEGUN_2			46
1008 #define MZ2_GUNNER_MACHINEGUN_3			47
1009 #define MZ2_GUNNER_MACHINEGUN_4			48
1010 #define MZ2_GUNNER_MACHINEGUN_5			49
1011 #define MZ2_GUNNER_MACHINEGUN_6			50
1012 #define MZ2_GUNNER_MACHINEGUN_7			51
1013 #define MZ2_GUNNER_MACHINEGUN_8			52
1014 #define MZ2_GUNNER_GRENADE_1			53
1015 #define MZ2_GUNNER_GRENADE_2			54
1016 #define MZ2_GUNNER_GRENADE_3			55
1017 #define MZ2_GUNNER_GRENADE_4			56
1018 
1019 #define MZ2_CHICK_ROCKET_1				57
1020 
1021 #define MZ2_FLYER_BLASTER_1				58
1022 #define MZ2_FLYER_BLASTER_2				59
1023 
1024 #define MZ2_MEDIC_BLASTER_1				60
1025 
1026 #define MZ2_GLADIATOR_RAILGUN_1			61
1027 
1028 #define MZ2_HOVER_BLASTER_1				62
1029 
1030 #define MZ2_ACTOR_MACHINEGUN_1			63
1031 
1032 #define MZ2_SUPERTANK_MACHINEGUN_1		64
1033 #define MZ2_SUPERTANK_MACHINEGUN_2		65
1034 #define MZ2_SUPERTANK_MACHINEGUN_3		66
1035 #define MZ2_SUPERTANK_MACHINEGUN_4		67
1036 #define MZ2_SUPERTANK_MACHINEGUN_5		68
1037 #define MZ2_SUPERTANK_MACHINEGUN_6		69
1038 #define MZ2_SUPERTANK_ROCKET_1			70
1039 #define MZ2_SUPERTANK_ROCKET_2			71
1040 #define MZ2_SUPERTANK_ROCKET_3			72
1041 
1042 #define MZ2_BOSS2_MACHINEGUN_L1			73
1043 #define MZ2_BOSS2_MACHINEGUN_L2			74
1044 #define MZ2_BOSS2_MACHINEGUN_L3			75
1045 #define MZ2_BOSS2_MACHINEGUN_L4			76
1046 #define MZ2_BOSS2_MACHINEGUN_L5			77
1047 #define MZ2_BOSS2_ROCKET_1				78
1048 #define MZ2_BOSS2_ROCKET_2				79
1049 #define MZ2_BOSS2_ROCKET_3				80
1050 #define MZ2_BOSS2_ROCKET_4				81
1051 
1052 #define MZ2_FLOAT_BLASTER_1				82
1053 
1054 #define MZ2_SOLDIER_BLASTER_3			83
1055 #define MZ2_SOLDIER_SHOTGUN_3			84
1056 #define MZ2_SOLDIER_MACHINEGUN_3		85
1057 #define MZ2_SOLDIER_BLASTER_4			86
1058 #define MZ2_SOLDIER_SHOTGUN_4			87
1059 #define MZ2_SOLDIER_MACHINEGUN_4		88
1060 #define MZ2_SOLDIER_BLASTER_5			89
1061 #define MZ2_SOLDIER_SHOTGUN_5			90
1062 #define MZ2_SOLDIER_MACHINEGUN_5		91
1063 #define MZ2_SOLDIER_BLASTER_6			92
1064 #define MZ2_SOLDIER_SHOTGUN_6			93
1065 #define MZ2_SOLDIER_MACHINEGUN_6		94
1066 #define MZ2_SOLDIER_BLASTER_7			95
1067 #define MZ2_SOLDIER_SHOTGUN_7			96
1068 #define MZ2_SOLDIER_MACHINEGUN_7		97
1069 #define MZ2_SOLDIER_BLASTER_8			98
1070 #define MZ2_SOLDIER_SHOTGUN_8			99
1071 #define MZ2_SOLDIER_MACHINEGUN_8		100
1072 
1073 // --- Xian shit below ---
1074 #define	MZ2_MAKRON_BFG					101
1075 #define MZ2_MAKRON_BLASTER_1			102
1076 #define MZ2_MAKRON_BLASTER_2			103
1077 #define MZ2_MAKRON_BLASTER_3			104
1078 #define MZ2_MAKRON_BLASTER_4			105
1079 #define MZ2_MAKRON_BLASTER_5			106
1080 #define MZ2_MAKRON_BLASTER_6			107
1081 #define MZ2_MAKRON_BLASTER_7			108
1082 #define MZ2_MAKRON_BLASTER_8			109
1083 #define MZ2_MAKRON_BLASTER_9			110
1084 #define MZ2_MAKRON_BLASTER_10			111
1085 #define MZ2_MAKRON_BLASTER_11			112
1086 #define MZ2_MAKRON_BLASTER_12			113
1087 #define MZ2_MAKRON_BLASTER_13			114
1088 #define MZ2_MAKRON_BLASTER_14			115
1089 #define MZ2_MAKRON_BLASTER_15			116
1090 #define MZ2_MAKRON_BLASTER_16			117
1091 #define MZ2_MAKRON_BLASTER_17			118
1092 #define MZ2_MAKRON_RAILGUN_1			119
1093 #define	MZ2_JORG_MACHINEGUN_L1			120
1094 #define	MZ2_JORG_MACHINEGUN_L2			121
1095 #define	MZ2_JORG_MACHINEGUN_L3			122
1096 #define	MZ2_JORG_MACHINEGUN_L4			123
1097 #define	MZ2_JORG_MACHINEGUN_L5			124
1098 #define	MZ2_JORG_MACHINEGUN_L6			125
1099 #define	MZ2_JORG_MACHINEGUN_R1			126
1100 #define	MZ2_JORG_MACHINEGUN_R2			127
1101 #define	MZ2_JORG_MACHINEGUN_R3			128
1102 #define	MZ2_JORG_MACHINEGUN_R4			129
1103 #define MZ2_JORG_MACHINEGUN_R5			130
1104 #define	MZ2_JORG_MACHINEGUN_R6			131
1105 #define MZ2_JORG_BFG_1					132
1106 #define MZ2_BOSS2_MACHINEGUN_R1			133
1107 #define MZ2_BOSS2_MACHINEGUN_R2			134
1108 #define MZ2_BOSS2_MACHINEGUN_R3			135
1109 #define MZ2_BOSS2_MACHINEGUN_R4			136
1110 #define MZ2_BOSS2_MACHINEGUN_R5			137
1111 
1112 //ROGUE
1113 #define	MZ2_CARRIER_MACHINEGUN_L1		138
1114 #define	MZ2_CARRIER_MACHINEGUN_R1		139
1115 #define	MZ2_CARRIER_GRENADE				140
1116 #define MZ2_TURRET_MACHINEGUN			141
1117 #define MZ2_TURRET_ROCKET				142
1118 #define MZ2_TURRET_BLASTER				143
1119 #define MZ2_STALKER_BLASTER				144
1120 #define MZ2_DAEDALUS_BLASTER			145
1121 #define MZ2_MEDIC_BLASTER_2				146
1122 #define	MZ2_CARRIER_RAILGUN				147
1123 #define	MZ2_WIDOW_DISRUPTOR				148
1124 #define	MZ2_WIDOW_BLASTER				149
1125 #define	MZ2_WIDOW_RAIL					150
1126 #define	MZ2_WIDOW_PLASMABEAM			151		// PMM - not used
1127 #define	MZ2_CARRIER_MACHINEGUN_L2		152
1128 #define	MZ2_CARRIER_MACHINEGUN_R2		153
1129 #define	MZ2_WIDOW_RAIL_LEFT				154
1130 #define	MZ2_WIDOW_RAIL_RIGHT			155
1131 #define	MZ2_WIDOW_BLASTER_SWEEP1		156
1132 #define	MZ2_WIDOW_BLASTER_SWEEP2		157
1133 #define	MZ2_WIDOW_BLASTER_SWEEP3		158
1134 #define	MZ2_WIDOW_BLASTER_SWEEP4		159
1135 #define	MZ2_WIDOW_BLASTER_SWEEP5		160
1136 #define	MZ2_WIDOW_BLASTER_SWEEP6		161
1137 #define	MZ2_WIDOW_BLASTER_SWEEP7		162
1138 #define	MZ2_WIDOW_BLASTER_SWEEP8		163
1139 #define	MZ2_WIDOW_BLASTER_SWEEP9		164
1140 #define	MZ2_WIDOW_BLASTER_100			165
1141 #define	MZ2_WIDOW_BLASTER_90			166
1142 #define	MZ2_WIDOW_BLASTER_80			167
1143 #define	MZ2_WIDOW_BLASTER_70			168
1144 #define	MZ2_WIDOW_BLASTER_60			169
1145 #define	MZ2_WIDOW_BLASTER_50			170
1146 #define	MZ2_WIDOW_BLASTER_40			171
1147 #define	MZ2_WIDOW_BLASTER_30			172
1148 #define	MZ2_WIDOW_BLASTER_20			173
1149 #define	MZ2_WIDOW_BLASTER_10			174
1150 #define	MZ2_WIDOW_BLASTER_0				175
1151 #define	MZ2_WIDOW_BLASTER_10L			176
1152 #define	MZ2_WIDOW_BLASTER_20L			177
1153 #define	MZ2_WIDOW_BLASTER_30L			178
1154 #define	MZ2_WIDOW_BLASTER_40L			179
1155 #define	MZ2_WIDOW_BLASTER_50L			180
1156 #define	MZ2_WIDOW_BLASTER_60L			181
1157 #define	MZ2_WIDOW_BLASTER_70L			182
1158 #define	MZ2_WIDOW_RUN_1					183
1159 #define	MZ2_WIDOW_RUN_2					184
1160 #define	MZ2_WIDOW_RUN_3					185
1161 #define	MZ2_WIDOW_RUN_4					186
1162 #define	MZ2_WIDOW_RUN_5					187
1163 #define	MZ2_WIDOW_RUN_6					188
1164 #define	MZ2_WIDOW_RUN_7					189
1165 #define	MZ2_WIDOW_RUN_8					190
1166 #define	MZ2_CARRIER_ROCKET_1			191
1167 #define	MZ2_CARRIER_ROCKET_2			192
1168 #define	MZ2_CARRIER_ROCKET_3			193
1169 #define	MZ2_CARRIER_ROCKET_4			194
1170 #define	MZ2_WIDOW2_BEAMER_1				195
1171 #define	MZ2_WIDOW2_BEAMER_2				196
1172 #define	MZ2_WIDOW2_BEAMER_3				197
1173 #define	MZ2_WIDOW2_BEAMER_4				198
1174 #define	MZ2_WIDOW2_BEAMER_5				199
1175 #define	MZ2_WIDOW2_BEAM_SWEEP_1			200
1176 #define	MZ2_WIDOW2_BEAM_SWEEP_2			201
1177 #define	MZ2_WIDOW2_BEAM_SWEEP_3			202
1178 #define	MZ2_WIDOW2_BEAM_SWEEP_4			203
1179 #define	MZ2_WIDOW2_BEAM_SWEEP_5			204
1180 #define	MZ2_WIDOW2_BEAM_SWEEP_6			205
1181 #define	MZ2_WIDOW2_BEAM_SWEEP_7			206
1182 #define	MZ2_WIDOW2_BEAM_SWEEP_8			207
1183 #define	MZ2_WIDOW2_BEAM_SWEEP_9			208
1184 #define	MZ2_WIDOW2_BEAM_SWEEP_10		209
1185 #define	MZ2_WIDOW2_BEAM_SWEEP_11		210
1186 
1187 // ROGUE
1188 
1189 extern	vec3_t monster_flash_offset [];
1190 
1191 
1192 // temp entity events
1193 //
1194 // Temp entity events are for things that happen
1195 // at a location seperate from any existing entity.
1196 // Temporary entity messages are explicitly constructed
1197 // and broadcast.
1198 typedef enum
1199 {
1200 	TE_GUNSHOT,
1201 	TE_BLOOD,
1202 	TE_BLASTER,
1203 	TE_RAILTRAIL,
1204 	TE_SHOTGUN,
1205 	TE_EXPLOSION1,
1206 	TE_EXPLOSION2,
1207 	TE_ROCKET_EXPLOSION,
1208 	TE_GRENADE_EXPLOSION,
1209 	TE_SPARKS,
1210 	TE_SPLASH,
1211 	TE_BUBBLETRAIL,
1212 	TE_SCREEN_SPARKS,
1213 	TE_SHIELD_SPARKS,
1214 	TE_BULLET_SPARKS,
1215 	TE_LASER_SPARKS,
1216 	TE_PARASITE_ATTACK,
1217 	TE_ROCKET_EXPLOSION_WATER,
1218 	TE_GRENADE_EXPLOSION_WATER,
1219 	TE_MEDIC_CABLE_ATTACK,
1220 	TE_BFG_EXPLOSION,
1221 	TE_BFG_BIGEXPLOSION,
1222 	TE_BOSSTPORT,			// used as '22' in a map, so DON'T RENUMBER!!!
1223 	TE_BFG_LASER,
1224 	TE_GRAPPLE_CABLE,
1225 	TE_WELDING_SPARKS,
1226 	TE_GREENBLOOD,
1227 	TE_BLUEHYPERBLASTER,
1228 	TE_PLASMA_EXPLOSION,
1229 	TE_TUNNEL_SPARKS,
1230 //ROGUE
1231 	TE_BLASTER2,
1232 	TE_RAILTRAIL2,
1233 	TE_FLAME,
1234 	TE_LIGHTNING,
1235 	TE_DEBUGTRAIL,
1236 	TE_PLAIN_EXPLOSION,
1237 	TE_FLASHLIGHT,
1238 	TE_FORCEWALL,
1239 	TE_HEATBEAM,
1240 	TE_MONSTER_HEATBEAM,
1241 	TE_STEAM,
1242 	TE_BUBBLETRAIL2,
1243 	TE_MOREBLOOD,
1244 	TE_HEATBEAM_SPARKS,
1245 	TE_HEATBEAM_STEAM,
1246 	TE_CHAINFIST_SMOKE,
1247 	TE_ELECTRIC_SPARKS,
1248 	TE_TRACKER_EXPLOSION,
1249 	TE_TELEPORT_EFFECT,
1250 	TE_DBALL_GOAL,
1251 	TE_WIDOWBEAMOUT,
1252 	TE_NUKEBLAST,
1253 	TE_WIDOWSPLASH,
1254 	TE_EXPLOSION1_BIG,
1255 	TE_EXPLOSION1_NP,
1256 	TE_FLECHETTE
1257 //ROGUE
1258 } temp_event_t;
1259 
1260 #define SPLASH_UNKNOWN		0
1261 #define SPLASH_SPARKS		1
1262 #define SPLASH_BLUE_WATER	2
1263 #define SPLASH_BROWN_WATER	3
1264 #define SPLASH_SLIME		4
1265 #define	SPLASH_LAVA			5
1266 #define SPLASH_BLOOD		6
1267 
1268 
1269 // sound channels
1270 // channel 0 never willingly overrides
1271 // other channels (1-7) allways override a playing sound on that channel
1272 #define	CHAN_AUTO               0
1273 #define	CHAN_WEAPON             1
1274 #define	CHAN_VOICE              2
1275 #define	CHAN_ITEM               3
1276 #define	CHAN_BODY               4
1277 // modifier flags
1278 #define	CHAN_NO_PHS_ADD			8	// send to all clients, not just ones in PHS (ATTN 0 will also do this)
1279 #define	CHAN_RELIABLE			16	// send by reliable message, not datagram
1280 
1281 
1282 // sound attenuation values
1283 #define	ATTN_NONE               0	// full volume the entire level
1284 #define	ATTN_NORM               1
1285 #define	ATTN_IDLE               2
1286 #define	ATTN_STATIC             3	// diminish very rapidly with distance
1287 
1288 
1289 // player_state->stats[] indexes
1290 #define STAT_HEALTH_ICON		0
1291 #define	STAT_HEALTH				1
1292 #define	STAT_AMMO_ICON			2
1293 #define	STAT_AMMO				3
1294 #define	STAT_ARMOR_ICON			4
1295 #define	STAT_ARMOR				5
1296 #define	STAT_SELECTED_ICON		6
1297 #define	STAT_PICKUP_ICON		7
1298 #define	STAT_PICKUP_STRING		8
1299 #define	STAT_TIMER_ICON			9
1300 #define	STAT_TIMER				10
1301 #define	STAT_HELPICON			11
1302 #define	STAT_SELECTED_ITEM		12
1303 #define	STAT_LAYOUTS			13
1304 #define	STAT_FRAGS				14
1305 #define	STAT_FLASHES			15		// cleared each frame, 1 = health, 2 = armor
1306 #define STAT_CHASE				16
1307 #define STAT_SPECTATOR			17
1308 
1309 #define	MAX_STATS				32
1310 
1311 
1312 // dmflags->value flags
1313 #define	DF_NO_HEALTH		0x00000001	// 1
1314 #define	DF_NO_ITEMS			0x00000002	// 2
1315 #define	DF_WEAPONS_STAY		0x00000004	// 4
1316 #define	DF_NO_FALLING		0x00000008	// 8
1317 #define	DF_INSTANT_ITEMS	0x00000010	// 16
1318 #define	DF_SAME_LEVEL		0x00000020	// 32
1319 #define DF_SKINTEAMS		0x00000040	// 64
1320 #define DF_MODELTEAMS		0x00000080	// 128
1321 #define DF_NO_FRIENDLY_FIRE	0x00000100	// 256
1322 #define	DF_SPAWN_FARTHEST	0x00000200	// 512
1323 #define DF_FORCE_RESPAWN	0x00000400	// 1024
1324 #define DF_NO_ARMOR			0x00000800	// 2048
1325 #define DF_ALLOW_EXIT		0x00001000	// 4096
1326 #define DF_INFINITE_AMMO	0x00002000	// 8192
1327 #define DF_QUAD_DROP		0x00004000	// 16384
1328 #define DF_FIXED_FOV		0x00008000	// 32768
1329 
1330 // RAFAEL
1331 #define	DF_QUADFIRE_DROP	0x00010000	// 65536
1332 
1333 //ROGUE
1334 #define DF_NO_MINES			0x00020000
1335 #define DF_NO_STACK_DOUBLE	0x00040000
1336 #define DF_NO_NUKES			0x00080000
1337 #define DF_NO_SPHERES		0x00100000
1338 //ROGUE
1339 
1340 /*
1341 ROGUE - VERSIONS
1342 1234	08/13/1998		Activision
1343 1235	08/14/1998		Id Software
1344 1236	08/15/1998		Steve Tietze
1345 1237	08/15/1998		Phil Dobranski
1346 1238	08/15/1998		John Sheley
1347 1239	08/17/1998		Barrett Alexander
1348 1230	08/17/1998		Brandon Fish
1349 1245	08/17/1998		Don MacAskill
1350 1246	08/17/1998		David "Zoid" Kirsch
1351 1247	08/17/1998		Manu Smith
1352 1248	08/17/1998		Geoff Scully
1353 1249	08/17/1998		Andy Van Fossen
1354 1240	08/20/1998		Activision Build 2
1355 1256	08/20/1998		Ranger Clan
1356 1257	08/20/1998		Ensemble Studios
1357 1258	08/21/1998		Robert Duffy
1358 1259	08/21/1998		Stephen Seachord
1359 1250	08/21/1998		Stephen Heaslip
1360 1267	08/21/1998		Samir Sandesara
1361 1268	08/21/1998		Oliver Wyman
1362 1269	08/21/1998		Steven Marchegiano
1363 1260	08/21/1998		Build #2 for Nihilistic
1364 1278	08/21/1998		Build #2 for Ensemble
1365 
1366 9999	08/20/1998		Internal Use
1367 */
1368 #define ROGUE_VERSION_ID		1278
1369 
1370 #define ROGUE_VERSION_STRING	"08/21/1998 Beta 2 for Ensemble"
1371 
1372 // ROGUE
1373 /*
1374 ==========================================================
1375 
1376   ELEMENTS COMMUNICATED ACROSS THE NET
1377 
1378 ==========================================================
1379 */
1380 
1381 #define	ANGLE2SHORT(x)	((int)((x)*65536/360) & 65535)
1382 #define	SHORT2ANGLE(x)	((x)*(360.0/65536))
1383 
1384 
1385 //
1386 // config strings are a general means of communication from
1387 // the server to all connected clients.
1388 // Each config string can be at most MAX_QPATH characters.
1389 //
1390 #define	CS_NAME				0
1391 #define	CS_CDTRACK			1
1392 #define	CS_SKY				2
1393 #define	CS_SKYAXIS			3		// %f %f %f format
1394 #define	CS_SKYROTATE		4
1395 #define	CS_STATUSBAR		5		// display program string
1396 
1397 #define CS_AIRACCEL			29		// air acceleration control
1398 #define	CS_MAXCLIENTS		30
1399 #define	CS_MAPCHECKSUM		31		// for catching cheater maps
1400 
1401 #define	CS_MODELS			32
1402 #define	CS_SOUNDS			(CS_MODELS+MAX_MODELS)
1403 #define	CS_IMAGES			(CS_SOUNDS+MAX_SOUNDS)
1404 #define	CS_LIGHTS			(CS_IMAGES+MAX_IMAGES)
1405 #define	CS_ITEMS			(CS_LIGHTS+MAX_LIGHTSTYLES)
1406 #define	CS_PLAYERSKINS		(CS_ITEMS+MAX_ITEMS)
1407 #define CS_GENERAL			(CS_PLAYERSKINS+MAX_CLIENTS)
1408 #define	MAX_CONFIGSTRINGS	(CS_GENERAL+MAX_GENERAL)
1409 
1410 
1411 //==============================================
1412 
1413 
1414 // entity_state_t->event values
1415 // ertity events are for effects that take place reletive
1416 // to an existing entities origin.  Very network efficient.
1417 // All muzzle flashes really should be converted to events...
1418 typedef enum
1419 {
1420 	EV_NONE,
1421 	EV_ITEM_RESPAWN,
1422 	EV_FOOTSTEP,
1423 	EV_FALLSHORT,
1424 	EV_FALL,
1425 	EV_FALLFAR,
1426 	EV_PLAYER_TELEPORT,
1427 	EV_OTHER_TELEPORT
1428 } entity_event_t;
1429 
1430 
1431 // entity_state_t is the information conveyed from the server
1432 // in an update message about entities that the client will
1433 // need to render in some way
1434 typedef struct entity_state_s
1435 {
1436 	int		number;			// edict index
1437 
1438 	vec3_t	origin;
1439 	vec3_t	angles;
1440 	vec3_t	old_origin;		// for lerping
1441 	int		modelindex;
1442 	int		modelindex2, modelindex3, modelindex4;	// weapons, CTF flags, etc
1443 	int		frame;
1444 	int		skinnum;
1445 	unsigned int		effects;		// PGM - we're filling it, so it needs to be unsigned
1446 	int		renderfx;
1447 	int		solid;			// for client side prediction, 8*(bits 0-4) is x/y radius
1448 							// 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
1449 							// gi.linkentity sets this properly
1450 	int		sound;			// for looping sounds, to guarantee shutoff
1451 	int		event;			// impulse events -- muzzle flashes, footsteps, etc
1452 							// events only go out for a single frame, they
1453 							// are automatically cleared each frame
1454 } entity_state_t;
1455 
1456 //==============================================
1457 
1458 
1459 // player_state_t is the information needed in addition to pmove_state_t
1460 // to rendered a view.  There will only be 10 player_state_t sent each second,
1461 // but the number of pmove_state_t changes will be reletive to client
1462 // frame rates
1463 typedef struct
1464 {
1465 	pmove_state_t	pmove;		// for prediction
1466 
1467 	// these fields do not need to be communicated bit-precise
1468 
1469 	vec3_t		viewangles;		// for fixed views
1470 	vec3_t		viewoffset;		// add to pmovestate->origin
1471 	vec3_t		kick_angles;	// add to view direction to get render angles
1472 								// set by weapon kicks, pain effects, etc
1473 
1474 	vec3_t		gunangles;
1475 	vec3_t		gunoffset;
1476 	int			gunindex;
1477 	int			gunframe;
1478 
1479 	float		blend[4];		// rgba full screen effect
1480 
1481 	float		fov;			// horizontal field of view
1482 
1483 	int			rdflags;		// refdef flags
1484 
1485 	short		stats[MAX_STATS];		// fast status bar updates
1486 } player_state_t;
1487 
1488 
1489 
1490