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);
1127void COM_DefaultExtension( char *path, int maxSize, const char *extension );
1128
1129void COM_BeginParseSession( const char *name );
1130int COM_GetCurrentParseLine( void );
1131const char *COM_Parse( char **data_p );
1132char *COM_ParseExt( char **data_p, qboolean allowLineBreak );
1133char *COM_ParseExtIgnoreQuotes( char **data_p, qboolean allowLineBreak );
1134const char *COM_GetToken( char **data_p, qboolean crossline );
1135void Com_SkipRestOfLine(char **data);
1136void Com_SkipBracedSection(char **program);
1137void Com_Parse1DMatrix(char **buf_p, int x, float *m, qboolean checkBrackets);
1138int COM_Compress( char *data_p );
1139void COM_ParseError( char *format, ... ) Q_PRINTF_FUNC(1, 2);
1140void COM_ParseWarning( char *format, ... ) Q_PRINTF_FUNC(1, 2);
1141//int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
1142
1143#define MAX_TOKENLENGTH 1024
1144
1145#ifndef TT_STRING
1146//token types
1147#define TT_STRING 1 // string
1148#define TT_LITERAL 2 // literal
1149#define TT_NUMBER 3 // number
1150#define TT_NAME 4 // name
1151#define TT_PUNCTUATION 5 // punctuation
1152#endif
1153
1154typedef struct pc_token_s
1155{
1156 int type;
1157 int subtype;
1158 int intvalue;
1159 float floatvalue;
1160 char string[MAX_TOKENLENGTH];
1161} pc_token_t;
1162
1163// data is an in/out parm, returns a parsed out token
1164
1165void COM_MatchToken( char**buf_p, char *match );
1166
1167qboolean SkipBracedSection (char **program, int depth);
1168void SkipRestOfLine ( char **data );
1169
1170void Parse1DMatrix (char **buf_p, int x, float *m);
1171void Parse2DMatrix (char **buf_p, int y, int x, float *m);
1172void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);
1173
1174int Com_HexStrToInt( const char *str );
1175
1176size_t QDECL Com_sprintf (char *dest, size_t size, const char *fmt, ...) Q_PRINTF_FUNC(3, 4);
1177
1178char *Com_SkipTokens( char *s, int numTokens, const char *sep );
1179char *Com_SkipCharset( char *s, const char *sep );
1180
1181void Com_RandomBytes(byte* string, int len);
1182void Com_BackslashToSlash( char *str );
1183
1184// mode parm for FS_FOpenFile
1185typedef enum {
1186 FS_READ,
1187 FS_WRITE,
1188 FS_APPEND,
1189 FS_APPEND_SYNC
1190} fsMode_t;
1191
1192typedef enum {
1193 FS_SEEK_CUR,
1194 FS_SEEK_END,
1195 FS_SEEK_SET
1196} fsOrigin_t;
1197
1198//=============================================
1199
1200// get the control character for the given key (moved from sdl_input.c)
1201#define CTRL(a) ((a)-'a'+1)
1202
1203int Q_isprint( int c );
1204int Q_islower( int c );
1205int Q_isupper( int c );
1206int Q_isalpha( int c );
1207qboolean Q_isanumber( const char *s );
1208qboolean Q_isintegral( float f );
1209
1210// portable case insensitive compare
1211int Q_stricmp (const char *s1, const char *s2);
1212int Q_strncmp( const char *s1, const char *s2, size_t n );
1213int Q_stricmpn (const char *s1, const char *s2, size_t n);
1214char *Q_strlwr( char *s1 );
1215char *Q_strupr( char *s1 );
1216char *Q_strrchr( const char* string, int c );
1217const char *Q_stristr( const char *s, const char *find);
1218qboolean Q_strreplace(char *dest, int destsize, const char *find, const char *replace);
1219
1220// buffer size safe library replacements
1221void Q_strncpyz( char *dest, const char *src, size_t destsize );
1222void Q_strcat( char *dest, int size, const char *src );
1223
1224// strlen that discounts Quake color sequences
1225int Q_PrintStrlen( const char *string );
1226// removes color sequences from string
1227char *Q_CleanStr( char *string );
1228// Count the number of char tocount encountered in string
1229int Q_CountChar(const char *string, char tocount);
1230
1231//=============================================
1232
1233void Swap_Init(void);
1234
1235// 64-bit integers for global rankings interface
1236// implemented as a struct for qvm compatibility
1237typedef struct
1238{
1239 byte b0;
1240 byte b1;
1241 byte b2;
1242 byte b3;
1243 byte b4;
1244 byte b5;
1245 byte b6;
1246 byte b7;
1247} qint64;
1248
1249void Swap_Init (void);
1250
1251const char * QDECL va(const char *format, ...) Q_PRINTF_FUNC(1, 2);
1252
1253#define TRUNCATE_LENGTH 64
1254void Com_TruncateLongString( char *buffer, const char *s );
1255
1256//=============================================
1257
1258float vectoyaw(const vec3_t vec);
1259int MusicMood_NameToNum( const char * name );
1260const char * MusicMood_NumToName( int num );
1261int EAXMode_NameToNum( const char * name );
1262const char * EAXMode_NumToName( int num );
1263
1264//
1265// key / value info strings
1266//
1267char *Info_ValueForKey( const char *s, const char *key );
1268void Info_RemoveKey( char *s, const char *key );
1269void Info_RemoveKey_big( char *s, const char *key );
1270void Info_SetValueForKey( char *s, const char *key, const char *value );
1271void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
1272qboolean Info_Validate( const char *s );
1273void Info_NextPair( const char **s, char *key, char *value );
1274
1275// this is only here so the functions in q_shared.c and bg_*.c can link
1276void QDECL Com_Error( int level, const char *error, ... ) Q_NO_RETURN Q_PRINTF_FUNC(2, 3);
1277void QDECL Com_Printf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1278void QDECL Com_DPrintf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1279void QDECL Com_DPrintf2( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1280void QDECL Com_DebugPrintf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2);
1281
1282
1283/*
1284==========================================================
1285
1286CVARS (console variables)
1287
1288Many variables can be used for cheating purposes, so when
1289cheats is zero, force all unspecified variables to their
1290default values.
1291==========================================================
1292*/
1293
1294#define CVAR_ARCHIVE 0x0001 // set to cause it to be saved to vars.rc
1295 // used for system variables, not for player
1296 // specific configurations
1297#define CVAR_USERINFO 0x0002 // sent to server on connect or change
1298#define CVAR_SERVERINFO 0x0004 // sent in response to front end requests
1299#define CVAR_SYSTEMINFO 0x0008 // these cvars will be duplicated on all clients
1300#define CVAR_INIT 0x0010 // don't allow change from console at all,
1301 // but can be set from the command line
1302#define CVAR_LATCH 0x0020 // will only change when C code next does
1303 // a Cvar_Get(), so it can't be changed
1304 // without proper initialization. modified
1305 // will be set, even though the value hasn't
1306 // changed yet
1307#define CVAR_ROM 0x0040 // display only, cannot be set by user at all
1308#define CVAR_USER_CREATED 0x0080 // created by a set command
1309#define CVAR_TEMP 0x0100 // can be set even when cheats are disabled, but is not archived
1310#define CVAR_CHEAT 0x0200 // can not be changed if cheats are disabled
1311#define CVAR_NORESTART 0x0400 // do not clear when a cvar_restart is issued
1312
1313#define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to.
1314
1315#define CVAR_SOUND_LATCH 0x1000 // specifically for sound will only change
1316 // when C code next does a Cvar_Get(), so it
1317 // can't be changed without proper initialization.
1318 // modified will be set, even though the value hasn't
1319 // changed yet
1320
1321#define CVAR_TERRAIN_LATCH 0x2000 // specifically for terrain will only change
1322
1323#define CVAR_SAVEGAME 0x4000 // cvar will be saved when saving to file
1324
1325#define CVAR_VM_CREATED 0x8000 // cvar was created exclusively in one of the VMs.
1326#define CVAR_PROTECTED 0x10000 // prevent modifying this var from VMs or the server
1327#define CVAR_RESETSTRING 0x20000 // force the cvar's reset string to be set
1328// These flags are only returned by the Cvar_Flags() function
1329#define CVAR_MODIFIED 0x40000000 // Cvar was modified
1330#define CVAR_NONEXISTENT 0x80000000 // Cvar doesn't exist.
1331
1332// nothing outside the Cvar_*() functions should modify these fields!
1333typedef struct cvar_s cvar_t;
1334
1335struct cvar_s {
1336 char *name;
1337 char *string;
1338 char *resetString; // cvar_restart will reset to this value
1339 char *latchedString; // for CVAR_LATCH vars
1340 int flags;
1341 qboolean modified; // set each time the cvar is changed
1342 int modificationCount; // incremented each time the cvar is changed
1343 float value; // atof( string )
1344 int integer; // atoi( string )
1345 qboolean validate;
1346 qboolean integral;
1347 float min;
1348 float max;
1349 char *description;
1350
1351 cvar_t *next;
1352 cvar_t *prev;
1353 cvar_t *hashNext;
1354 cvar_t *hashPrev;
1355 int hashIndex;
1356};
1357
1358#define MAX_CVAR_VALUE_STRING 256
1359
1360typedef int cvarHandle_t;
1361
1362// the modules that run in the virtual machine can't access the cvar_t directly,
1363// so they must ask for structured updates
1364typedef struct {
1365 cvarHandle_t handle;
1366 int modificationCount;
1367 float value;
1368 int integer;
1369 char string[MAX_CVAR_VALUE_STRING];
1370 char latchedString[MAX_CVAR_VALUE_STRING];
1371} vmCvar_t;
1372
1373/*
1374==============================================================
1375
1376COLLISION DETECTION
1377
1378==============================================================
1379*/
1380
1381#include "surfaceflags.h" // shared with the q3map utility
1382
1383// plane types are used to speed some tests
1384// 0-2 are axial planes
1385#define PLANE_X 0
1386#define PLANE_Y 1
1387#define PLANE_Z 2
1388#define PLANE_NON_AXIAL 3
1389#define PLANE_NON_PLANAR 4
1390
1391
1392/*
1393=================
1394PlaneTypeForNormal
1395=================
1396*/
1397
1398//#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) )
1399static ID_INLINE int PlaneTypeForNormal(vec3_t normal)
1400{
1401 if(normal[0] == 1.0)
1402 return PLANE_X;
1403
1404 if(normal[1] == 1.0)
1405 return PLANE_Y;
1406
1407 if(normal[2] == 1.0)
1408 return PLANE_Z;
1409
1410 if(normal[0] == 0.0 && normal[1] == 0.0 && normal[2] == 0.0)
1411 return PLANE_NON_PLANAR;
1412
1413 return PLANE_NON_AXIAL;
1414}
1415
1416// plane_t structure
1417// !!! if this is changed, it must be changed in asm code too !!!
1418typedef struct cplane_s {
1419 vec3_t normal;
1420 float dist;
1421 byte type; // for fast side tests: 0,1,2 = axial, 3 = nonaxial
1422 byte signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision
1423 byte pad[2];
1424} cplane_t;
1425
1426// body hit location
1427typedef enum hitloc_e {
1428 HITLOC_MISS = -2,
1429 HITLOC_GENERAL = -1,
1430 HITLOC_HEAD = 0,
1431 HITLOC_HELMET,
1432 HITLOC_NECK,
1433 HITLOC_TORSO_UPPER,
1434 HITLOC_TORSO_MID,
1435 HITLOC_TORSO_LOWER,
1436 HITLOC_PELVIS,
1437 HITLOC_R_ARM_UPPER,
1438 HITLOC_L_ARM_UPPER,
1439 HITLOC_R_LEG_UPPER,
1440 HITLOC_L_LEG_UPPER,
1441 HITLOC_R_ARM_LOWER,
1442 HITLOC_L_ARM_LOWER,
1443 HITLOC_R_LEG_LOWER,
1444 HITLOC_L_LEG_LOWER,
1445 HITLOC_R_HAND,
1446 HITLOC_L_HAND,
1447 HITLOC_R_FOOT,
1448 HITLOC_L_FOOT,
1449 NUMBODYLOCATIONS
1450} hitloc_t;
1451
1452// a trace is returned when a box is swept through the world
1453typedef struct {
1454 qboolean allsolid; // if true, plane is not valid
1455 qboolean startsolid; // if true, the initial point was in a solid area
1456 float fraction; // time completed, 1.0 = didn't hit anything
1457 vec3_t endpos; // final position
1458 cplane_t plane; // surface normal at impact, transformed to world space
1459 int surfaceFlags; // surface hit
1460 int shaderNum;
1461 int contents; // contents on other side of surface hit
1462 int entityNum; // entity the contacted surface is a part of
1463
1464 int location;
1465 struct gentity_s *ent;
1466} trace_t;
1467
1468// trace->entityNum can also be 0 to (MAX_GENTITIES-1)
1469// or ENTITYNUM_NONE, ENTITYNUM_WORLD
1470
1471#define SAVEGAME_STRUCT_VERSION 4
1472
1473typedef struct savegamestruct_s {
1474 //int version
1475 // Modified in OPM
1476 //===
1477 short version;
1478 // The type matches com_target_game
1479 byte type;
1480 // Currently unused
1481 byte flags;
1482 //===
1483 int time;
1484 int mapTime;
1485 char comment[ 64 ];
1486 char mapName[ 64 ];
1487 char saveName[ 64 ];
1488 char tm_filename[ 64 ];
1489 int tm_loopcount;
1490 int tm_offset;
1491} savegamestruct_t;
1492
1493// markfragments are returned by CM_MarkFragments()
1494typedef struct {
1495 int firstPoint;
1496 int numPoints;
1497 int iIndex;
1499
1500typedef struct treadMark_s {
1501 int iReferenceNumber;
1502 int iLastTime;
1503 qhandle_t hTreadShader;
1504 int iState;
1505 float fWidth;
1506 vec3_t vStartDir;
1507 vec3_t vStartVerts[ 2 ];
1508 float fStartTexCoord;
1509 float fStartAlpha;
1510 vec3_t vMidPos;
1511 vec3_t vMidVerts[ 2 ];
1512 float fMidTexCoord;
1513 float fMidAlpha;
1514 vec3_t vEndPos;
1515 vec3_t vEndVerts[ 2 ];
1516 float fEndTexCoord;
1517 float fEndAlpha;
1518} treadMark_t;
1519
1520typedef struct {
1521 vec3_t p;
1522 quat_t q;
1523} bone_t;
1524
1525typedef struct {
1526 vec3_t origin;
1527 vec3_t axis[ 3 ];
1529
1530//=====================================================================
1531
1532
1533// in order from highest priority to lowest
1534// if none of the catchers are active, bound key strings will be executed
1535#define KEYCATCH_CONSOLE 0x0001
1536#define KEYCATCH_UI 0x0002
1537#define KEYCATCH_MESSAGE 0x0004
1538#define KEYCATCH_CGAME 0x0008
1539
1540
1541// sound channels
1542// channel 0 never willingly overrides
1543// other channels will allways override a playing sound on that channel
1544/*typedef enum {
1545 CHAN_AUTO,
1546 CHAN_LOCAL, // menu sounds, etc
1547 CHAN_WEAPON,
1548 CHAN_VOICE,
1549 CHAN_ITEM,
1550 CHAN_BODY,
1551 CHAN_LOCAL_SOUND, // chat messages, etc
1552 CHAN_ANNOUNCER // announcer voices, etc
1553} soundChannel_t;*/
1554typedef enum {
1555 CHAN_AUTO,
1556 CHAN_BODY,
1557 CHAN_ITEM,
1558 CHAN_WEAPONIDLE,
1559 CHAN_VOICE,
1560 CHAN_LOCAL,
1561 CHAN_WEAPON,
1562 CHAN_DIALOG_SECONDARY,
1563 CHAN_DIALOG,
1564 CHAN_MENU,
1565 CHAN_LOCAL_SOUND, // chat messages, etc
1566 CHAN_ANNOUNCER, // announcer voices, etc
1567 CHAN_MAX
1568} soundChannel_t;
1569
1570#define S_FLAG_DO_CALLBACK 0x400
1571
1572#define DEFAULT_MIN_DIST -1.0
1573#define DEFAULT_VOL -1.0
1574
1575#define LEVEL_WIDE_MIN_DIST 10000 // full volume the entire level
1576#define LEVEL_WIDE_STRING "levelwide"
1577
1578#define SOUND_SYNCH 0x1
1579#define SOUND_SYNCH_FADE 0x2
1580#define SOUND_RANDOM_PITCH_20 0x4
1581#define SOUND_RANDOM_PITCH_40 0x8
1582#define SOUND_LOCAL_DIALOG 0x10
1583
1584typedef enum
1585{
1586 mood_none,
1587 mood_normal,
1588 mood_action,
1589 mood_suspense,
1590 mood_mystery,
1591 mood_success,
1592 mood_failure,
1593 mood_surprise,
1594 mood_special,
1595 mood_aux1,
1596 mood_aux2,
1597 mood_aux3,
1598 mood_aux4,
1599 mood_aux5,
1600 mood_aux6,
1601 mood_aux7,
1602 mood_totalnumber
1603} music_mood_t;
1604
1605typedef enum
1606{
1607 eax_generic,
1608 eax_paddedcell,
1609 eax_room,
1610 eax_bathroom,
1611 eax_livingroom,
1612 eax_stoneroom,
1613 eax_auditorium,
1614 eax_concerthall,
1615 eax_cave,
1616 eax_arena,
1617 eax_hangar,
1618 eax_carpetedhallway,
1619 eax_hallway,
1620 eax_stonecorridor,
1621 eax_alley,
1622 eax_forest,
1623 eax_city,
1624 eax_mountains,
1625 eax_quarry,
1626 eax_plain,
1627 eax_parkinglot,
1628 eax_sewerpipe,
1629 eax_underwater,
1630 eax_drugged,
1631 eax_dizzy,
1632 eax_psychotic,
1633 eax_totalnumber
1634} eax_mode_t;
1635
1636/*
1637========================================================================
1638
1639 ELEMENTS COMMUNICATED ACROSS THE NET
1640
1641========================================================================
1642*/
1643
1644#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535)
1645#define BYTE2ANGLE(x) ((x)*(360.0/255))
1646#define SHORT2ANGLE(x) ((x)*(360.0/65536))
1647
1648#define SNAPFLAG_RATE_DELAYED 1
1649#define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies
1650#define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected
1651
1652//
1653// per-level limits
1654//
1655#define MAX_CLIENTS 64 // absolute limit
1656#define MAX_LOCATIONS 64
1657
1658#define MAX_MAP_BOUNDS 8192
1659#define MIN_MAP_BOUNDS ( -MAX_MAP_BOUNDS )
1660#define MAP_SIZE ( MAX_MAP_BOUNDS - MIN_MAP_BOUNDS )
1661
1662#define GENTITYNUM_BITS 10 // don't need to send any more
1663#define MAX_GENTITIES (1<<GENTITYNUM_BITS)
1664
1665// entitynums are communicated with GENTITY_BITS, so any reserved
1666// values that are going to be communcated over the net need to
1667// also be in this range
1668#define ENTITYNUM_NONE (MAX_GENTITIES-1)
1669#define ENTITYNUM_WORLD (MAX_GENTITIES-2)
1670#define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-2)
1671
1672#define MAX_SERVER_SOUNDS 64
1673#define MAX_SERVER_SOUNDS_BITS (MAX_SERVER_SOUNDS-1)
1674
1675#define MAX_MODELS 1024 // these are sent over the net as 8 bits
1676#define MAX_SOUNDS 512 // so they cannot be blindly increased
1677#define MAX_OBJECTIVES 20
1678#define MAX_LIGHTSTYLES 32
1679#define MAX_WEAPONS 64
1680
1681#define MAX_CONFIGSTRINGS 2736
1682#define MAX_HUDDRAW_ELEMENTS 256
1683
1684#define MAX_SUBTITLES 4
1685
1686// these are the only configstrings that the system reserves, all the
1687// other ones are strictly for servergame to clientgame communication
1688#define CS_SERVERINFO 0 // an info string with all the serverinfo cvars
1689#define CS_SYSTEMINFO 1 // an info string for server system to client system configuration (timescale, etc)
1690
1691#define RESERVED_CONFIGSTRINGS 2 // game can't modify below this, only the system can
1692
1693#define MAX_GAMESTATE_CHARS 41952
1694typedef struct {
1695 int stringOffsets[MAX_CONFIGSTRINGS];
1696 char stringData[MAX_GAMESTATE_CHARS];
1697 int dataCount;
1698} gameState_t;
1699
1700//=========================================================
1701
1702// maybe this is better put somewhere else...
1703typedef struct server_sound_s {
1704 vec3_t origin;
1705 int entity_number;
1706 int channel;
1707 short int sound_index;
1708 float volume;
1709 float min_dist;
1710 float maxDist;
1711 float pitch;
1712 qboolean stop_flag;
1713 qboolean streamed;
1714} server_sound_t;
1715
1716typedef struct usereyes_s {
1717 signed char ofs[ 3 ];
1718 float angles[ 2 ];
1719} usereyes_t;
1720
1721// bit field limits
1722#define MAX_STATS 32
1723#define MAX_ACTIVE_ITEMS 8
1724#define MAX_AMMO 16
1725#define MAX_AMMOCOUNT 16
1726
1727#define MAX_PERSISTANT 16
1728#define MAX_POWERUPS 16
1729
1730#define MAX_PS_EVENTS 2
1731
1732#define PS_PMOVEFRAMECOUNTBITS 6
1733
1734// playerState_t is the information needed by both the client and server
1735// to predict player motion and actions
1736// nothing outside of pmove should modify these, or some degree of prediction error
1737// will occur
1738
1739// you can't add anything to this without modifying the code in msg.c
1740
1741// playerState_t is a full superset of entityState_t as it is used by players,
1742// so if a playerState_t is transmitted, the entityState_t can be fully derived
1743// from it.
1744
1745typedef struct playerState_s {
1746 int commandTime; // cmd->serverTime of last executed command
1747 int pm_type;
1748 int bobCycle; // for view bobbing and footstep generation
1749 int net_pm_flags; // ducked, jump_held, etc
1750 int pm_flags; // ducked, jump_held, etc
1751 int pm_time;
1752
1753 vec3_t origin;
1754 vec3_t velocity;
1755
1756 int gravity;
1757 int speed;
1758 int delta_angles[3]; // add to command angles to get view direction
1759 // changed by spawns, rotating objects, and teleporters
1760
1761 int groundEntityNum; // ENTITYNUM_NONE = in air
1762
1763 qboolean walking;
1764 qboolean groundPlane;
1765 int feetfalling;
1766 float falldir[3];
1767 trace_t groundTrace;
1768
1769 int clientNum; // ranges from 0 to MAX_CLIENTS-1
1770
1771 vec3_t viewangles; // for fixed views
1772 int viewheight;
1773
1774 float fLeanAngle;
1775 int iNetViewModelAnim;
1776 int iViewModelAnim;
1777 int iViewModelAnimChanged;
1778
1779 int stats[MAX_STATS];
1780 int activeItems[MAX_ACTIVE_ITEMS];
1781 int ammo_name_index[MAX_AMMO];
1782 int ammo_amount[MAX_AMMOCOUNT];
1783 int max_ammo_amount[MAX_AMMOCOUNT];
1784
1785 int current_music_mood;
1786 int fallback_music_mood;
1787 float music_volume;
1788 float music_volume_fade_time;
1789
1790 int reverb_type;
1791 float reverb_level;
1792
1793 float blend[4]; // rgba full screen effect
1794 float fov; // fov of the player
1795
1796 vec3_t camera_origin; // origin for camera view
1797 vec3_t camera_angles; // angles for camera view
1798 float camera_time;
1799
1800 vec3_t camera_offset; // angular offset for camera
1801 vec3_t camera_posofs;
1802 int camera_flags; // third-person camera flags
1803 vec3_t damage_angles; // these angles are added directly to the view, without lerping
1804 // --
1805 // Team Assault
1806 int radarInfo;
1807 qboolean voted;
1808 // --
1809
1810 // not communicated over the net at all
1811 int ping; // server to game info for scoreboard
1812 float vEyePos[3];
1813} playerState_t;
1814
1815
1816//====================================================================
1817
1818//
1819// usercmd_t->button bits, many of which are generated by the client system,
1820// so they aren't game-only definitions
1821//
1822#define BUTTON_ATTACKLEFT_BITINDEX 0
1823#define BUTTON_ATTACKRIGHT_BITINDEX 1
1824#define BUTTON_RUN_BITINDEX 2
1825#define BUTTON_USE_BITINDEX 3
1826#define BUTTON_LEAN_LEFT_BITINDEX 4
1827#define BUTTON_LEAN_RIGHT_BITINDEX 5
1828#define BUTTON_TALK_BITINDEX 6 // displays talk balloon and disables actions
1829#define BUTTON_ANY_BITINDEX 14 // any key whatsoever
1830#define BUTTON_MOUSE_BITINDEX 15 // mouse move
1831
1832#define BUTTON_ATTACKLEFT (1 << BUTTON_ATTACKLEFT_BITINDEX)
1833#define BUTTON_ATTACKRIGHT (1 << BUTTON_ATTACKRIGHT_BITINDEX)
1834#define BUTTON_RUN (1 << BUTTON_RUN_BITINDEX)
1835#define BUTTON_USE (1 << BUTTON_USE_BITINDEX)
1836#define BUTTON_LEAN_LEFT (1 << BUTTON_LEAN_LEFT_BITINDEX)
1837#define BUTTON_LEAN_RIGHT (1 << BUTTON_LEAN_RIGHT_BITINDEX)
1838#define BUTTON_TALK (1 << BUTTON_TALK_BITINDEX) // displays talk balloon and disables actions
1839#define BUTTON_ANY (1 << BUTTON_ANY_BITINDEX) // any key whatsoever
1840#define BUTTON_MOUSE (1 << BUTTON_MOUSE_BITINDEX)
1841
1842typedef enum {
1843 WEAPON_COMMAND_NONE,
1844 WEAPON_COMMAND_USE_PISTOL,
1845 WEAPON_COMMAND_USE_RIFLE,
1846 WEAPON_COMMAND_USE_SMG,
1847 WEAPON_COMMAND_USE_MG,
1848 WEAPON_COMMAND_USE_GRENADE,
1849 WEAPON_COMMAND_USE_HEAVY,
1850 WEAPON_COMMAND_USE_ITEM1,
1851 WEAPON_COMMAND_USE_ITEM2,
1852 WEAPON_COMMAND_USE_ITEM3,
1853 WEAPON_COMMAND_USE_ITEM4,
1854 WEAPON_COMMAND_USE_PREV_WEAPON,
1855 WEAPON_COMMAND_USE_NEXT_WEAPON,
1856 WEAPON_COMMAND_USE_LAST_WEAPON,
1857 WEAPON_COMMAND_HOLSTER,
1858 WEAPON_COMMAND_DROP,
1859} weaponcommand_t;
1860
1861#define WEAPON_COMMAND_MAX_VER6 15
1862#define WEAPON_COMMAND_MAX_VER17 31
1863
1864static unsigned int GetWeaponCommandMask(unsigned int maxCmds) {
1865 return maxCmds << 7;
1866}
1867
1868static unsigned int GetWeaponCommand(unsigned int buttons, unsigned int maxCmds) {
1869 return (buttons & (maxCmds << 7)) >> 7;
1870}
1871
1872#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN,
1873 // then BUTTON_WALKING should be set
1874
1875// usercmd_t is sent to the server each client frame
1876typedef struct usercmd_s {
1877 int serverTime;
1878 byte msec;
1879 short unsigned int buttons;
1880 short int angles[3];
1881 //int weapon; // su44: there is no 'weapon' field
1882 // in MoHAA's usercmd_s - weapon commands are encoded
1883 // into buttons bits. See CL_CmdButtons from cl_input.c.
1884 signed char forwardmove, rightmove, upmove;
1885} usercmd_t;
1886
1887//===================================================================
1888
1889//
1890// Animation flags
1891//
1892#define MDL_ANIM_DELTA_DRIVEN ( 1 << 0 )
1893#define MDL_ANIM_DEFAULT_ANGLES ( 1 << 3 )
1894#define MDL_ANIM_NO_TIMECHECK ( 1 << 4 )
1895
1896// if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
1897#define SOLID_BMODEL 0xffffff
1898
1899// renderfx flags (entityState_t::renderfx)
1900// su44: moved it here, in MoHAA (and FAKK)
1901// render flags are set by "renderEffects" event
1902// and sent to cgame trough entityState_t
1903// TODO: find out rest of them
1904#define RF_THIRD_PERSON (1<<0) // don't draw through eyes, only mirrors (player bodies, chat sprites)
1905#define RF_FIRST_PERSON (1<<1) // only draw through eyes (view weapon, damage blood blob)
1906#define RF_DEPTHHACK (1<<2) // hack the z-depth so that view weapons do not clip into walls
1907#define RF_VIEWLENSFLARE (1<<3) // View dependent lensflare
1908#define RF_FRAMELERP (1<<4) // interpolate between current and next state
1909#define RF_BEAM (1<<5) // draw a beam between origin and origin2
1910#define RF_DONTDRAW (1<<7) // don't draw this entity but send it over
1911#define RF_LENSFLARE (1<<8) // add a lens flare to this
1912#define RF_EXTRALIGHT (1<<9) // use good lighting on this entity
1913#define RF_DETAIL (1<<10) // Culls a model based on the distance away from you
1914#define RF_SHADOW (1<<11) // whether or not to draw a shadow
1915#define RF_PORTALSURFACE (1<<12) // don't draw, but use to set portal views
1916#define RF_SKYORIGIN (1<<13) // don't draw, but use to set sky portal origin and coordinate system
1917#define RF_SKYENTITY (1<<14) // this entity is only visible through a skyportal
1918#define RF_LIGHTOFFSET (1<<15) // this entity has a light offset
1919#define RF_CUSTOMSHADERPASS (1<<16) // draw the custom shader on top of the base geometry
1920#define RF_MINLIGHT (1<<17) // allways have some light (viewmodel, some items)
1921#define RF_FULLBRIGHT (1<<18) // allways have full lighting
1922#define RF_LIGHTING_ORIGIN (1<<19) // use refEntity->lightingOrigin instead of refEntity->origin
1923// for lighting. This allows entities to sink into the floor
1924// with their origin going solid, and allows all parts of a
1925// player to get the same lighting
1926#define RF_SHADOW_PLANE (1<<20) // use refEntity->shadowPlane
1927#define RF_WRAP_FRAMES (1<<21) // mod the model frames by the maxframes to allow continuous
1928// animation without needing to know the frame count
1929//#define RF_PORTALENTITY (1<<22) // this entity should only be drawn from a portal
1930//#define RF_DUALENTITY (1<<23) // this entity is drawn both in the portal and outside it.
1931#define RF_ADDITIVE_DLIGHT (1<<22) // this entity has an additive dynamic light
1932#define RF_LIGHTSTYLE_DLIGHT (1<<23) // this entity has a dynamic light that uses a light style
1933#define RF_SHADOW_PRECISE (1<<24) // this entity can have a precise shadow applied to it
1934#define RF_INVISIBLE (1<<25) // This entity is invisible, and only negative lights will light it up
1935#define RF_ALWAYSDRAW (1<<26) // This entity is invisible, and only negative lights will light it up
1936#define RF_PRECISESHADOW (1<<28) // This entity is invisible, and only negative lights will light it up
1937//
1938// use this mask when propagating renderfx from one entity to another
1939//
1940#define RF_FLAGS_NOT_INHERITED ( RF_LENSFLARE | RF_VIEWLENSFLARE | RF_BEAM | RF_EXTRALIGHT | RF_SKYORIGIN | RF_SHADOW | RF_SHADOW_PRECISE | RF_SHADOW_PLANE )
1941
1942
1943//#define RF_ADDICTIVEDYNAMICLIGHT ?????
1944
1945#define RF_FORCENOLOD 1024
1946
1947#define BEAM_LIGHTNING_EFFECT (1<<0)
1948#define BEAM_USEMODEL (1<<1)
1949#define BEAM_PERSIST_EFFECT (1<<2)
1950#define BEAM_SPHERE_EFFECT (1<<3)
1951#define BEAM_RANDOM_DELAY (1<<4)
1952#define BEAM_TOGGLE (1<<5)
1953#define BEAM_RANDOM_TOGGLEDELAY (1<<6)
1954#define BEAM_WAVE_EFFECT (1<<7)
1955#define BEAM_USE_NOISE (1<<8)
1956#define BEAM_PARENT (1<<9)
1957#define BEAM_TILESHADER (1<<10)
1958#define BEAM_OFFSET_ENDPOINTS (1<<11)
1959#define BEAM_FADE (1<<12)
1960#define BEAM_INVERTED (1<<13)
1961#define BEAM_INVERTED_FAST (1<<14)
1962
1963typedef struct frameInfo_s {
1964 int index;
1965 float time;
1966 float weight;
1967} frameInfo_t;
1968
1969typedef enum {
1970 TR_STATIONARY,
1971 TR_INTERPOLATE, // non-parametric, but interpolate between snapshots
1972 TR_LINEAR,
1973 TR_LINEAR_STOP,
1974 TR_SINE, // value = base + sin( time / duration ) * delta
1975 TR_GRAVITY,
1976 TR_LERP
1977} trType_t;
1978
1979typedef struct {
1980 int trTime;
1981 vec3_t trDelta;
1982} trajectory_t;
1983
1984#define NUM_BONE_CONTROLLERS 5
1985
1986#define NUM_MORPH_CONTROLLERS 10
1987
1988#define MAX_MODEL_SURFACES 32 // this needs to be the same in qfiles.h for TIKI_MAX_SURFACES
1989
1990#define MDL_SURFACE_SKINOFFSET_BIT0 ( 1 << 0 )
1991#define MDL_SURFACE_SKINOFFSET_BIT1 ( 1 << 1 )
1992#define MDL_SURFACE_NODRAW ( 1 << 2 )
1993#define MDL_SURFACE_SURFACETYPE_BIT0 ( 1 << 3 )
1994#define MDL_SURFACE_SURFACETYPE_BIT1 ( 1 << 4 )
1995#define MDL_SURFACE_SURFACETYPE_BIT2 ( 1 << 5 )
1996#define MDL_SURFACE_CROSSFADE_SKINS ( 1 << 6 )
1997#define MDL_SURFACE_SKIN_NO_DAMAGE ( 1 << 7 )
1998
1999#define CROUCH_HEIGHT 36
2000#define CROUCH_EYE_HEIGHT 48
2001#define STAND_HEIGHT 72
2002#define STAND_EYE_HEIGHT 82
2003
2004#define MAX_FRAMEINFOS 16
2005#define FRAMEINFO_BLEND ( MAX_FRAMEINFOS >> 1 )
2006
2007// entityState_t is the information conveyed from the server
2008// in an update message about entities that the client will
2009// need to render in some way
2010// Different eTypes may use the information in different ways
2011// The messages are delta compressed, so it doesn't really matter if
2012// the structure size is fairly large
2013
2014typedef struct entityState_s {
2015 int number; // entity index
2016 int eType; // entityType_t
2017 int eFlags;
2018
2019 trajectory_t pos;
2020
2021 vec3_t netorigin;
2022 vec3_t origin;
2023 vec3_t origin2;
2024
2025 vec3_t netangles;
2026 vec3_t angles;
2027
2028 int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24)
2029 int loopSound; // constantly loop this sound
2030 float loopSoundVolume;
2031 float loopSoundMinDist;
2032 float loopSoundMaxDist;
2033 float loopSoundPitch;
2034 int loopSoundFlags;
2035
2036 int parent;
2037 int tag_num;
2038
2039 qboolean attach_use_angles;
2040 vec3_t attach_offset;
2041
2042 int beam_entnum;
2043
2044 int modelindex;
2045 int usageIndex;
2046 int skinNum;
2047 int wasframe;
2048 frameInfo_t frameInfo[ MAX_FRAMEINFOS ];
2049 float actionWeight;
2050
2051 int bone_tag[ NUM_BONE_CONTROLLERS ];
2052 vec3_t bone_angles[ NUM_BONE_CONTROLLERS ];
2053 quat_t bone_quat[ NUM_BONE_CONTROLLERS ]; // not sent over
2054 byte surfaces[ 32 ];
2055
2056 int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses
2057 int groundEntityNum; // -1 = in air
2058
2059 int solid; // for client side prediction, trap_linkentity sets this properly
2060
2061 float scale;
2062 float alpha;
2063 int renderfx;
2064 float shader_data[ 2 ];
2065 float shader_time;
2066 quat_t quat;
2067 vec3_t eyeVector;
2068} entityState_t;
2069
2070typedef enum {
2071 CA_UNINITIALIZED,
2072 CA_DISCONNECTED, // not talking to a server
2073 CA_AUTHORIZING, // not used any more, was checking cd key
2074 CA_CONNECTING, // sending request packets to the server
2075 CA_CHALLENGING, // sending challenge packets to the server
2076 CA_CONNECTED, // netchan_t established, getting gamestate
2077 CA_LOADING, // only during cgame initialization, never during main loop
2078 CA_PRIMED, // got gamestate, waiting for first frame
2079 CA_ACTIVE, // game views should be displayed
2080 CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server
2081} connstate_t;
2082
2083typedef struct qtime_s {
2084 int tm_sec;
2085 int tm_min;
2086 int tm_hour;
2087 int tm_mday;
2088 int tm_mon;
2089 int tm_year;
2090 int tm_wday;
2091 int tm_yday;
2092 int tm_isdst;
2093} qtime_t;
2094
2095typedef struct {
2096 float start[ 3 ];
2097 float end[ 3 ];
2098 float color[ 3 ];
2099 float alpha;
2100 float width;
2101 unsigned short factor;
2102 unsigned short pattern;
2103} debugline_t;
2104
2105typedef struct {
2106 char szText[ 64 ];
2107 float pos[ 3 ];
2108 float scale;
2109 float color[ 4 ];
2111
2112enum hdalign_e
2113{
2114 HUD_ALIGN_X_LEFT = 0,
2115 HUD_ALIGN_X_CENTER = 1,
2116 HUD_ALIGN_X_RIGHT = 2,
2117 HUD_ALIGN_Y_TOP = 0,
2118 HUD_ALIGN_Y_CENTER = 1,
2119 HUD_ALIGN_Y_BOTTOM = 2,
2120};
2121
2122typedef struct hdelement_s {
2123 qhandle_t hShader;
2124 char shaderName[ MAX_RES_NAME ];
2125
2126 int iX;
2127 int iY;
2128 int iWidth;
2129 int iHeight;
2130
2131 float vColor[ 4 ];
2132
2133 int iHorizontalAlign;
2134 int iVerticalAlign;
2135 qboolean bVirtualScreen;
2136
2137 char string[ MAX_STRING_CHARS ];
2138 char fontName[ MAX_RES_NAME ];
2139
2140 struct fontheader_s *pFont;
2141} hdelement_t;
2142
2143typedef struct {
2144 frameInfo_t g_VMFrameInfo[MAX_FRAMEINFOS];
2145
2146 int g_iLastVMAnim;
2147 int g_iLastVMAnimChanged;
2148 int g_iCurrentVMAnimSlot;
2149 int g_iCurrentVMDuration;
2150
2151 qboolean g_bCrossblending;
2152
2153 int g_iLastEquippedWeaponStat;
2154 char g_szLastActiveItem[ 80 ];
2155 int g_iLastAnimPrefixIndex;
2156
2157 float g_vCurrentVMPosOffset[ 3 ];
2158} clientAnim_t;
2159
2160#define GLYPH_START 0
2161#define GLYPH_END 255
2162#define GLYPH_CHARSTART 32
2163#define GLYPH_CHAREND 127
2164#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1
2165typedef struct {
2166 int height; // number of scan lines
2167 int top; // top of glyph in buffer
2168 int bottom; // bottom of glyph in buffer
2169 int pitch; // width for copying
2170 int xSkip; // x adjustment
2171 int imageWidth; // width of actual image
2172 int imageHeight; // height of actual image
2173 float s; // x offset in image where glyph starts
2174 float t; // y offset in image where glyph starts
2175 float s2;
2176 float t2;
2177 qhandle_t glyph; // handle to the shader with the glyph
2178 char shaderName[32];
2179} glyphInfo_t;
2180
2181typedef struct {
2182 glyphInfo_t glyphs [GLYPHS_PER_FONT];
2183 float glyphScale;
2184 char name[MAX_QPATH];
2185} fontInfo_t;
2186
2187#define Square(x) ((x)*(x))
2188
2189// real time
2190//=============================================
2191
2192// server browser sources
2193// TTimo: AS_MPLAYER is no longer used
2194#define AS_LOCAL 0
2195#define AS_MPLAYER 99
2196#define AS_GLOBAL 2
2197#define AS_FAVORITES 3
2198#define AS_GAMESPY 1 // wombat: right now we use AS_GLOBAL for GS, too
2199
2200
2201// cinematic states
2202typedef enum {
2203 FMV_IDLE,
2204 FMV_PLAY, // play
2205 FMV_EOF, // all other conditions, i.e. stop/EOF/abort
2206 FMV_ID_BLT,
2207 FMV_ID_IDLE,
2208 FMV_LOOPED,
2209 FMV_ID_WAIT
2210} e_status;
2211
2212typedef enum _flag_status {
2213 FLAG_ATBASE = 0,
2214 FLAG_TAKEN, // CTF
2215 FLAG_TAKEN_RED, // One Flag CTF
2216 FLAG_TAKEN_BLUE, // One Flag CTF
2217 FLAG_DROPPED
2218} flagStatus_t;
2219
2220//
2221// Radar system
2222//
2223typedef struct {
2224 int time;
2225 int lastSpeakTime;
2226 int teamShader;
2227 float origin[2];
2228 float axis[2];
2230
2231typedef struct {
2232 int clientNum;
2233 float x;
2234 float y;
2235 float yaw;
2237
2238#define MAX_GLOBAL_SERVERS 2048
2239#define MAX_OTHER_SERVERS 128
2240#define MAX_PINGREQUESTS 32
2241#define MAX_SERVERSTATUSREQUESTS 16
2242
2243#define SAY_ALL 0
2244#define SAY_TEAM 1
2245#define SAY_TELL 2
2246
2247#define CDKEY_LEN 16
2248#define CDCHKSUM_LEN 2
2249
2250#define FLOAT_TO_INT( x, fracbits ) ( ( x ) * ( 1 << ( fracbits ) ) )
2251
2252#define FLOAT_TO_PKT( x, dest, wholebits, fracbits ) \
2253 { \
2254 if ( ( x ) >= ( 1 << ( wholebits ) ) ) \
2255 { \
2256 ( dest ) = FLOAT_TO_INT( ( 1 << ( wholebits ) ), ( fracbits ) ) - 1; \
2257 } \
2258 else if ( ( x ) < 0 ) \
2259 { \
2260 ( dest ) = 0; \
2261 } \
2262 else \
2263 { \
2264 ( dest ) = FLOAT_TO_INT( ( x ), ( fracbits ) ); \
2265 } \
2266 }
2267
2268#define SIGNED_FLOAT_TO_PKT( x, dest, wholebits, fracbits ) \
2269 { \
2270 float temp_x; \
2271 temp_x = ( x ) + ( 1 << ( wholebits ) ); \
2272 if ( temp_x >= ( 1 << ( ( wholebits ) + 1 ) ) ) \
2273 ( dest ) = FLOAT_TO_INT( ( 1 << ( ( wholebits ) + 1 ) ), ( fracbits ) ) - 1; \
2274 else if ( temp_x < 0 ) \
2275 (dest) = 0; \
2276 else \
2277 ( dest ) = FLOAT_TO_INT( temp_x, ( fracbits ) ); \
2278 }
2279
2280#define INT_TO_FLOAT( x, wholebits, fracbits ) ( ( float )( ( ( float )( x ) ) / ( float )( 1 << ( fracbits ) ) - ( float )( 1 << ( wholebits ) ) ) )
2281#define UINT_TO_FLOAT( x, fracbits ) ( ( float )( ( ( float )( x ) ) / ( float )( 1 << ( fracbits ) ) ) )
2282
2283#define TRANSLATION_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 11 )
2284#define PKT_TO_TRANSLATION( x ) UINT_TO_FLOAT( ( x ), 11 )
2285
2286#define OFFSET_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 1, 14 )
2287#define PKT_TO_OFFSET( x ) UINT_TO_FLOAT( ( x ), 14 )
2288
2289#define ROTATE_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 9, 6 )
2290#define PKT_TO_ROTATE( x ) UINT_TO_FLOAT( ( x ), 6 )
2291
2292#define BASE_TO_PKT( x, dest ) SIGNED_FLOAT_TO_PKT( ( x ), ( dest ), 3, 4 )
2293#define PKT_TO_BASE( x ) INT_TO_FLOAT( ( x ), 3, 4 )
2294
2295#define AMPLITUDE_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2296#define PKT_TO_AMPLITUDE( x ) UINT_TO_FLOAT( ( x ), 4 )
2297
2298#define PHASE_TO_PKT( x, dest ) SIGNED_FLOAT_TO_PKT( ( x ), ( dest ), 3, 4 )
2299#define PKT_TO_PHASE( x ) INT_TO_FLOAT( ( x ), 3, 4 )
2300
2301#define FREQUENCY_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2302#define PKT_TO_FREQUENCY( x ) UINT_TO_FLOAT( ( x ), 4 )
2303
2304#define BEAM_PARM_TO_PKT( x, dest ) FLOAT_TO_PKT( ( x ), ( dest ), 4, 4 )
2305#define PKT_TO_BEAM_PARM( x ) UINT_TO_FLOAT( ( x ), 4 )
2306
2307#define STUB() printf( "STUB: function %s in %s line %d.\n", __FUNCTION__, __FILE__, __LINE__ )
2308#define STUB_DESC( description ) printf( "STUB: %s in %s line %d.\n", description, __FILE__, __LINE__ )
2309#define UNIMPLEMENTED() Com_Printf( "FIXME: (%s) is unimplemented (file %s:%d)\n", __FUNCTION__, __FILE__, __LINE__ )
2310
2311#if defined(__cplusplus)
2312}
2313#endif
2314
2315#ifdef __cplusplus
2316#include <chrono>
2317
2318using qcclock_t = std::chrono::steady_clock;
2319using qctime_t = qcclock_t::time_point;
2320using qctimedelta_t = qcclock_t::duration;
2321#endif
Definition q_shared.h:1520
Definition q_shared.h:2143
Definition q_shared.h:1418
Definition q_shared.h:1335
Definition q_shared.h:2095
Definition q_shared.h:2105
Definition q_shared.h:2014
Definition q_shared.h:2181
Definition tr_types_new.h:57
Definition q_shared.h:1963
Definition q_shared.h:1694
Definition g_public.h:168
Definition q_shared.h:2165
Definition q_shared.h:1103
Definition q_shared.h:2122
Definition q_shared.h:1494
Definition q_shared.h:1525
Definition q_shared.h:1155
Definition q_shared.h:1745
Definition q_shared.h:1238
Definition q_shared.h:2083
Definition q_shared.h:2223
Definition q_shared.h:2231
Definition q_shared.h:1473
Definition q_shared.h:1703
Definition q_shared.h:1453
Definition q_shared.h:1979
Definition q_shared.h:1500
Definition q_shared.h:1876
Definition q_shared.h:1716
Definition q_shared.h:1364
Definition q_shared.h:208