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