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