OpenMoHAA 0.83.0
Loading...
Searching...
No Matches
q_shared.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4
5This file is part of Quake III Arena source code.
6
7Quake III Arena source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12Quake III Arena source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with Quake III Arena source code; if not, write to the Free Software
19Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20===========================================================================
21*/
22
23// q_shared.h -- included first by ALL program modules.
24// A user mod should never modify this file
25
26#pragma once
27
28#if defined(__cplusplus)
29extern "C" {
30#endif
31
32#define PRODUCT_NAME "OpenMoHAA"
33#define PRODUCT_DATE __DATE__
34
35#define BASEGAME "main"
36// We're always legacy
37#define LEGACY_PROTOCOL
38
39#define GAME_EXTENSION_MOH "main"
40#define PRODUCT_EXTENSION_MOH "Allied Assault"
41#define TARGET_GAME_VERSION_MOH "1.12"
42#define TARGET_GAME_PROTOCOL_DEMO_MOH 6
43#define TARGET_GAME_PROTOCOL_MOH 8
44#define TARGET_GAME_NAME_MOH "mohaa"
45
46#define HOMEPATH_NAME_UNIX_MOH ".moh"
47#define HOMEPATH_NAME_WIN_MOH "moh"
48#define HOMEPATH_NAME_MACOSX_MOH HOMEPATH_NAME_WIN_MOH
49
50#define GAME_EXTENSION_MOHTA "mainta"
51#define PRODUCT_EXTENSION_MOHTA "Spearhead"
52#define TARGET_GAME_VERSION_MOHTA "2.16"
53#define TARGET_GAME_PROTOCOL_MIN_MOHTA 16
54#define TARGET_GAME_PROTOCOL_MOHTA 17
55#define TARGET_GAME_NAME_MOHTA "mohaas"
56
57#define HOMEPATH_NAME_UNIX_MOHTA ".mohta"
58#define HOMEPATH_NAME_WIN_MOHTA "mohta"
59#define HOMEPATH_NAME_MACOSX_MOHTA HOMEPATH_NAME_WIN_MOHTA
60
61#define GAME_EXTENSION_BASE_MOHTT "maintt"
62#define PRODUCT_EXTENSION_MOHTT "Breakthrough"
63// The version string must be equal or above 2.0 to be able to connect to breakthrough servers
64#define TARGET_GAME_VERSION_MOHTT "2.41"
65#define TARGET_GAME_VERSION_MOHTT_DEMO "0.31"
66#define TARGET_GAME_PROTOCOL_MIN_MOHTT 16
67#define TARGET_GAME_PROTOCOL_MOHTT 17
68#define TARGET_GAME_NAME_MOHTT "mohaab"
69
70#define HOMEPATH_NAME_UNIX_MOHTT ".mohtt"
71#define HOMEPATH_NAME_WIN_MOHTT "mohtt"
72#define HOMEPATH_NAME_MACOSX_MOHTT HOMEPATH_NAME_WIN_MOHTT
73
74//
75// The target type specifies which content pack the engine targets.
76//
77// Note: An universal client is not currently possible without refactoring the network and the file system.
78// Pak files must be reloaded on-the-fly depending on the server the client is connecting to.
79//
80#define HOMEPATH_NAME_UNIX ".openmohaa"
81#define HOMEPATH_NAME_WIN "openmohaa"
82#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
83
84#define CLIENT_WINDOW_TITLE PRODUCT_NAME
85#define CLIENT_WINDOW_MIN_TITLE PRODUCT_NAME
86
87#define MAX_MASTER_SERVERS 5 // number of supported master servers
88
89#define DEMOEXT "dm_" // standard demo extension
90
91#ifdef _MSC_VER
92
93#pragma warning(disable : 4018) // signed/unsigned mismatch
94#pragma warning(disable : 4032)
95#pragma warning(disable : 4051)
96#pragma warning(disable : 4057) // slightly different base types
97#pragma warning(disable : 4100) // unreferenced formal parameter
98#pragma warning(disable : 4115)
99#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence
100#pragma warning(disable : 4127) // conditional expression is constant
101#pragma warning(disable : 4136)
102#pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression
103//#pragma warning(disable : 4201)
104//#pragma warning(disable : 4214)
105#pragma warning(disable : 4244)
106#pragma warning(disable : 4142) // benign redefinition
107//#pragma warning(disable : 4305) // truncation from const double to float
108//#pragma warning(disable : 4310) // cast truncates constant value
109//#pragma warning(disable: 4505) // unreferenced local function has been removed
110#pragma warning(disable : 4514)
111#pragma warning(disable : 4702) // unreachable code
112#pragma warning(disable : 4711) // selected for automatic inline expansion
113#pragma warning(disable : 4220) // varargs matches remaining parameters
114//#pragma intrinsic( memset, memcpy )
115#endif
116
117#ifdef __GNUC__
118#define Q_UNUSED_VAR __attribute__((unused))
119#define Q_NO_RETURN __attribute__((noreturn))
120
121#ifdef __MINGW32__
122// For some reason MinGW wants both gnu_printf and ms_printf
123#define Q_PRINTF_FUNC(fmt, va) \
124 __attribute__((format(gnu_printf, fmt, va))) \
125 __attribute__((format(ms_printf, fmt, va)))
126#else
127#define Q_PRINTF_FUNC(fmt, va) __attribute__((format(printf, fmt, va)))
128#endif
129
130#define Q_SCANF_FUNC(fmt, va) __attribute__((format(scanf, fmt, va)))
131#define Q_ALIGN(x) __attribute__((aligned(x)))
132#else
133#define Q_UNUSED_VAR
134#define Q_NO_RETURN
135#define Q_PRINTF_FUNC(fmt, va)
136#define Q_SCANF_FUNC(fmt, va)
137#define Q_ALIGN(x)
138#endif
139
140#if (defined _MSC_VER)
141#define Q_EXPORT __declspec(dllexport)
142#elif (defined __SUNPRO_C)
143#define Q_EXPORT __global
144#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
145#define Q_EXPORT __attribute__((visibility("default")))
146#else
147#define Q_EXPORT
148#endif
149
150/**********************************************************************
151 VM Considerations
152
153 The VM can not use the standard system headers because we aren't really
154 using the compiler they were meant for. We use bg_lib.h which contains
155 prototypes for the functions we define for our own use in bg_lib.c.
156
157 When writing mods, please add needed headers HERE, do not start including
158 stuff like <stdio.h> in the various .c files that make up each of the VMs
159 since you will be including system headers files can will have issues.
160
161 Remember, if you use a C library function that is not defined in bg_lib.c,
162 you will have to add your own version for support in the VM.
163
164 **********************************************************************/
165
166#ifndef Q3_VM
167
168#ifdef _DEBUG_MEM
169# ifdef WIN32
170# define _CRTDBG_MAP_ALLOC
171# include <stdlib.h>
172# include <crtdbg.h>
173# endif
174#endif
175
176#include <assert.h>
177#include <math.h>
178#include <stdio.h>
179#include <stdarg.h>
180#include <string.h>
181#include <stdlib.h>
182#include <time.h>
183#include <ctype.h>
184#include <limits.h>
185#include <stdint.h>
186
187#ifdef _WIN32
188 // vsnprintf is ISO/IEC 9899:1999
189 // abstracting this to make it portable
190 size_t Q_vsnprintf(char *str, size_t size, const char *format, va_list ap) Q_PRINTF_FUNC(3, 0);
191#else
192#define Q_vsnprintf vsnprintf
193#endif
194
195#endif
196
197#include "q_platform.h"
198
199//=============================================================
200
201typedef unsigned char byte;
202typedef unsigned char uchar;
203
204enum { qfalse, qtrue };
205
206typedef union {
207 float f;
208 int i;
209 unsigned int ui;
210} floatint_t;
211
212typedef int qboolean;
213
214typedef int qhandle_t;
215typedef int sfxHandle_t;
216typedef int fileHandle_t;
217typedef int clipHandle_t;
218
219#ifdef __GNUC__
220#define ALIGN(x) __attribute__((aligned(x)))
221#else
222#define ALIGN(x)
223#endif
224
225#define PAD(base, alignment) (((base)+(alignment)-1) & ~((alignment)-1))
226#define PADLEN(base, alignment) (PAD((base), (alignment)) - (base))
227
228#define PADP(base, alignment) ((void *) PAD((intptr_t) (base), (alignment)))
229
230#ifndef NULL
231#define NULL ((void *)0)
232#endif
233
234#ifndef BIT
235#define BIT(x) (1 << x)
236#endif
237
238#define STRING(s) #s
239// expand constants before stringifying them
240#define XSTRING(s) STRING(s)
241
242#define MAX_QINT 0x7fffffff
243#define MIN_QINT (-MAX_QINT-1)
244
245#define ARRAY_LEN(x) (sizeof(x) / sizeof(*(x)))
246#define STRARRAY_LEN(x) (ARRAY_LEN(x) - 1)
247
248// angle indexes
249#define PITCH 0 // up / down
250#define YAW 1 // left / right
251#define ROLL 2 // fall over
252
253#ifndef WIN32
254#define stricmp strcasecmp
255#define strnicmp strncasecmp
256#endif
257
258typedef enum {
259 TG_MOH,
260 TG_MOHTA,
261 TG_MOHTT,
262 TG_INVALID
263} target_game_e;
264
265typedef enum {
266 PROTOCOL_MOH_MIN = 6,
267 PROTOCOL_MOH_DEMO = 6,
268 PROTOCOL_MOH = 8,
269 PROTOCOL_MOHTA_MIN = 15,
270 PROTOCOL_MOHTA_DEMO = 16,
271 PROTOCOL_MOHTA = 17,
272} protocol_e;
273
274// plane sides
275typedef enum
276{
277 SIDE_FRONT = 0,
278 SIDE_BACK = 1,
279 SIDE_ON = 2,
280 SIDE_CROSS = 3
281} planeSide_t;
282
283typedef enum
284{
285 SOLID_NOT, // no interaction with other objects
286 SOLID_TRIGGER, // only touch when inside, after moving
287 SOLID_BBOX, // touch on edge
288 SOLID_BSP // bsp clip, touch on edge
289} solid_t;
290
291// the game guarantees that no string from the network will ever
292// exceed MAX_STRING_CHARS
293#define MAX_STRING_CHARS 2048 // max length of a string passed to Cmd_TokenizeString
294#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString
295#define MAX_TOKEN_CHARS 1024 // max length of an individual token
296
297#define MAX_INFO_STRING 1350
298#define MAX_INFO_KEY 1024
299#define MAX_INFO_VALUE 1024
300
301#define BIG_INFO_STRING 8192 // used for system info key only
302#define BIG_INFO_KEY 8192
303#define BIG_INFO_VALUE 8192
304
305#define MAX_RES_NAME 64
306
307#define MAX_QPATH 256 // max length of a quake game pathname
308#ifdef PATH_MAX
309#define MAX_OSPATH PATH_MAX
310#else
311#define MAX_OSPATH 256 // max length of a filesystem pathname
312#endif
313
314#define MAX_NAME_LENGTH 32 // max length of a client name
315
316// paramters for command buffer stuffing
317typedef enum {
318 EXEC_NOW, // don't return until completed, a VM should NEVER use this,
319 // because some commands might cause the VM to be unloaded...
320 EXEC_INSERT, // insert at current position, but don't run yet
321 EXEC_APPEND // add to end of the command buffer (normal case)
322} cbufExec_t;
323
324
325//
326// these aren't needed by any of the VMs. put in another header?
327//
328#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility
329
330
331// print levels from renderer (FIXME: set up for game / cgame?)
332typedef enum {
333 PRINT_ALL,
334 PRINT_DEVELOPER, // only print when "developer 1"
335 PRINT_DEVELOPER_2, // print when "developer 2"
336 PRINT_WARNING,
337 PRINT_ERROR
338} printParm_t;
339
340
341#ifdef ERR_FATAL
342#undef ERR_FATAL // this is be defined in malloc.h
343#endif
344
345// parameters to the main Error routine
346typedef enum {
347 ERR_FATAL, // exit the entire game with a popup window
348 ERR_DROP, // print to console and disconnect from game
349 ERR_SERVERDISCONNECT, // don't kill server
350 ERR_DISCONNECT, // client disconnected from the server
351 ERR_NEED_CD // pop up the need-cd dialog
352} errorParm_t;
353
354
355// font rendering values used by ui and cgame
356
357#define PROP_GAP_WIDTH 5
358#define PROP_SPACE_WIDTH 8
359#define PROP_HEIGHT 30
360#define PROP_SMALL_SIZE_SCALE 0.75
361
362#define BLINK_DIVISOR 200
363#define PULSE_DIVISOR 250.0f
364
365#define UI_LEFT 0x00000000 // default
366#define UI_CENTER 0x00000001
367#define UI_RIGHT 0x00000002
368#define UI_FORMATMASK 0x00000007
369#define UI_SMALLFONT 0x00000010
370#define UI_BIGFONT 0x00000020 // default
371#define UI_GIANTFONT 0x00000040
372#define UI_DROPSHADOW 0x00000800
373#define UI_BLINK 0x00001000
374#define UI_INVERSE 0x00002000
375#define UI_PULSE 0x00004000
376
377typedef enum {
378 h_high,
379 h_low,
380 h_dontcare
381} ha_pref;
382
383#ifdef HUNK_DEBUG
384#define Hunk_Alloc( size, preference ) Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__)
385void *Hunk_AllocDebug( int size, ha_pref preference, const char *label, const char *file, int line );
386#else
387void *Hunk_Alloc( int size, ha_pref preference );
388#endif
389
390#define Com_Memset memset
391#define Com_Memcpy memcpy
392
393#define Com_Allocate malloc
394#define Com_Dealloc free
395
396#define CIN_system 1
397#define CIN_loop 2
398#define CIN_hold 4
399#define CIN_silent 8
400#define CIN_shader 16
401
402/*
403==============================================================
404
405MATHLIB
406
407==============================================================
408*/
409
410
411typedef float vec_t;
412typedef vec_t vec2_t[2];
413typedef vec_t vec3_t[3];
414typedef vec_t vec4_t[4];
415typedef vec_t quat_t[4]; // | x y z w |
416typedef vec_t vec5_t[5];
417typedef vec_t matrix3x3_t[9];
418typedef vec_t matrix_t[16];
419typedef vec3_t axis_t[3];
420
421typedef int fixed4_t;
422typedef int fixed8_t;
423typedef int fixed16_t;
424
425#ifndef M_PI
426#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h
427#endif
428
429#ifndef M_SQRT2
430#define M_SQRT2 1.414213562f
431#endif
432
433#ifndef M_SQRT1_2
434#define M_SQRT1_2 7.0710678118654752440E-1
435#endif
436
437#define NUMVERTEXNORMALS 162
438extern vec3_t bytedirs[NUMVERTEXNORMALS];
439
440// all drawing is done to a 640*480 virtual screen size
441// and will be automatically scaled to the real resolution
442#define SCREEN_WIDTH 640
443#define SCREEN_HEIGHT 480
444
445#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH)
446#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2)
447
448#define SMALLCHAR_WIDTH 8
449#define SMALLCHAR_HEIGHT 16
450
451#define BIGCHAR_WIDTH 16
452#define BIGCHAR_HEIGHT 16
453
454#define GIANTCHAR_WIDTH 32
455#define GIANTCHAR_HEIGHT 48
456
457extern vec4_t colorBlack;
458extern vec4_t colorRed;
459extern vec4_t colorGreen;
460extern vec4_t colorBlue;
461extern vec4_t colorYellow;
462extern vec4_t colorMagenta;
463extern vec4_t colorCyan;
464extern vec4_t colorWhite;
465extern vec4_t colorLtGrey;
466extern vec4_t colorMdGrey;
467extern vec4_t colorDkGrey;
468
469enum {
470 MESSAGE_YELLOW = 1,
471 MESSAGE_CHAT_WHITE,
472 MESSAGE_WHITE,
473 MESSAGE_CHAT_RED,
474 MESSAGE_CHAT_GREEN,
475 MESSAGE_MAX
476};
477
478#define Q_COLOR_ESCAPE '^'
479#define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && isalnum(*((p)+1)) ) // ^[0-9a-zA-Z]
480
481#define COLOR_BLACK '0'
482#define COLOR_RED '1'
483#define COLOR_GREEN '2'
484#define COLOR_YELLOW '3'
485#define COLOR_BLUE '4'
486#define COLOR_CYAN '5'
487#define COLOR_MAGENTA '6'
488#define COLOR_WHITE '7'
489#define ColorIndex(c) ( ( (c) - '0' ) & 7 )
490
491#if 0
492#define S_COLOR_BLACK "^0"
493#define S_COLOR_RED "^1"
494#define S_COLOR_GREEN "^2"
495#define S_COLOR_YELLOW "^3"
496#define S_COLOR_BLUE "^4"
497#define S_COLOR_CYAN "^5"
498#define S_COLOR_MAGENTA "^6"
499#define S_COLOR_WHITE "^7"
500#else
501#define S_COLOR_BLACK ""
502#define S_COLOR_RED ""
503#define S_COLOR_GREEN ""
504#define S_COLOR_YELLOW ""
505#define S_COLOR_BLUE ""
506#define S_COLOR_CYAN ""
507#define S_COLOR_MAGENTA ""
508#define S_COLOR_WHITE ""
509#endif
510
511#define HUD_MESSAGE_YELLOW "\x01"
512#define HUD_MESSAGE_WHITE "\x03"
513#define HUD_MESSAGE_CHAT_WHITE "\x02"
514#define HUD_MESSAGE_CHAT_RED "\x04"
515
516extern vec4_t g_color_table[8];
517
518#define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b
519#define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a
520
521#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )
522#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )
523
524#define Q_max(a, b) ((a) > (b) ? (a) : (b))
525#define Q_min(a, b) ((a) < (b) ? (a) : (b))
526#define Q_bound(a, b, c) (Q_max(a, Q_min(b, c)))
527#define Q_clamp(a, b, c) ((b) >= (c) ? (a)=(b) : (a) < (b) ? (a)=(b) : (a) > (c) ? (a)=(c) : (a))
528#define Q_lerp(from, to, frac) (from + ((to - from) * frac))
529
530#define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) )
531#define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) )
532
533#ifndef Q_min
534#define Q_min(a,b) (((a) < (b)) ? (a) : (b))
535#endif
536#ifndef Q_max
537#define Q_max(a,b) (((a) > (b)) ? (a) : (b))
538#endif
539
540int Q_clamp_int(int value, int min, int max);
541float Q_clamp_float(float value, float min, float max);
542
543#define bound(a,minval,maxval) ( ((a) > (minval)) ? ( ((a) < (maxval)) ? (a) : (maxval) ) : (minval) )
544
545struct cplane_s;
546
547extern vec3_t vec3_origin;
548extern vec3_t axisDefault[3];
549extern matrix_t matrixIdentity;
550
551#define nanmask (255<<23)
552
553#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
554
555static ID_INLINE long Q_ftol(float f)
556{
557#if id386_sse && defined(_MSC_VER)
558 static int tmp;
559 __asm fld f
560 __asm fistp tmp
561 __asm mov eax, tmp
562#else
563 return (long)f;
564#endif
565}
566
567#if idppc
568
569static ID_INLINE float Q_rsqrt( float number ) {
570 float x = 0.5f * number;
571 float y;
572#ifdef __GNUC__
573 asm("frsqrte %0,%1" : "=f" (y) : "f" (number));
574#else
575 y = __frsqrte( number );
576#endif
577 return y * (1.5f - (x * y * y));
578 }
579
580#ifdef __GNUC__
581static ID_INLINE float Q_fabs(float x) {
582 float abs_x;
583
584 asm("fabs %0,%1" : "=f" (abs_x) : "f" (x));
585 return abs_x;
586}
587#else
588#define Q_fabs __fabsf
589#endif
590
591#else
592float Q_fabs( float f );
593float Q_rsqrt( float f ); // reciprocal square root
594#endif
595
596#define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) )
597
598byte ClampByte(int i);
599signed char ClampChar( int i );
600signed short ClampShort( int i );
601
602double dEpsilon( void );
603double dIdentity( void );
604double dSign( const double number );
605double dClamp( const double value, const double min, const double max );
606double dDistance( const double value1, const double value2 );
607qboolean dCloseEnough( const double value1, const double value2, const double epsilon );
608qboolean dSmallEnough( const double value, const double epsilon );
609
610float fEpsilon( void );
611float fIdentity( void );
612float fSign( const float number );
613float fClamp( const float value, const float min, const float max );
614float fDistance( const float value1, const float value2 );
615qboolean fCloseEnough( const float value1, const float value2, const float epsilon );
616qboolean fSmallEnough( const float value, const float epsilon );
617
618int iSign( const int number );
619int iClamp( const int value, const int min, const int max );
620
621// this isn't a real cheap function to call!
622int DirToByte( vec3_t dir );
623void ByteToDir( int b, vec3_t dir );
624
625#if 1
626
627#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
628#define DotProduct2D(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1])
629#define CrossProduct2D(a,b) ((a)[0]*(b)[1]-(b)[0]*(a)[1])
630#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
631#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
632#define VectorAdd2D(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1])
633#define VectorSub2D(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1])
634#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
635#define VectorCopy2D(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1])
636#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
637#define VectorScale2D(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s))
638#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
639#define VectorMA2D(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s))
640
641#else
642
643#define DotProduct(x,y) _DotProduct(x,y)
644#define VectorSubtract(a,b,c) _VectorSubtract(a,b,c)
645#define VectorAdd(a,b,c) _VectorAdd(a,b,c)
646#define VectorCopy(a,b) _VectorCopy(a,b)
647#define VectorScale(v, s, o) _VectorScale(v,s,o)
648#define VectorMA(v, s, b, o) _VectorMA(v,s,b,o)
649
650#endif
651
652#ifdef Q3_VM
653#ifdef VectorCopy
654#undef VectorCopy
655// this is a little hack to get more efficient copies in our interpreter
656typedef struct {
657 float v[3];
658} vec3struct_t;
659#define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a)
660#endif
661#endif
662
663#define VectorClear2D(a) ((a)[0]=(a)[1]=0)
664#define VectorLength2DSquared(a) ((a)[0]*(a)[0]+(a)[1]*(a)[1])
665#define VectorLength2D(a) (sqrt(VectorLength2DSquared(a)))
666#define VectorSet2D(v, x, y) ((v)[0]=(x), (v)[1]=(y))
667
668#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0)
669#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
670#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
671#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
672
673#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));}
674
675#define DotProduct4(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])
676#define VectorSubtract4(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])
677#define VectorAdd4(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])
678#define VectorCopy4(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
679#define VectorScale4(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s),(o)[3]=(v)[3]*(s))
680#define VectorMA4(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s))
681#define VectorClear4(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0)
682#define VectorNegate4(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3])
683#define VectorSet4(v,x,y,z,w) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z),(v)[3]=(w))
684
685#define VectorCopy5(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3],(b)[4]=(a)[4])
686
687// just in case you do't want to use the macros
688vec_t _DotProduct( const vec3_t v1, const vec3_t v2 );
689void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out );
690void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out );
691void _VectorCopy( const vec3_t in, vec3_t out );
692void _VectorScale( const vec3_t in, float scale, vec3_t out );
693void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc );
694vec_t Q_rint( vec_t in );
695
696unsigned ColorBytes3 (float r, float g, float b);
697unsigned ColorBytes4 (float r, float g, float b, float a);
698
699float NormalizeColor( const vec3_t in, vec3_t out );
700void RotatePointAroundAxis(vec3_t dst, int axis, const vec3_t point, float degrees);
701void ClampColor(vec4_t color);
702
703float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
704void ClearBounds( vec3_t mins, vec3_t maxs );
705void ZeroBounds(vec3_t mins, vec3_t maxs);
706void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
707void BoundsAdd(vec3_t mins, vec3_t maxs, const vec3_t mins2, const vec3_t maxs2);
708
709float PointToSegmentDistanceSquared(const vec3_t origin, const vec3_t a, const vec3_t b);
710
711#if !defined( Q3_VM ) || ( defined( Q3_VM ) && defined( __Q3_VM_MATH ) )
712static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
713 if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
714 return 0;
715 }
716 return 1;
717}
718
719static ID_INLINE int VectorCompare2D( const vec2_t v1, const vec2_t v2 ) {
720 if( v1[ 0 ] != v2[ 0 ] || v1[ 1 ] != v2[ 1 ] ) {
721 return 0;
722 }
723 return 1;
724}
725
726static ID_INLINE int VectorCompareEpsilon( const vec3_t v1, const vec3_t v2, float fEpsilon )
727{
728 int i;
729
730 for( i = 0; i < 3; i++ )
731 {
732 if( fabs( v1[ i ] - v2[ i ] ) > fEpsilon ) {
733 return 0;
734 }
735 }
736 return 1;
737}
738
739static ID_INLINE vec_t VectorLength( const vec3_t v ) {
740 return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
741}
742
743static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {
744 return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
745}
746
747static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
748 vec3_t v;
749
750 VectorSubtract (p2, p1, v);
751 return VectorLength( v );
752}
753
754static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
755 vec3_t v;
756
757 VectorSubtract (p2, p1, v);
758 return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
759}
760
761// fast vector normalize routine that does not check to make sure
762// that length != 0, nor does it return length, uses rsqrt approximation
763static ID_INLINE void VectorNormalizeFast( vec3_t v )
764{
765 float ilength;
766
767 ilength = Q_rsqrt( DotProduct( v, v ) );
768
769 v[0] *= ilength;
770 v[1] *= ilength;
771 v[2] *= ilength;
772}
773
774static ID_INLINE void VectorInverse( vec3_t v ){
775 v[0] = -v[0];
776 v[1] = -v[1];
777 v[2] = -v[2];
778}
779
780static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {
781 cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
782 cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
783 cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
784}
785
786#else
787int VectorCompare( const vec3_t v1, const vec3_t v2 );
788
789vec_t VectorLength( const vec3_t v );
790
791vec_t VectorLengthSquared( const vec3_t v );
792
793vec_t Distance( const vec3_t p1, const vec3_t p2 );
794
795vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
796
797void VectorNormalizeFast( vec3_t v );
798
799void VectorInverse( vec3_t v );
800
801void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );
802
803#endif
804
805vec_t VectorNormalize (vec3_t v); // returns vector length
806vec_t VectorNormalize2( const vec3_t v, vec3_t out );
807vec_t VectorNormalize2D( vec2_t v );
808vec_t VectorNormalize2D2( const vec2_t v, vec2_t out );
809void VectorPackTo01( vec3_t v );
810void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out );
811void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out );
812
813int NearestPowerOfTwo(int val);
814int Q_log2(int val);
815
816float Q_acos(float c);
817
818int Q_rand( int *seed );
819float Q_random( int *seed );
820float Q_crandom( int *seed );
821
822#define random() ((rand () & 0x7fff) / ((float)0x7fff))
823#define random2() ((rand () & 0x7fff) * (1.0 / ((float)0x7fff)))
824#define crandom() (2.0 * (random() - 0.5))
825
826float grandom( void );
827float erandom( float mean );
828
829#define AnglesToMat AnglesToAxis
830
831void vectoangles( const vec3_t value1, vec3_t angles );
832void VectorToAngles( const vec3_t vec, vec3_t angles );
833void AnglesToAxis(const vec3_t angles, vec3_t axis[3]);
834void YawToAxis(float yaw, float axis[2]);
835
836float noise(float vec[], int len);
837float noise1(float arg);
838float noise2(vec3_t arg);
839float noise3(vec3_t arg);
840
841void R_ConcatRotations( float in1[ 3 ][ 3 ], float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
842void R_ConcatTransforms( float in1[ 3 ][ 4 ], float in2[ 3 ][ 4 ], float out[ 3 ][ 4 ] );
843
844void MatrixToEulerAngles( const float mat[ 3 ][ 3 ], vec3_t ang );
845void QuatToMat( const float q[ 4 ], float m[ 3 ][ 3 ] );
846void SlerpQuaternion(float from[4], float to[4], float t, float res[4]);
847void EulerToQuat( float ang[ 3 ], float q[ 4 ] );
848void MatToQuat( float srcMatrix[ 3 ][ 3 ], float destQuat[ 4 ] );
849
850float ProjectPointOnLine( const vec3_t i_vStart, const vec3_t i_vEnd, const vec3_t i_vPoint, vec3_t o_vProj );
851float ProjectLineOnPlane(const vec3_t vPlaneNorm, float fPlaneDist, const vec3_t vStart, const vec3_t vEnd, vec3_t vProj );
852
853float anglemod( float a );
854float angledist( float ang );
855
856void AxisClear( vec3_t axis[3] );
857void AxisCopy( const vec3_t in[3], vec3_t out[3] );
858
859void SetPlaneSignbits( struct cplane_s *out );
860int BoxOnPlaneSide (const vec3_t emins, const vec3_t emaxs, struct cplane_s *plane);
861
862void CalculateRotatedBounds( vec3_t angles, vec3_t mins, vec3_t maxs );
863void CalculateRotatedBounds2( float trans[ 3 ][ 3 ], vec3_t mins, vec3_t maxs );
864int BoundingBoxToInteger( vec3_t mins, vec3_t maxs );
865void IntegerToBoundingBox( int num, vec3_t mins, vec3_t maxs );
866qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs,
867 const vec3_t mins2, const vec3_t maxs2);
868qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs,
869 const vec3_t origin, vec_t radius);
870qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs,
871 const vec3_t origin);
872
873float AngleMod(float a);
874float LerpAngle (float from, float to, float frac);
875float LerpAngleFromCurrent( float from, float to, float current, float frac );
876float AngleSubtract( float a1, float a2 );
877void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 );
878
879float AngleNormalize360 ( float angle );
880float AngleNormalize180 ( float angle );
881float AngleDelta ( float angle1, float angle2 );
882
883qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
884qboolean PlanesGetIntersectionPoint(const vec4_t plane1, const vec4_t plane2, const vec4_t plane3, vec3_t out);
885void PlaneIntersectRay(const vec3_t rayPos, const vec3_t rayDir, const vec4_t plane, vec3_t res);
886void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
887void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
888void RotateAroundDirection( vec3_t axis[3], float yaw );
889void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up );
890// perpendicular vector could be replaced by this
891
892//int PlaneTypeForNormal (vec3_t normal);
893
894void MatrixTransformVector( const vec3_t in, const float mat[ 3 ][ 3 ], vec3_t out );
895void MatrixTransformVectorRight( const float mat[ 3 ][ 3 ], const vec3_t in, vec3_t out );
896void Matrix3x3Multiply( const float in1[ 3 ][ 3 ], const float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
897void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up );
898void AngleVectorsLeft( const vec3_t angles, vec3_t forward, vec3_t left, vec3_t up );
899void PerpendicularVector( vec3_t dst, const vec3_t src );
900
901void GetPerpendicularViewVector(const vec3_t point, const vec3_t p1, const vec3_t p2, vec3_t up);
902void ProjectPointOntoVector(vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj);
903
904float pointToLineDistance(const vec3_t point, const vec3_t p1, const vec3_t p2);
905float VectorMinComponent(vec3_t v);
906float VectorMaxComponent(vec3_t v);
907
908#ifndef MAX
909#define MAX(x,y) ((x)>(y)?(x):(y))
910#endif
911
912#ifndef MIN
913#define MIN(x,y) ((x)<(y)?(x):(y))
914#endif
915
916vec_t DistanceBetweenLineSegmentsSquared(const vec3_t sP0, const vec3_t sP1,
917 const vec3_t tP0, const vec3_t tP1, float *s, float *t);
918vec_t DistanceBetweenLineSegments(const vec3_t sP0, const vec3_t sP1,
919 const vec3_t tP0, const vec3_t tP1, float *s, float *t);
920
921void VectorMatrixInverse( void* DstMatrix, const void* SrcMatrix );
922
923void MatrixIdentity(matrix_t m);
924void MatrixClear(matrix_t m);
925void MatrixCopy(const matrix_t in, matrix_t out);
926qboolean MatrixCompare(const matrix_t a, const matrix_t b);
927void MatrixTransposeIntoXMM(const matrix_t m);
928void MatrixTranspose(const matrix_t in, matrix_t out);
929
930// invert any m4x4 using Kramer's rule.. return qtrue if matrix is singular, else return qfalse
931qboolean MatrixInverse(matrix_t m);
932void MatrixSetupXRotation(matrix_t m, vec_t degrees);
933void MatrixSetupYRotation(matrix_t m, vec_t degrees);
934void MatrixSetupZRotation(matrix_t m, vec_t degrees);
935void MatrixSetupTranslation(matrix_t m, vec_t x, vec_t y, vec_t z);
936void MatrixSetupScale(matrix_t m, vec_t x, vec_t y, vec_t z);
937void MatrixSetupShear(matrix_t m, vec_t x, vec_t y);
938void Matrix4x4Multiply(const matrix_t a, const matrix_t b, matrix_t out);
939void MatrixMultiply( const float in1[ 3 ][ 3 ], const float in2[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
940void MatrixMultiply2( matrix_t m, const matrix_t m2 );
941void MatrixMultiplyRotation(matrix_t m, vec_t pitch, vec_t yaw, vec_t roll);
942void MatrixMultiplyZRotation(matrix_t m, vec_t degrees);
943void MatrixMultiplyTranslation(matrix_t m, vec_t x, vec_t y, vec_t z);
944void MatrixMultiplyScale(matrix_t m, vec_t x, vec_t y, vec_t z);
945void MatrixMultiplyShear(matrix_t m, vec_t x, vec_t y);
946void MatrixToAngles(const matrix_t m, vec3_t angles);
947void MatrixFromAngles(matrix_t m, vec_t pitch, vec_t yaw, vec_t roll);
948void MatrixFromVectorsFLU(matrix_t m, const vec3_t forward, const vec3_t left, const vec3_t up);
949void MatrixFromVectorsFRU(matrix_t m, const vec3_t forward, const vec3_t right, const vec3_t up);
950void MatrixFromQuat(matrix_t m, const quat_t q);
951void MatrixFromPlanes(matrix_t m, const vec4_t left, const vec4_t right, const vec4_t bottom, const vec4_t top,
952 const vec4_t near, const vec4_t far);
953void MatrixToVectorsFLU(const matrix_t m, vec3_t forward, vec3_t left, vec3_t up);
954void MatrixToVectorsFRU(const matrix_t m, vec3_t forward, vec3_t right, vec3_t up);
955void MatrixSetupTransformFromVectorsFLU(matrix_t m, const vec3_t forward, const vec3_t left, const vec3_t up, const vec3_t origin);
956void MatrixSetupTransformFromVectorsFRU(matrix_t m, const vec3_t forward, const vec3_t right, const vec3_t up, const vec3_t origin);
957void MatrixSetupTransformFromRotation(matrix_t m, const matrix_t rot, const vec3_t origin);
958void MatrixSetupTransformFromQuat(matrix_t m, const quat_t quat, const vec3_t origin);
959void MatrixAffineInverse(const matrix_t in, matrix_t out);
960void MatrixTransformNormal(const matrix_t m, const vec3_t in, vec3_t out);
961void MatrixTransformNormal2(const matrix_t m, vec3_t inout);
962void MatrixTransformPoint(const matrix_t m, const vec3_t in, vec3_t out);
963void MatrixTransformPoint2(const matrix_t m, vec3_t inout);
964void MatrixTransform4(const matrix_t m, const vec4_t in, vec4_t out);
965void MatrixTransformPlane(const matrix_t m, const vec4_t in, vec4_t out);
966void MatrixTransformPlane2(const matrix_t m, vec3_t inout);
967void MatrixPerspectiveProjection(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
968void MatrixPerspectiveProjectionLH(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
969void MatrixPerspectiveProjectionRH(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
970void MatrixPerspectiveProjectionFovYAspectLH(matrix_t m, vec_t fov, vec_t aspect, vec_t near, vec_t far);
971void MatrixPerspectiveProjectionFovXYLH(matrix_t m, vec_t fovX, vec_t fovY, vec_t near, vec_t far);
972void MatrixPerspectiveProjectionFovXYRH(matrix_t m, vec_t fovX, vec_t fovY, vec_t near, vec_t far);
973void MatrixPerspectiveProjectionFovXYInfiniteRH(matrix_t m, vec_t fovX, vec_t fovY, vec_t near);
974void MatrixOrthogonalProjection(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
975
976void MatrixOrthogonalProjectionLH(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
977void MatrixOrthogonalProjectionRH(matrix_t m, vec_t left, vec_t right, vec_t bottom, vec_t top, vec_t near, vec_t far);
978
979void MatrixPlaneReflection(matrix_t m, const vec4_t plane);
980
981void MatrixLookAtLH(matrix_t output, const vec3_t pos, const vec3_t dir, const vec3_t up);
982void MatrixLookAtRH(matrix_t m, const vec3_t eye, const vec3_t dir, const vec3_t up);
983void MatrixScaleTranslateToUnitCube(matrix_t m, const vec3_t mins, const vec3_t maxs);
984void MatrixCrop(matrix_t m, const vec3_t mins, const vec3_t maxs);
985
986void TransposeMatrix( float in[ 3 ][ 3 ], float out[ 3 ][ 3 ] );
987
988static ID_INLINE void AnglesToMatrix(const vec3_t angles, matrix_t m)
989{
990 MatrixFromAngles(m, angles[PITCH], angles[YAW], angles[ROLL]);
991}
992
993
994#define QuatSet(q,x,y,z,w) ((q)[0]=(x),(q)[1]=(y),(q)[2]=(z),(q)[3]=(w))
995#define QuatCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
996
997#define QuatCompare(a,b) ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3])
998
999static ID_INLINE void QuatClear(quat_t q)
1000{
1001 q[0] = 0;
1002 q[1] = 0;
1003 q[2] = 0;
1004 q[3] = 1;
1005}
1006
1007/*
1008static ID_INLINE int QuatCompare(const quat_t a, const quat_t b)
1009{
1010 if(a[0] != b[0] || a[1] != b[1] || a[2] != b[2] || a[3] != b[3])
1011 {
1012 return 0;
1013 }
1014 return 1;
1015}
1016*/
1017
1018static ID_INLINE void QuatCalcW(quat_t q)
1019{
1020#if 1
1021 vec_t term = 1.0f - (q[0] * q[0] + q[1] * q[1] + q[2] * q[2]);
1022
1023 if(term < 0.0)
1024 q[3] = 0.0;
1025 else
1026 q[3] = -sqrt(term);
1027#else
1028 q[3] = sqrt(fabs(1.0f - (q[0] * q[0] + q[1] * q[1] + q[2] * q[2])));
1029#endif
1030}
1031
1032static ID_INLINE void QuatInverse(quat_t q)
1033{
1034 q[0] = -q[0];
1035 q[1] = -q[1];
1036 q[2] = -q[2];
1037}
1038
1039static ID_INLINE void QuatAntipodal(quat_t q)
1040{
1041 q[0] = -q[0];
1042 q[1] = -q[1];
1043 q[2] = -q[2];
1044 q[3] = -q[3];
1045}
1046
1047static ID_INLINE vec_t QuatLength(const quat_t q)
1048{
1049 return (vec_t) sqrt(q[0] * q[0] + q[1] * q[1] + q[2] * q[2] + q[3] * q[3]);
1050}
1051
1052vec_t QuatNormalize(quat_t q);
1053
1054void QuatFromAngles(quat_t q, vec_t pitch, vec_t yaw, vec_t roll);
1055
1056static ID_INLINE void AnglesToQuat(const vec3_t angles, quat_t q)
1057{
1058 QuatFromAngles(q, angles[PITCH], angles[YAW], angles[ROLL]);
1059}
1060
1061void QuatFromMatrix(quat_t q, const matrix_t m);
1062void QuatToVectorsFLU(const quat_t quat, vec3_t forward, vec3_t left, vec3_t up);
1063void QuatToVectorsFRU(const quat_t quat, vec3_t forward, vec3_t right, vec3_t up);
1064void QuatToAxis(const quat_t q, vec3_t axis[3]);
1065void QuatToAngles(const quat_t q, vec3_t angles);
1066
1067// wombat: pretty straightforward
1068void QuatToRotAngle( const quat_t q, vec_t *angle );
1069void QuatToRotAngleAxis( const quat_t q, vec_t *angle, vec3_t axis );
1070
1071void QuatFromRotAngleAxis( quat_t q, vec_t angle, const vec3_t axis );
1072
1073// Quaternion multiplication, analogous to the matrix multiplication routines.
1074
1075// qa = rotate by qa, then qb
1076void QuatMultiply0(quat_t qa, const quat_t qb);
1077
1078// qc = rotate by qa, then qb
1079void QuatMultiply1(const quat_t qa, const quat_t qb, quat_t qc);
1080
1081// qc = rotate by qa, then by inverse of qb
1082void QuatMultiply2(const quat_t qa, const quat_t qb, quat_t qc);
1083
1084// qc = rotate by inverse of qa, then by qb
1085void QuatMultiply3(const quat_t qa, const quat_t qb, quat_t qc);
1086
1087// qc = rotate by inverse of qa, then by inverse of qb
1088void QuatMultiply4(const quat_t qa, const quat_t qb, quat_t qc);
1089
1090void QuaternionMultiply( quat_t output, quat_t first, quat_t second );
1091
1092void QuatSlerp(const quat_t from, const quat_t to, float frac, quat_t out);
1093void QuatTransformVector(const quat_t q, const vec3_t in, vec3_t out);
1094int Q_isnan( float x );
1095
1096//=============================================
1097
1098
1099typedef struct
1100{
1101 qboolean frameMemory;
1102 int currentElements;
1103 int maxElements; // will reallocate and move when exceeded
1104 void **elements;
1105} growList_t;
1106
1107// you don't need to init the growlist if you don't mind it growing and moving
1108// the list as it expands
1109void Com_InitGrowList(growList_t * list, int maxElements);
1110void Com_DestroyGrowList(growList_t * list);
1111int Com_AddToGrowList(growList_t * list, void *data);
1112void *Com_GrowListElement(const growList_t * list, int index);
1113int Com_IndexForGrowListElement(const growList_t * list, const void *element);
1114
1115
1116//=============================================
1117
1118float Com_Clamp( float min, float max, float value );
1119
1120const char *COM_SkipPath( const char *pathname );
1121const char *COM_GetExtension( const char *name );
1122void COM_StripExtension(const char *in, char *out, int destsize);
1123qboolean COM_CompareExtension(const char* in, const char* ext);
1124void COM_DefaultExtension( char *path, int maxSize, const char *extension );
1125
1126void COM_BeginParseSession( const char *name );
1127int COM_GetCurrentParseLine( void );
1128const char *COM_Parse( char **data_p );
1129char *COM_ParseExt( char **data_p, qboolean allowLineBreak );
1130char *COM_ParseExtIgnoreQuotes( char **data_p, qboolean allowLineBreak );
1131const char *COM_GetToken( char **data_p, qboolean crossline );
1132void Com_SkipRestOfLine(char **data);
1133void Com_SkipBracedSection(char **program);
1134void Com_Parse1DMatrix(char **buf_p, int x, float *m, qboolean checkBrackets);
1135int COM_Compress( char *data_p );
1136void COM_ParseError( char *format, ... ) Q_PRINTF_FUNC(1, 2);
1137void COM_ParseWarning( char *format, ... ) Q_PRINTF_FUNC(1, 2);
1138//int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
1139
1140#define MAX_TOKENLENGTH 1024
1141
1142#ifndef TT_STRING
1143//token types
1144#define TT_STRING 1 // string
1145#define TT_LITERAL 2 // literal
1146#define TT_NUMBER 3 // number
1147#define TT_NAME 4 // name
1148#define TT_PUNCTUATION 5 // punctuation
1149#endif
1150
1151typedef struct pc_token_s
1152{
1153 int type;
1154 int subtype;
1155 int intvalue;
1156 float floatvalue;
1157 char string[MAX_TOKENLENGTH];
1158} pc_token_t;
1159
1160// data is an in/out parm, returns a parsed out token
1161
1162void COM_MatchToken( char**buf_p, char *match );
1163
1164qboolean SkipBracedSection (char **program, int depth);
1165void SkipRestOfLine ( char **data );
1166
1167void Parse1DMatrix (char **buf_p, int x, float *m);
1168void Parse2DMatrix (char **buf_p, int y, int x, float *m);
1169void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);
1170
1171int Com_HexStrToInt( const char *str );
1172
1173size_t QDECL Com_sprintf (char *dest, size_t size, const char *fmt, ...) Q_PRINTF_FUNC(3, 4);
1174
1175char *Com_SkipTokens( char *s, int numTokens, const char *sep );
1176char *Com_SkipCharset( char *s, const char *sep );
1177
1178void Com_RandomBytes(byte* string, int len);
1179void Com_BackslashToSlash( char *str );
1180
1181// mode parm for FS_FOpenFile
1182typedef enum {
1183 FS_READ,
1184 FS_WRITE,
1185 FS_APPEND,
1186 FS_APPEND_SYNC
1187} fsMode_t;
1188
1189typedef enum {
1190 FS_SEEK_CUR,
1191 FS_SEEK_END,
1192 FS_SEEK_SET
1193} fsOrigin_t;
1194
1195//=============================================
1196
1197// get the control character for the given key (moved from sdl_input.c)
1198#define CTRL(a) ((a)-'a'+1)
1199
1200int Q_isprint( int c );
1201int Q_islower( int c );
1202int Q_isupper( int c );
1203int Q_isalpha( int c );
1204qboolean Q_isanumber( const char *s );
1205qboolean Q_isintegral( float f );
1206
1207// portable case insensitive compare
1208int Q_stricmp (const char *s1, const char *s2);
1209int Q_strncmp( const char *s1, const char *s2, size_t n );
1210int Q_stricmpn (const char *s1, const char *s2, size_t n);
1211char *Q_strlwr( char *s1 );
1212char *Q_strupr( char *s1 );
1213char *Q_strrchr( const char* string, int c );
1214const char *Q_stristr( const char *s, const char *find);
1215qboolean Q_strreplace(char *dest, int destsize, const char *find, const char *replace);
1216
1217// buffer size safe library replacements
1218void Q_strncpyz( char *dest, const char *src, size_t destsize );
1219void Q_strcat( char *dest, int size, const char *src );
1220
1221// strlen that discounts Quake color sequences
1222int Q_PrintStrlen( const char *string );
1223// removes color sequences from string
1224char *Q_CleanStr( char *string );
1225// Count the number of char tocount encountered in string
1226int Q_CountChar(const char *string, char tocount);
1227
1228//=============================================
1229
1230void Swap_Init(void);
1231
1232// 64-bit integers for global rankings interface
1233// implemented as a struct for qvm compatibility
1234typedef struct
1235{
1236 byte b0;
1237 byte b1;
1238 byte b2;
1239 byte b3;
1240 byte b4;
1241 byte b5;
1242 byte b6;
1243 byte b7;
1244} qint64;
1245
1246void Swap_Init (void);
1247
1248const char * QDECL va(const char *format, ...) Q_PRINTF_FUNC(1, 2);
1249
1250#define TRUNCATE_LENGTH 64
1251void Com_TruncateLongString( char *buffer, const char *s );
1252
1253//=============================================
1254
1255float vectoyaw(const vec3_t vec);
1256int MusicMood_NameToNum( const char * name );
1257const char * MusicMood_NumToName( int num );
1258int EAXMode_NameToNum( const char * name );
1259const char * EAXMode_NumToName( int num );
1260
1261//
1262// key / value info strings
1263//
1264char *Info_ValueForKey( const char *s, const char *key );
1265void Info_RemoveKey( char *s, const char *key );
1266void Info_RemoveKey_big( char *s, const char *key );
1267void Info_SetValueForKey( char *s, const char *key, const char *value );
1268void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
1269qboolean Info_Validate( const char *s );
1270void Info_NextPair( const char **s, char *key, char *value );
1271
1272// this is only here so the functions in q_shared.c and bg_*.c can link
1273void QDECL Com_Error( int level, const char *error, ... ) Q_NO_RETURN Q_PRINTF_FUNC(2, 3);
1274void QDECL Com_Printf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1275void QDECL Com_DPrintf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1276void QDECL Com_DPrintf2( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1277void QDECL Com_DebugPrintf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1278
1279
1280/*
1281==========================================================
1282
1283CVARS (console variables)
1284
1285Many variables can be used for cheating purposes, so when
1286cheats is zero, force all unspecified variables to their
1287default values.
1288==========================================================
1289*/
1290
1291#define CVAR_ARCHIVE 0x0001 // set to cause it to be saved to vars.rc
1292 // used for system variables, not for player
1293 // specific configurations
1294#define CVAR_USERINFO 0x0002 // sent to server on connect or change
1295#define CVAR_SERVERINFO 0x0004 // sent in response to front end requests
1296#define CVAR_SYSTEMINFO 0x0008 // these cvars will be duplicated on all clients
1297#define CVAR_INIT 0x0010 // don't allow change from console at all,
1298 // but can be set from the command line
1299#define CVAR_LATCH 0x0020 // will only change when C code next does
1300 // a Cvar_Get(), so it can't be changed
1301 // without proper initialization. modified
1302 // will be set, even though the value hasn't
1303 // changed yet
1304#define CVAR_ROM 0x0040 // display only, cannot be set by user at all
1305#define CVAR_USER_CREATED 0x0080 // created by a set command
1306#define CVAR_TEMP 0x0100 // can be set even when cheats are disabled, but is not archived
1307#define CVAR_CHEAT 0x0200 // can not be changed if cheats are disabled
1308#define CVAR_NORESTART 0x0400 // do not clear when a cvar_restart is issued
1309
1310#define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to.
1311
1312#define CVAR_SOUND_LATCH 0x1000 // specifically for sound will only change
1313 // when C code next does a Cvar_Get(), so it
1314 // can't be changed without proper initialization.
1315 // modified will be set, even though the value hasn't
1316 // changed yet
1317
1318#define CVAR_TERRAIN_LATCH 0x2000 // specifically for terrain will only change
1319
1320#define CVAR_SAVEGAME 0x4000 // cvar will be saved when saving to file
1321
1322#define CVAR_VM_CREATED 0x8000 // cvar was created exclusively in one of the VMs.
1323#define CVAR_PROTECTED 0x10000 // prevent modifying this var from VMs or the server
1324#define CVAR_RESETSTRING 0x20000 // force the cvar's reset string to be set
1325// These flags are only returned by the Cvar_Flags() function
1326#define CVAR_MODIFIED 0x40000000 // Cvar was modified
1327#define CVAR_NONEXISTENT 0x80000000 // Cvar doesn't exist.
1328
1329// nothing outside the Cvar_*() functions should modify these fields!
1330typedef struct cvar_s cvar_t;
1331
1332struct cvar_s {
1333 char *name;
1334 char *string;
1335 char *resetString; // cvar_restart will reset to this value
1336 char *latchedString; // for CVAR_LATCH vars
1337 int flags;
1338 qboolean modified; // set each time the cvar is changed
1339 int modificationCount; // incremented each time the cvar is changed
1340 float value; // atof( string )
1341 int integer; // atoi( string )
1342 qboolean validate;
1343 qboolean integral;
1344 float min;
1345 float max;
1346 char *description;
1347
1348 cvar_t *next;
1349 cvar_t *prev;
1350 cvar_t *hashNext;
1351 cvar_t *hashPrev;
1352 int hashIndex;
1353};
1354
1355#define MAX_CVAR_VALUE_STRING 256
1356
1357typedef int cvarHandle_t;
1358
1359// the modules that run in the virtual machine can't access the cvar_t directly,
1360// so they must ask for structured updates
1361typedef struct {
1362 cvarHandle_t handle;
1363 int modificationCount;
1364 float value;
1365 int integer;
1366 char string[MAX_CVAR_VALUE_STRING];
1367 char latchedString[MAX_CVAR_VALUE_STRING];
1368} vmCvar_t;
1369
1370/*
1371==============================================================
1372
1373COLLISION DETECTION
1374
1375==============================================================
1376*/
1377
1378#include "surfaceflags.h" // shared with the q3map utility
1379
1380// plane types are used to speed some tests
1381// 0-2 are axial planes
1382#define PLANE_X 0
1383#define PLANE_Y 1
1384#define PLANE_Z 2
1385#define PLANE_NON_AXIAL 3
1386#define PLANE_NON_PLANAR 4
1387
1388
1389/*
1390=================
1391PlaneTypeForNormal
1392=================
1393*/
1394
1395//#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) )
1396static ID_INLINE int PlaneTypeForNormal(vec3_t normal)
1397{
1398 if(normal[0] == 1.0)
1399 return PLANE_X;
1400
1401 if(normal[1] == 1.0)
1402 return PLANE_Y;
1403
1404 if(normal[2] == 1.0)
1405 return PLANE_Z;
1406
1407 if(normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0)
1408 return PLANE_NON_PLANAR;
1409
1410 return PLANE_NON_AXIAL;
1411}
1412
1413// plane_t structure
1414// !!! if this is changed, it must be changed in asm code too !!!
1415typedef struct cplane_s {
1416 vec3_t normal;
1417 float dist;
1418 byte type; // for fast side tests: 0,1,2 = axial, 3 = nonaxial
1419 byte signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision
1420 byte pad[2];
1421} cplane_t;
1422
1423// body hit location
1424typedef enum hitloc_e {
1425 HITLOC_MISS = -2,
1426 HITLOC_GENERAL = -1,
1427 HITLOC_HEAD = 0,
1428 HITLOC_HELMET,
1429 HITLOC_NECK,
1430 HITLOC_TORSO_UPPER,
1431 HITLOC_TORSO_MID,
1432 HITLOC_TORSO_LOWER,
1433 HITLOC_PELVIS,
1434 HITLOC_R_ARM_UPPER,
1435 HITLOC_L_ARM_UPPER,
1436 HITLOC_R_LEG_UPPER,
1437 HITLOC_L_LEG_UPPER,
1438 HITLOC_R_ARM_LOWER,
1439 HITLOC_L_ARM_LOWER,
1440 HITLOC_R_LEG_LOWER,
1441 HITLOC_L_LEG_LOWER,
1442 HITLOC_R_HAND,
1443 HITLOC_L_HAND,
1444 HITLOC_R_FOOT,
1445 HITLOC_L_FOOT,
1446 NUMBODYLOCATIONS
1447} hitloc_t;
1448
1449// a trace is returned when a box is swept through the world
1450typedef struct {
1451 qboolean allsolid; // if true, plane is not valid
1452 qboolean startsolid; // if true, the initial point was in a solid area
1453 float fraction; // time completed, 1.0 = didn't hit anything
1454 vec3_t endpos; // final position
1455 cplane_t plane; // surface normal at impact, transformed to world space
1456 int surfaceFlags; // surface hit
1457 int shaderNum;
1458 int contents; // contents on other side of surface hit
1459 int entityNum; // entity the contacted surface is a part of
1460
1461 int location;
1462 struct gentity_s *ent;
1463} trace_t;
1464
1465// trace->entityNum can also be 0 to (MAX_GENTITIES-1)
1466// or ENTITYNUM_NONE, ENTITYNUM_WORLD
1467
1468#define SAVEGAME_STRUCT_VERSION 4
1469
1470typedef struct savegamestruct_s {
1471 //int version
1472 // Modified in OPM
1473 //===
1474 short version;
1475 // The type matches com_target_game
1476 byte type;
1477 // Currently unused
1478 byte flags;
1479 //===
1480 int time;
1481 int mapTime;
1482 char comment[ 64 ];
1483 char mapName[ 64 ];
1484 char saveName[ 64 ];
1485 char tm_filename[ 64 ];
1486 int tm_loopcount;
1487 int tm_offset;
1488} savegamestruct_t;
1489
1490// markfragments are returned by CM_MarkFragments()
1491typedef struct {
1492 int firstPoint;
1493 int numPoints;
1494 int iIndex;
1496
1497typedef struct treadMark_s {
1498 int iReferenceNumber;
1499 int iLastTime;
1500 qhandle_t hTreadShader;
1501 int iState;
1502 float fWidth;
1503 vec3_t vStartDir;
1504 vec3_t vStartVerts[ 2 ];
1505 float fStartTexCoord;
1506 float fStartAlpha;
1507 vec3_t vMidPos;
1508 vec3_t vMidVerts[ 2 ];
1509 float fMidTexCoord;
1510 float fMidAlpha;
1511 vec3_t vEndPos;
1512 vec3_t vEndVerts[ 2 ];
1513 float fEndTexCoord;
1514 float fEndAlpha;
1515} treadMark_t;
1516
1517typedef struct {
1518 vec3_t p;
1519 quat_t q;
1520} bone_t;
1521
1522typedef struct {
1523 vec3_t origin;
1524 vec3_t axis[ 3 ];
1526
1527//=====================================================================
1528
1529
1530// in order from highest priority to lowest
1531// if none of the catchers are active, bound key strings will be executed
1532#define KEYCATCH_CONSOLE 0x0001
1533#define KEYCATCH_UI 0x0002
1534#define KEYCATCH_MESSAGE 0x0004
1535#define KEYCATCH_CGAME 0x0008
1536
1537
1538// sound channels
1539// channel 0 never willingly overrides
1540// other channels will allways override a playing sound on that channel
1541/*typedef enum {
1542 CHAN_AUTO,
1543 CHAN_LOCAL, // menu sounds, etc
1544 CHAN_WEAPON,
1545 CHAN_VOICE,
1546 CHAN_ITEM,
1547 CHAN_BODY,
1548 CHAN_LOCAL_SOUND, // chat messages, etc
1549 CHAN_ANNOUNCER // announcer voices, etc
1550} soundChannel_t;*/
1551typedef enum {
1552 CHAN_AUTO,
1553 CHAN_BODY,
1554 CHAN_ITEM,
1555 CHAN_WEAPONIDLE,
1556 CHAN_VOICE,
1557 CHAN_LOCAL,
1558 CHAN_WEAPON,
1559 CHAN_DIALOG_SECONDARY,
1560 CHAN_DIALOG,
1561 CHAN_MENU,
1562 CHAN_LOCAL_SOUND, // chat messages, etc
1563 CHAN_ANNOUNCER, // announcer voices, etc
1564 CHAN_MAX
1565} soundChannel_t;
1566
1567#define S_FLAG_DO_CALLBACK 0x400
1568
1569#define DEFAULT_MIN_DIST -1.0
1570#define DEFAULT_VOL -1.0
1571
1572#define LEVEL_WIDE_MIN_DIST 10000 // full volume the entire level
1573#define LEVEL_WIDE_STRING "levelwide"
1574
1575#define SOUND_SYNCH 0x1
1576#define SOUND_SYNCH_FADE 0x2
1577#define SOUND_RANDOM_PITCH_20 0x4
1578#define SOUND_RANDOM_PITCH_40 0x8
1579#define SOUND_LOCAL_DIALOG 0x10
1580
1581typedef enum
1582{
1583 mood_none,
1584 mood_normal,
1585 mood_action,
1586 mood_suspense,
1587 mood_mystery,
1588 mood_success,
1589 mood_failure,
1590 mood_surprise,
1591 mood_special,
1592 mood_aux1,
1593 mood_aux2,
1594 mood_aux3,
1595 mood_aux4,
1596 mood_aux5,
1597 mood_aux6,
1598 mood_aux7,
1599 mood_totalnumber
1600} music_mood_t;
1601
1602typedef enum
1603{
1604 eax_generic,
1605 eax_paddedcell,
1606 eax_room,
1607 eax_bathroom,
1608 eax_livingroom,
1609 eax_stoneroom,
1610 eax_auditorium,
1611 eax_concerthall,
1612 eax_cave,
1613 eax_arena,
1614 eax_hangar,
1615 eax_carpetedhallway,
1616 eax_hallway,
1617 eax_stonecorridor,
1618 eax_alley,
1619 eax_forest,
1620 eax_city,
1621 eax_mountains,
1622 eax_quarry,
1623 eax_plain,
1624 eax_parkinglot,
1625 eax_sewerpipe,
1626 eax_underwater,
1627 eax_drugged,
1628 eax_dizzy,
1629 eax_psychotic,
1630 eax_totalnumber
1631} eax_mode_t;
1632
1633/*
1634========================================================================
1635
1636 ELEMENTS COMMUNICATED ACROSS THE NET
1637
1638========================================================================
1639*/
1640
1641#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535)
1642#define BYTE2ANGLE(x) ((x)*(360.0/255))
1643#define SHORT2ANGLE(x) ((x)*(360.0/65536))
1644
1645#define SNAPFLAG_RATE_DELAYED 1
1646#define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies
1647#define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected
1648
1649//
1650// per-level limits
1651//
1652#define MAX_CLIENTS 64 // absolute limit
1653#define MAX_LOCATIONS 64
1654
1655#define MAX_MAP_BOUNDS 8192
1656#define MIN_MAP_BOUNDS ( -MAX_MAP_BOUNDS )
1657#define MAP_SIZE ( MAX_MAP_BOUNDS - MIN_MAP_BOUNDS )
1658
1659#define GENTITYNUM_BITS 10 // don't need to send any more
1660#define MAX_GENTITIES (1<<GENTITYNUM_BITS)
1661
1662// entitynums are communicated with GENTITY_BITS, so any reserved
1663// values that are going to be communcated over the net need to
1664// also be in this range
1665#define ENTITYNUM_NONE (MAX_GENTITIES-1)
1666#define ENTITYNUM_WORLD (MAX_GENTITIES-2)
1667#define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-2)
1668
1669#define MAX_SERVER_SOUNDS 64
1670#define MAX_SERVER_SOUNDS_BITS (MAX_SERVER_SOUNDS-1)
1671
1672#define MAX_MODELS 1024 // these are sent over the net as 8 bits
1673#define MAX_SOUNDS 512 // so they cannot be blindly increased
1674#define MAX_OBJECTIVES 20
1675#define MAX_LIGHTSTYLES 32
1676#define MAX_WEAPONS 64
1677
1678#define MAX_CONFIGSTRINGS 2736
1679#define MAX_HUDDRAW_ELEMENTS 256
1680
1681#define MAX_SUBTITLES 4
1682
1683// these are the only configstrings that the system reserves, all the
1684// other ones are strictly for servergame to clientgame communication
1685#define CS_SERVERINFO 0 // an info string with all the serverinfo cvars
1686#define CS_SYSTEMINFO 1 // an info string for server system to client system configuration (timescale, etc)
1687
1688#define RESERVED_CONFIGSTRINGS 2 // game can't modify below this, only the system can
1689
1690#define MAX_GAMESTATE_CHARS 41952
1691typedef struct {
1692 int stringOffsets[MAX_CONFIGSTRINGS];
1693 char stringData[MAX_GAMESTATE_CHARS];
1694 int dataCount;
1695} gameState_t;
1696
1697//=========================================================
1698
1699// maybe this is better put somewhere else...
1700typedef struct server_sound_s {
1701 vec3_t origin;
1702 int entity_number;
1703 int channel;
1704 short int sound_index;
1705 float volume;
1706 float min_dist;
1707 float maxDist;
1708 float pitch;
1709 qboolean stop_flag;
1710 qboolean streamed;
1711} server_sound_t;
1712
1713typedef struct usereyes_s {
1714 signed char ofs[ 3 ];
1715 float angles[ 2 ];
1716} usereyes_t;
1717
1718// bit field limits
1719#define MAX_STATS 32
1720#define MAX_ACTIVE_ITEMS 8
1721#define MAX_AMMO 16
1722#define MAX_AMMOCOUNT 16
1723
1724#define MAX_PERSISTANT 16
1725#define MAX_POWERUPS 16
1726
1727#define MAX_PS_EVENTS 2
1728
1729#define PS_PMOVEFRAMECOUNTBITS 6
1730
1731// playerState_t is the information needed by both the client and server
1732// to predict player motion and actions
1733// nothing outside of pmove should modify these, or some degree of prediction error
1734// will occur
1735
1736// you can't add anything to this without modifying the code in msg.c
1737
1738// playerState_t is a full superset of entityState_t as it is used by players,
1739// so if a playerState_t is transmitted, the entityState_t can be fully derived
1740// from it.
1741
1742typedef struct playerState_s {
1743 int commandTime; // cmd->serverTime of last executed command
1744 int pm_type;
1745 int bobCycle; // for view bobbing and footstep generation
1746 int net_pm_flags; // ducked, jump_held, etc
1747 int pm_flags; // ducked, jump_held, etc
1748 int pm_time;
1749
1750 vec3_t origin;
1751 vec3_t velocity;
1752
1753 int gravity;
1754 int speed;
1755 int delta_angles[3]; // add to command angles to get view direction
1756 // changed by spawns, rotating objects, and teleporters
1757
1758 int groundEntityNum; // ENTITYNUM_NONE = in air
1759
1760 qboolean walking;
1761 qboolean groundPlane;
1762 int feetfalling;
1763 float falldir[3];
1764 trace_t groundTrace;
1765
1766 int clientNum; // ranges from 0 to MAX_CLIENTS-1
1767
1768 vec3_t viewangles; // for fixed views
1769 int viewheight;
1770
1771 float fLeanAngle;
1772 int iNetViewModelAnim;
1773 int iViewModelAnim;
1774 int iViewModelAnimChanged;
1775
1776 int stats[MAX_STATS];
1777 int activeItems[MAX_ACTIVE_ITEMS];
1778 int ammo_name_index[MAX_AMMO];
1779 int ammo_amount[MAX_AMMOCOUNT];
1780 int max_ammo_amount[MAX_AMMOCOUNT];
1781
1782 int current_music_mood;
1783 int fallback_music_mood;
1784 float music_volume;
1785 float music_volume_fade_time;
1786
1787 int reverb_type;
1788 float reverb_level;
1789
1790 float blend[4]; // rgba full screen effect
1791 float fov; // fov of the player
1792
1793 vec3_t camera_origin; // origin for camera view
1794 vec3_t camera_angles; // angles for camera view
1795 float camera_time;
1796
1797 vec3_t camera_offset; // angular offset for camera
1798 vec3_t camera_posofs;
1799 int camera_flags; // third-person camera flags
1800 vec3_t damage_angles; // these angles are added directly to the view, without lerping
1801 // --
1802 // Team Assault
1803 int radarInfo;
1804 qboolean voted;
1805 // --
1806
1807 // not communicated over the net at all
1808 int ping; // server to game info for scoreboard
1809 float vEyePos[3];
1810} playerState_t;
1811
1812
1813//====================================================================
1814
1815//
1816// usercmd_t->button bits, many of which are generated by the client system,
1817// so they aren't game-only definitions
1818//
1819#define BUTTON_ATTACKLEFT_BITINDEX 0
1820#define BUTTON_ATTACKRIGHT_BITINDEX 1
1821#define BUTTON_RUN_BITINDEX 2
1822#define BUTTON_USE_BITINDEX 3
1823#define BUTTON_LEAN_LEFT_BITINDEX 4
1824#define BUTTON_LEAN_RIGHT_BITINDEX 5
1825#define BUTTON_TALK_BITINDEX 6 // displays talk balloon and disables actions
1826#define BUTTON_ANY_BITINDEX 14 // any key whatsoever
1827#define BUTTON_MOUSE_BITINDEX 15 // mouse move
1828
1829#define BUTTON_ATTACKLEFT (1 << BUTTON_ATTACKLEFT_BITINDEX)
1830#define BUTTON_ATTACKRIGHT (1 << BUTTON_ATTACKRIGHT_BITINDEX)
1831#define BUTTON_RUN (1 << BUTTON_RUN_BITINDEX)
1832#define BUTTON_USE (1 << BUTTON_USE_BITINDEX)
1833#define BUTTON_LEAN_LEFT (1 << BUTTON_LEAN_LEFT_BITINDEX)
1834#define BUTTON_LEAN_RIGHT (1 << BUTTON_LEAN_RIGHT_BITINDEX)
1835#define BUTTON_TALK (1 << BUTTON_TALK_BITINDEX) // displays talk balloon and disables actions
1836#define BUTTON_ANY (1 << BUTTON_ANY_BITINDEX) // any key whatsoever
1837#define BUTTON_MOUSE (1 << BUTTON_MOUSE_BITINDEX)
1838
1839typedef enum {
1840 WEAPON_COMMAND_NONE,
1841 WEAPON_COMMAND_USE_PISTOL,
1842 WEAPON_COMMAND_USE_RIFLE,
1843 WEAPON_COMMAND_USE_SMG,
1844 WEAPON_COMMAND_USE_MG,
1845 WEAPON_COMMAND_USE_GRENADE,
1846 WEAPON_COMMAND_USE_HEAVY,
1847 WEAPON_COMMAND_USE_ITEM1,
1848 WEAPON_COMMAND_USE_ITEM2,
1849 WEAPON_COMMAND_USE_ITEM3,
1850 WEAPON_COMMAND_USE_ITEM4,
1851 WEAPON_COMMAND_USE_PREV_WEAPON,
1852 WEAPON_COMMAND_USE_NEXT_WEAPON,
1853 WEAPON_COMMAND_USE_LAST_WEAPON,
1854 WEAPON_COMMAND_HOLSTER,
1855 WEAPON_COMMAND_DROP,
1856} weaponcommand_t;
1857
1858#define WEAPON_COMMAND_MAX_VER6 15
1859#define WEAPON_COMMAND_MAX_VER17 31
1860
1861static unsigned int GetWeaponCommandMask(unsigned int maxCmds) {
1862 return maxCmds << 7;
1863}
1864
1865static unsigned int GetWeaponCommand(unsigned int buttons, unsigned int maxCmds) {
1866 return (buttons & (maxCmds << 7)) >> 7;
1867}
1868
1869#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN,
1870 // then BUTTON_WALKING should be set
1871
1872// usercmd_t is sent to the server each client frame
1873typedef struct usercmd_s {
1874 int serverTime;
1875 byte msec;
1876 short unsigned int buttons;
1877 short int angles[3];
1878 //int weapon; // su44: there is no 'weapon' field
1879 // in MoHAA's usercmd_s - weapon commands are encoded
1880 // into buttons bits. See CL_CmdButtons from cl_input.c.
1881 signed char forwardmove, rightmove, upmove;
1882} usercmd_t;
1883
1884//===================================================================
1885
1886//
1887// Animation flags
1888//
1889#define MDL_ANIM_DELTA_DRIVEN ( 1 << 0 )
1890#define MDL_ANIM_DEFAULT_ANGLES ( 1 << 3 )
1891#define MDL_ANIM_NO_TIMECHECK ( 1 << 4 )
1892
1893// if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
1894#define SOLID_BMODEL 0xffffff
1895
1896// renderfx flags (entityState_t::renderfx)
1897// su44: moved it here, in MoHAA (and FAKK)
1898// render flags are set by "renderEffects" event
1899// and sent to cgame trough entityState_t
1900// TODO: find out rest of them
1901#define RF_THIRD_PERSON (1<<0) // don't draw through eyes, only mirrors (player bodies, chat sprites)
1902#define RF_FIRST_PERSON (1<<1) // only draw through eyes (view weapon, damage blood blob)
1903#define RF_DEPTHHACK (1<<2) // hack the z-depth so that view weapons do not clip into walls
1904#define RF_VIEWLENSFLARE (1<<3) // View dependent lensflare
1905#define RF_FRAMELERP (1<<4) // interpolate between current and next state
1906#define RF_BEAM (1<<5) // draw a beam between origin and origin2
1907#define RF_DONTDRAW (1<<7) // don't draw this entity but send it over
1908#define RF_LENSFLARE (1<<8) // add a lens flare to this
1909#define RF_EXTRALIGHT (1<<9) // use good lighting on this entity
1910#define RF_DETAIL (1<<10) // Culls a model based on the distance away from you
1911#define RF_SHADOW (1<<11) // whether or not to draw a shadow
1912#define RF_PORTALSURFACE (1<<12) // don't draw, but use to set portal views
1913#define RF_SKYORIGIN (1<<13) // don't draw, but use to set sky portal origin and coordinate system
1914#define RF_SKYENTITY (1<<14) // this entity is only visible through a skyportal
1915#define RF_LIGHTOFFSET (1<<15) // this entity has a light offset
1916#define RF_CUSTOMSHADERPASS (1<<16) // draw the custom shader on top of the base geometry
1917#define RF_MINLIGHT (1<<17) // allways have some light (viewmodel, some items)
1918#define RF_FULLBRIGHT (1<<18) // allways have full lighting
1919#define RF_LIGHTING_ORIGIN (1<<19) // use refEntity->lightingOrigin instead of refEntity->origin
1920// for lighting. This allows entities to sink into the floor
1921// with their origin going solid, and allows all parts of a
1922// player to get the same lighting
1923#define RF_SHADOW_PLANE (1<<20) // use refEntity->shadowPlane
1924#define RF_WRAP_FRAMES (1<<21) // mod the model frames by the maxframes to allow continuous
1925// animation without needing to know the frame count
1926//#define RF_PORTALENTITY (1<<22) // this entity should only be drawn from a portal
1927//#define RF_DUALENTITY (1<<23) // this entity is drawn both in the portal and outside it.
1928#define RF_ADDITIVE_DLIGHT (1<<22) // this entity has an additive dynamic light
1929#define RF_LIGHTSTYLE_DLIGHT (1<<23) // this entity has a dynamic light that uses a light style
1930#define RF_SHADOW_PRECISE (1<<24) // this entity can have a precise shadow applied to it
1931#define RF_INVISIBLE (1<<25) // This entity is invisible, and only negative lights will light it up
1932#define RF_ALWAYSDRAW (1<<26) // This entity is invisible, and only negative lights will light it up
1933#define RF_PRECISESHADOW (1<<28) // This entity is invisible, and only negative lights will light it up
1934//
1935// use this mask when propagating renderfx from one entity to another
1936//
1937#define RF_FLAGS_NOT_INHERITED ( RF_LENSFLARE | RF_VIEWLENSFLARE | RF_BEAM | RF_EXTRALIGHT | RF_SKYORIGIN | RF_SHADOW | RF_SHADOW_PRECISE | RF_SHADOW_PLANE )
1938
1939
1940//#define RF_ADDICTIVEDYNAMICLIGHT ?????
1941
1942#define RF_FORCENOLOD 1024
1943
1944#define BEAM_LIGHTNING_EFFECT (1<<0)
1945#define BEAM_USEMODEL (1<<1)
1946#define BEAM_PERSIST_EFFECT (1<<2)
1947#define BEAM_SPHERE_EFFECT (1<<3)
1948#define BEAM_RANDOM_DELAY (1<<4)
1949#define BEAM_TOGGLE (1<<5)
1950#define BEAM_RANDOM_TOGGLEDELAY (1<<6)
1951#define BEAM_WAVE_EFFECT (1<<7)
1952#define BEAM_USE_NOISE (1<<8)
1953#define BEAM_PARENT (1<<9)
1954#define BEAM_TILESHADER (1<<10)
1955#define BEAM_OFFSET_ENDPOINTS (1<<11)
1956#define BEAM_FADE (1<<12)
1957#define BEAM_INVERTED (1<<13)
1958#define BEAM_INVERTED_FAST (1<<14)
1959
1960typedef struct frameInfo_s {
1961 int index;
1962 float time;
1963 float weight;
1964} frameInfo_t;
1965
1966typedef enum {
1967 TR_STATIONARY,
1968 TR_INTERPOLATE, // non-parametric, but interpolate between snapshots
1969 TR_LINEAR,
1970 TR_LINEAR_STOP,
1971 TR_SINE, // value = base + sin( time / duration ) * delta
1972 TR_GRAVITY,
1973 TR_LERP
1974} trType_t;
1975
1976typedef struct {
1977 int trTime;
1978 vec3_t trDelta;
1979} trajectory_t;
1980
1981#define NUM_BONE_CONTROLLERS 5
1982
1983#define NUM_MORPH_CONTROLLERS 10
1984
1985#define MAX_MODEL_SURFACES 32 // this needs to be the same in qfiles.h for TIKI_MAX_SURFACES
1986
1987#define MDL_SURFACE_SKINOFFSET_BIT0 ( 1 << 0 )
1988#define MDL_SURFACE_SKINOFFSET_BIT1 ( 1 << 1 )
1989#define MDL_SURFACE_NODRAW ( 1 << 2 )
1990#define MDL_SURFACE_SURFACETYPE_BIT0 ( 1 << 3 )
1991#define MDL_SURFACE_SURFACETYPE_BIT1 ( 1 << 4 )
1992#define MDL_SURFACE_SURFACETYPE_BIT2 ( 1 << 5 )
1993#define MDL_SURFACE_CROSSFADE_SKINS ( 1 << 6 )
1994#define MDL_SURFACE_SKIN_NO_DAMAGE ( 1 << 7 )
1995
1996#define CROUCH_HEIGHT 36
1997#define CROUCH_EYE_HEIGHT 48
1998#define STAND_HEIGHT 72
1999#define STAND_EYE_HEIGHT 82
2000
2001#define MAX_FRAMEINFOS 16
2002#define FRAMEINFO_BLEND ( MAX_FRAMEINFOS >> 1 )
2003
2004// entityState_t is the information conveyed from the server
2005// in an update message about entities that the client will
2006// need to render in some way
2007// Different eTypes may use the information in different ways
2008// The messages are delta compressed, so it doesn't really matter if
2009// the structure size is fairly large
2010
2011typedef struct entityState_s {
2012 int number; // entity index
2013 int eType; // entityType_t
2014 int eFlags;
2015
2016 trajectory_t pos;
2017
2018 vec3_t netorigin;
2019 vec3_t origin;
2020 vec3_t origin2;
2021
2022 vec3_t netangles;
2023 vec3_t angles;
2024
2025 int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24)
2026 int loopSound; // constantly loop this sound
2027 float loopSoundVolume;
2028 float loopSoundMinDist;
2029 float loopSoundMaxDist;
2030 float loopSoundPitch;
2031 int loopSoundFlags;
2032
2033 int parent;
2034 int tag_num;
2035
2036 qboolean attach_use_angles;
2037 vec3_t attach_offset;
2038
2039 int beam_entnum;
2040
2041 int modelindex;
2042 int usageIndex;
2043 int skinNum;
2044 int wasframe;
2045 frameInfo_t frameInfo[ MAX_FRAMEINFOS ];
2046 float actionWeight;
2047
2048 int bone_tag[ NUM_BONE_CONTROLLERS ];
2049 vec3_t bone_angles[ NUM_BONE_CONTROLLERS ];
2050 quat_t bone_quat[ NUM_BONE_CONTROLLERS ]; // not sent over
2051 byte surfaces[ 32 ];
2052
2053 int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses
2054 int groundEntityNum; // -1 = in air
2055
2056 int solid; // for client side prediction, trap_linkentity sets this properly
2057
2058 float scale;
2059 float alpha;
2060 int renderfx;
2061 float shader_data[ 2 ];
2062 float shader_time;
2063 quat_t quat;
2064 vec3_t eyeVector;
2065} entityState_t;
2066
2067typedef enum {
2068 CA_UNINITIALIZED,
2069 CA_DISCONNECTED, // not talking to a server
2070 CA_AUTHORIZING, // not used any more, was checking cd key
2071 CA_CONNECTING, // sending request packets to the server
2072 CA_CHALLENGING, // sending challenge packets to the server
2073 CA_CONNECTED, // netchan_t established, getting gamestate
2074 CA_LOADING, // only during cgame initialization, never during main loop
2075 CA_PRIMED, // got gamestate, waiting for first frame
2076 CA_ACTIVE, // game views should be displayed
2077 CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server
2078} connstate_t;
2079
2080typedef struct qtime_s {
2081 int tm_sec;
2082 int tm_min;
2083 int tm_hour;
2084 int tm_mday;
2085 int tm_mon;
2086 int tm_year;
2087 int tm_wday;
2088 int tm_yday;
2089 int tm_isdst;
2090} qtime_t;
2091
2092typedef struct {
2093 float start[ 3 ];
2094 float end[ 3 ];
2095 float color[ 3 ];
2096 float alpha;
2097 float width;
2098 unsigned short factor;
2099 unsigned short pattern;
2100} debugline_t;
2101
2102typedef struct {
2103 char szText[ 64 ];
2104 float pos[ 3 ];
2105 float scale;
2106 float color[ 4 ];
2108
2109enum hdalign_e
2110{
2111 HUD_ALIGN_X_LEFT = 0,
2112 HUD_ALIGN_X_CENTER = 1,
2113 HUD_ALIGN_X_RIGHT = 2,
2114 HUD_ALIGN_Y_TOP = 0,
2115 HUD_ALIGN_Y_CENTER = 1,
2116 HUD_ALIGN_Y_BOTTOM = 2,
2117};
2118
2119typedef struct hdelement_s {
2120 qhandle_t hShader;
2121 char shaderName[ MAX_RES_NAME ];
2122
2123 int iX;
2124 int iY;
2125 int iWidth;
2126 int iHeight;
2127
2128 float vColor[ 4 ];
2129
2130 int iHorizontalAlign;
2131 int iVerticalAlign;
2132 qboolean bVirtualScreen;
2133
2134 char string[ MAX_STRING_CHARS ];
2135 char fontName[ MAX_RES_NAME ];
2136
2137 struct fontheader_s *pFont;
2138} hdelement_t;
2139
2140typedef struct {
2141 frameInfo_t g_VMFrameInfo[MAX_FRAMEINFOS];
2142
2143 int g_iLastVMAnim;
2144 int g_iLastVMAnimChanged;
2145 int g_iCurrentVMAnimSlot;
2146 int g_iCurrentVMDuration;
2147
2148 qboolean g_bCrossblending;
2149
2150 int g_iLastEquippedWeaponStat;
2151 char g_szLastActiveItem[ 80 ];
2152 int g_iLastAnimPrefixIndex;
2153
2154 float g_vCurrentVMPosOffset[ 3 ];
2155} clientAnim_t;
2156
2157#define GLYPH_START 0
2158#define GLYPH_END 255
2159#define GLYPH_CHARSTART 32
2160#define GLYPH_CHAREND 127
2161#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1
2162typedef struct {
2163 int height; // number of scan lines
2164 int top; // top of glyph in buffer
2165 int bottom; // bottom of glyph in buffer
2166 int pitch; // width for copying
2167 int xSkip; // x adjustment
2168 int imageWidth; // width of actual image
2169 int imageHeight; // height of actual image
2170 float s; // x offset in image where glyph starts
2171 float t; // y offset in image where glyph starts
2172 float s2;
2173 float t2;
2174 qhandle_t glyph; // handle to the shader with the glyph
2175 char shaderName[32];
2176} glyphInfo_t;
2177
2178typedef struct {
2179 glyphInfo_t glyphs [GLYPHS_PER_FONT];
2180 float glyphScale;
2181 char name[MAX_QPATH];
2182} fontInfo_t;
2183
2184#define Square(x) ((x)*(x))
2185
2186// real time
2187//=============================================
2188
2189// server browser sources
2190// TTimo: AS_MPLAYER is no longer used
2191#define AS_LOCAL 0
2192#define AS_MPLAYER 99
2193#define AS_GLOBAL 2
2194#define AS_FAVORITES 3
2195#define AS_GAMESPY 1 // wombat: right now we use AS_GLOBAL for GS, too
2196
2197
2198// cinematic states
2199typedef enum {
2200 FMV_IDLE,
2201 FMV_PLAY, // play
2202 FMV_EOF, // all other conditions, i.e. stop/EOF/abort
2203 FMV_ID_BLT,
2204 FMV_ID_IDLE,
2205 FMV_LOOPED,
2206 FMV_ID_WAIT
2207} e_status;
2208
2209typedef enum _flag_status {
2210 FLAG_ATBASE = 0,
2211 FLAG_TAKEN, // CTF
2212 FLAG_TAKEN_RED, // One Flag CTF
2213 FLAG_TAKEN_BLUE, // One Flag CTF
2214 FLAG_DROPPED
2215} flagStatus_t;
2216
2217//
2218// Radar system
2219//
2220typedef struct {
2221 int time;
2222 int lastSpeakTime;
2223 int teamShader;
2224 float origin[2];
2225 float axis[2];
2227
2228typedef struct {
2229 int clientNum;
2230 float x;
2231 float y;
2232 float yaw;
2234
2235#define MAX_GLOBAL_SERVERS 2048
2236#define MAX_OTHER_SERVERS 128
2237#define MAX_PINGREQUESTS 32
2238#define MAX_SERVERSTATUSREQUESTS 16
2239
2240#define SAY_ALL 0
2241#define SAY_TEAM 1
2242#define SAY_TELL 2
2243
2244#define CDKEY_LEN 16
2245#define CDCHKSUM_LEN 2
2246
2247#define FLOAT_TO_INT( x, fracbits ) ( ( x ) * ( 1 << ( fracbits ) ) )
2248
2249#define FLOAT_TO_PKT( x, dest, wholebits, fracbits ) \
2250 { \
2251 if ( ( x ) >= ( 1 << ( wholebits ) ) ) \
2252 { \
2253 ( dest ) = FLOAT_TO_INT( ( 1 << ( wholebits ) ), ( fracbits ) ) - 1; \
2254 } \
2255 else if ( ( x ) < 0 ) \
2256 { \
2257 ( dest ) = 0; \
2258 } \
2259 else \
2260 { \
2261 ( dest ) = FLOAT_TO_INT( ( x ), ( fracbits ) ); \
2262 } \
2263 }
2264
2265#define SIGNED_FLOAT_TO_PKT( x, dest, wholebits, fracbits ) \
2266 { \
2267 float temp_x; \
2268 temp_x = ( x ) + ( 1 << ( wholebits ) ); \
2269 if ( temp_x >= ( 1 << ( ( wholebits ) + 1 ) ) ) \
2270 ( dest ) = FLOAT_TO_INT( ( 1 << ( ( wholebits ) + 1 ) ), ( fracbits ) ) - 1; \
2271 else if ( temp_x < 0 ) \
2272 (dest) = 0; \
2273 else \
2274 ( dest ) = FLOAT_TO_INT( temp_x, ( fracbits ) ); \
2275 }
2276
2277#define INT_TO_FLOAT( x, wholebits, fracbits ) ( ( float )( ( ( float )( x ) ) / ( float )( 1 << ( fracbits ) ) - ( float )( 1 << ( wholebits ) ) ) )
2278#define UINT_TO_FLOAT( x, fracbits ) ( ( float )( ( ( float )( x ) ) / ( float )( 1 << ( fracbits ) ) ) )
2279
2280#define TRANSLATION_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 11 )
2281#define PKT_TO_TRANSLATION( x ) UINT_TO_FLOAT( ( x ), 11 )
2282
2283#define OFFSET_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 1, 14 )
2284#define PKT_TO_OFFSET( x ) UINT_TO_FLOAT( ( x ), 14 )
2285
2286#define ROTATE_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 9, 6 )
2287#define PKT_TO_ROTATE( x ) UINT_TO_FLOAT( ( x ), 6 )
2288
2289#define BASE_TO_PKT( x, dest ) SIGNED_FLOAT_TO_PKT( ( x ), ( dest ), 3, 4 )
2290#define PKT_TO_BASE( x ) INT_TO_FLOAT( ( x ), 3, 4 )
2291
2292#define AMPLITUDE_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2293#define PKT_TO_AMPLITUDE( x ) UINT_TO_FLOAT( ( x ), 4 )
2294
2295#define PHASE_TO_PKT( x, dest ) SIGNED_FLOAT_TO_PKT( ( x ), ( dest ), 3, 4 )
2296#define PKT_TO_PHASE( x ) INT_TO_FLOAT( ( x ), 3, 4 )
2297
2298#define FREQUENCY_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2299#define PKT_TO_FREQUENCY( x ) UINT_TO_FLOAT( ( x ), 4 )
2300
2301#define BEAM_PARM_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2302#define PKT_TO_BEAM_PARM( x ) UINT_TO_FLOAT( ( x ), 4 )
2303
2304#define STUB() printf( "STUB: function %s in %s line %d.\n", __FUNCTION__, __FILE__, __LINE__ )
2305#define STUB_DESC( description ) printf( "STUB: %s in %s line %d.\n", description, __FILE__, __LINE__ )
2306#define UNIMPLEMENTED() Com_Printf( "FIXME: (%s) is unimplemented (file %s:%d)\n", __FUNCTION__, __FILE__, __LINE__ )
2307
2308#if defined(__cplusplus)
2309}
2310#endif
2311
2312#ifdef __cplusplus
2313#include <chrono>
2314
2315using qcclock_t = std::chrono::steady_clock;
2316using qctime_t = qcclock_t::time_point;
2317using qctimedelta_t = qcclock_t::duration;
2318#endif
Definition q_shared.h:1517
Definition q_shared.h:2140
Definition q_shared.h:1415
Definition q_shared.h:1332
Definition q_shared.h:2092
Definition q_shared.h:2102
Definition q_shared.h:2011
Definition q_shared.h:2178
Definition tr_types_new.h:57
Definition q_shared.h:1960
Definition q_shared.h:1691
Definition g_public.h:168
Definition q_shared.h:2162
Definition q_shared.h:1100
Definition q_shared.h:2119
Definition q_shared.h:1491
Definition q_shared.h:1522
Definition q_shared.h:1152
Definition q_shared.h:1742
Definition q_shared.h:1235
Definition q_shared.h:2080
Definition q_shared.h:2220
Definition q_shared.h:2228
Definition q_shared.h:1470
Definition q_shared.h:1700
Definition q_shared.h:1450
Definition q_shared.h:1976
Definition q_shared.h:1497
Definition q_shared.h:1873
Definition q_shared.h:1713
Definition q_shared.h:1361
Definition q_shared.h:206