Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

q_shared.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 //
00023 #ifndef __Q_SHARED_H
00024 #define __Q_SHARED_H
00025 
00026 // q_shared.h -- included first by ALL program modules.
00027 // A user mod should never modify this file
00028 
00029 #define Q3_VERSION      "Q3 1.32b"
00030 // 1.32 released 7-10-2002
00031 
00032 #define MAX_TEAMNAME 32
00033 
00034 /*#ifdef _WIN32
00035 
00036 #pragma warning(disable : 4018)     // signed/unsigned mismatch
00037 #pragma warning(disable : 4032)
00038 #pragma warning(disable : 4051)
00039 #pragma warning(disable : 4057)     // slightly different base types
00040 #pragma warning(disable : 4100)     // unreferenced formal parameter
00041 #pragma warning(disable : 4115)
00042 #pragma warning(disable : 4125)     // decimal digit terminates octal escape sequence
00043 #pragma warning(disable : 4127)     // conditional expression is constant
00044 #pragma warning(disable : 4136)
00045 #pragma warning(disable : 4152)     // nonstandard extension, function/data pointer conversion in expression
00046 //#pragma warning(disable : 4201)
00047 //#pragma warning(disable : 4214)
00048 #pragma warning(disable : 4244)
00049 #pragma warning(disable : 4142)     // benign redefinition
00050 //#pragma warning(disable : 4305)       // truncation from const double to float
00051 //#pragma warning(disable : 4310)       // cast truncates constant value
00052 //#pragma warning(disable:  4505)   // unreferenced local function has been removed
00053 #pragma warning(disable : 4514)
00054 #pragma warning(disable : 4702)     // unreachable code
00055 #pragma warning(disable : 4711)     // selected for automatic inline expansion
00056 #pragma warning(disable : 4220)     // varargs matches remaining parameters
00057 #endif*/
00058 
00059 /**********************************************************************
00060   VM Considerations
00061 
00062   The VM can not use the standard system headers because we aren't really
00063   using the compiler they were meant for.  We use bg_lib.h which contains
00064   prototypes for the functions we define for our own use in bg_lib.c.
00065 
00066   When writing mods, please add needed headers HERE, do not start including
00067   stuff like <stdio.h> in the various .c files that make up each of the VMs
00068   since you will be including system headers files can will have issues.
00069 
00070   Remember, if you use a C library function that is not defined in bg_lib.c,
00071   you will have to add your own version for support in the VM.
00072 
00073  **********************************************************************/
00074 
00075 #ifdef Q3_VM
00076 
00077 #include "bg_lib.h"
00078 
00079 #else
00080 
00081 #include <assert.h>
00082 #include <math.h>
00083 #include <stdio.h>
00084 #include <stdarg.h>
00085 #include <string.h>
00086 #include <stdlib.h>
00087 #include <time.h>
00088 #include <ctype.h>
00089 #include <limits.h>
00090 
00091 #endif
00092 
00093 #ifdef _WIN32
00094 
00095 //#pragma intrinsic( memset, memcpy )
00096 
00097 #endif
00098 
00099 
00100 // this is the define for determining if we have an asm version of a C function
00101 #if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__
00102 #define id386   1
00103 #else
00104 #define id386   0
00105 #endif
00106 
00107 #if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
00108 #define idppc   1
00109 #if defined(__VEC__)
00110 #define idppc_altivec 1
00111 #else
00112 #define idppc_altivec 0
00113 #endif
00114 #else
00115 #define idppc   0
00116 #define idppc_altivec 0
00117 #endif
00118 
00119 // for windows fastcall option
00120 
00121 #define QDECL
00122 
00123 short   ShortSwap (short l);
00124 int     LongSwap (int l);
00125 float   FloatSwap (const float *f);
00126 
00127 //======================= WIN32 DEFINES =================================
00128 
00129 #ifdef WIN32
00130 
00131 #define MAC_STATIC
00132 
00133 #undef QDECL
00134 #define QDECL   __cdecl
00135 
00136 // buildstring will be incorporated into the version string
00137 #ifdef NDEBUG
00138 #ifdef _M_IX86
00139 #define CPUSTRING   "win-x86"
00140 #elif defined _M_ALPHA
00141 #define CPUSTRING   "win-AXP"
00142 #endif
00143 #else
00144 #ifdef _M_IX86
00145 #define CPUSTRING   "win-x86-debug"
00146 #elif defined _M_ALPHA
00147 #define CPUSTRING   "win-AXP-debug"
00148 #endif
00149 #endif
00150 
00151 #define ID_INLINE __inline 
00152 
00153 static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
00154 #define LittleShort
00155 static ID_INLINE int BigLong(int l) { LongSwap(l); }
00156 #define LittleLong
00157 static ID_INLINE float BigFloat(const float *l) { FloatSwap(l); }
00158 #define LittleFloat
00159 
00160 #define PATH_SEP '\\'
00161 
00162 #endif
00163 
00164 //======================= MAC OS X DEFINES =====================
00165 
00166 #if defined(MACOS_X)
00167 
00168 #define MAC_STATIC
00169 #define __cdecl
00170 #define __declspec(x)
00171 #define stricmp strcasecmp
00172 #define ID_INLINE inline 
00173 
00174 #ifdef __ppc__
00175 #define CPUSTRING   "MacOSX-ppc"
00176 #elif defined __i386__
00177 #define CPUSTRING   "MacOSX-i386"
00178 #else
00179 #define CPUSTRING   "MacOSX-other"
00180 #endif
00181 
00182 #define PATH_SEP    '/'
00183 
00184 #define __rlwimi(out, in, shift, maskBegin, maskEnd) asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), "i" (shift), "i" (maskBegin), "i" (maskEnd))
00185 #define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset))
00186 
00187 static inline unsigned int __lwbrx(register void *addr, register int offset) {
00188     register unsigned int word;
00189     
00190     asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
00191     return word;
00192 }
00193 
00194 static inline unsigned short __lhbrx(register void *addr, register int offset) {
00195     register unsigned short halfword;
00196     
00197     asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset));
00198     return halfword;
00199 }
00200 
00201 static inline float __fctiw(register float f) {
00202     register float fi;
00203     
00204     asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
00205 
00206     return fi;
00207 }
00208 
00209 #define BigShort
00210 static inline short LittleShort(short l) { return ShortSwap(l); }
00211 #define BigLong
00212 static inline int LittleLong (int l) { return LongSwap(l); }
00213 #define BigFloat
00214 static inline float LittleFloat (const float l) { return FloatSwap(&l); }
00215 
00216 #endif
00217 
00218 //======================= MAC DEFINES =================================
00219 
00220 #ifdef __MACOS__
00221 
00222 #include <MacTypes.h>
00223 #define MAC_STATIC
00224 #define ID_INLINE inline 
00225 
00226 #define CPUSTRING   "MacOS-PPC"
00227 
00228 #define PATH_SEP ':'
00229 
00230 void Sys_PumpEvents( void );
00231 
00232 #define BigShort
00233 static inline short LittleShort(short l) { return ShortSwap(l); }
00234 #define BigLong
00235 static inline int LittleLong (int l) { return LongSwap(l); }
00236 #define BigFloat
00237 static inline float LittleFloat (const float l) { return FloatSwap(&l); }
00238 
00239 #endif
00240 
00241 //======================= LINUX DEFINES =================================
00242 
00243 // the mac compiler can't handle >32k of locals, so we
00244 // just waste space and make big arrays static...
00245 #ifdef __linux__
00246 
00247 // bk001205 - from Makefile
00248 #define stricmp strcasecmp
00249 
00250 #define MAC_STATIC // bk: FIXME
00251 #define ID_INLINE inline 
00252 
00253 #ifdef __i386__
00254 #define CPUSTRING   "linux-i386"
00255 #elif defined __axp__
00256 #define CPUSTRING   "linux-alpha"
00257 #else
00258 #define CPUSTRING   "linux-other"
00259 #endif
00260 
00261 #define PATH_SEP '/'
00262 
00263 // bk001205 - try
00264 #ifdef Q3_STATIC
00265 #define GAME_HARD_LINKED
00266 #define CGAME_HARD_LINKED
00267 #define UI_HARD_LINKED
00268 #define BOTLIB_HARD_LINKED
00269 #endif
00270 
00271 #if !idppc
00272 inline static short BigShort( short l) { return ShortSwap(l); }
00273 #define LittleShort
00274 inline static int BigLong(int l) { return LongSwap(l); }
00275 #define LittleLong
00276 inline static float BigFloat(const float *l) { return FloatSwap(l); }
00277 #define LittleFloat
00278 #else
00279 #define BigShort
00280 inline static short LittleShort(short l) { return ShortSwap(l); }
00281 #define BigLong
00282 inline static int LittleLong (int l) { return LongSwap(l); }
00283 #define BigFloat
00284 inline static float LittleFloat (const float *l) { return FloatSwap(l); }
00285 #endif
00286 
00287 #endif
00288 
00289 //======================= FreeBSD DEFINES =====================
00290 #ifdef __FreeBSD__ // rb010123
00291 
00292 #define stricmp strcasecmp
00293 
00294 #define MAC_STATIC
00295 #define ID_INLINE inline 
00296 
00297 #ifdef __i386__
00298 #define CPUSTRING       "freebsd-i386"
00299 #elif defined __axp__
00300 #define CPUSTRING       "freebsd-alpha"
00301 #else
00302 #define CPUSTRING       "freebsd-other"
00303 #endif
00304 
00305 #define PATH_SEP '/'
00306 
00307 // bk010116 - omitted Q3STATIC (see Linux above), broken target
00308 
00309 #if !idppc
00310 static short BigShort( short l) { return ShortSwap(l); }
00311 #define LittleShort
00312 static int BigLong(int l) { LongSwap(l); }
00313 #define LittleLong
00314 static float BigFloat(const float *l) { FloatSwap(l); }
00315 #define LittleFloat
00316 #else
00317 #define BigShort
00318 static short LittleShort(short l) { return ShortSwap(l); }
00319 #define BigLong
00320 static int LittleLong (int l) { return LongSwap(l); }
00321 #define BigFloat
00322 static float LittleFloat (const float *l) { return FloatSwap(l); }
00323 #endif
00324 
00325 #endif
00326 
00327 //=============================================================
00328 
00329 typedef unsigned char       byte;
00330 
00331 typedef enum {qfalse, qtrue}    qboolean;
00332 
00333 typedef int     qhandle_t;
00334 typedef int     sfxHandle_t;
00335 typedef int     fileHandle_t;
00336 typedef int     clipHandle_t;
00337 
00338 
00339 #ifndef NULL
00340 #define NULL ((void *)0)
00341 #endif
00342 
00343 #define MAX_QINT            0x7fffffff
00344 #define MIN_QINT            (-MAX_QINT-1)
00345 
00346 
00347 // angle indexes
00348 #define PITCH               0       // up / down
00349 #define YAW                 1       // left / right
00350 #define ROLL                2       // fall over
00351 
00352 // the game guarantees that no string from the network will ever
00353 // exceed MAX_STRING_CHARS
00354 #define MAX_STRING_CHARS    1024    // max length of a string passed to Cmd_TokenizeString
00355 #define MAX_STRING_TOKENS   1024    // max tokens resulting from Cmd_TokenizeString
00356 #define MAX_TOKEN_CHARS     1024    // max length of an individual token
00357 
00358 #define MAX_INFO_STRING     1024
00359 #define MAX_INFO_KEY          1024
00360 #define MAX_INFO_VALUE      1024
00361 
00362 #define BIG_INFO_STRING     8192  // used for system info key only
00363 #define BIG_INFO_KEY          8192
00364 #define BIG_INFO_VALUE      8192
00365 
00366 
00367 #define MAX_QPATH           64      // max length of a quake game pathname
00368 #ifdef PATH_MAX
00369 #define MAX_OSPATH          PATH_MAX
00370 #else
00371 #define MAX_OSPATH          256     // max length of a filesystem pathname
00372 #endif
00373 
00374 #define MAX_NAME_LENGTH     32      // max length of a client name
00375 
00376 #define MAX_SAY_TEXT    150
00377 
00378 // paramters for command buffer stuffing
00379 typedef enum {
00380     EXEC_NOW,           // don't return until completed, a VM should NEVER use this,
00381                         // because some commands might cause the VM to be unloaded...
00382     EXEC_INSERT,        // insert at current position, but don't run yet
00383     EXEC_APPEND         // add to end of the command buffer (normal case)
00384 } cbufExec_t;
00385 
00386 
00387 //
00388 // these aren't needed by any of the VMs.  put in another header?
00389 //
00390 #define MAX_MAP_AREA_BYTES      32      // bit vector of area visibility
00391 
00392 
00393 // print levels from renderer (FIXME: set up for game / cgame?)
00394 typedef enum {
00395     PRINT_ALL,
00396     PRINT_DEVELOPER,        // only print when "developer 1"
00397     PRINT_WARNING,
00398     PRINT_ERROR
00399 } printParm_t;
00400 
00401 
00402 #ifdef ERR_FATAL
00403 #undef ERR_FATAL            // this is be defined in malloc.h
00404 #endif
00405 
00406 // parameters to the main Error routine
00407 typedef enum {
00408     ERR_FATAL,                  // exit the entire game with a popup window
00409     ERR_DROP,                   // print to console and disconnect from game
00410     ERR_SERVERDISCONNECT,       // don't kill server
00411     ERR_DISCONNECT,             // client disconnected from the server
00412     ERR_NEED_CD                 // pop up the need-cd dialog
00413 } errorParm_t;
00414 
00415 
00416 // font rendering values used by ui and cgame
00417 
00418 #define PROP_GAP_WIDTH          3
00419 #define PROP_SPACE_WIDTH        8
00420 #define PROP_HEIGHT             27
00421 #define PROP_SMALL_SIZE_SCALE   0.75
00422 
00423 #define BLINK_DIVISOR           200
00424 #define PULSE_DIVISOR           75
00425 
00426 #define UI_LEFT         0x00000000  // default
00427 #define UI_CENTER       0x00000001
00428 #define UI_RIGHT        0x00000002
00429 #define UI_FORMATMASK   0x00000007
00430 #define UI_SMALLFONT    0x00000010
00431 #define UI_BIGFONT      0x00000020  // default
00432 #define UI_GIANTFONT    0x00000040
00433 #define UI_DROPSHADOW   0x00000800
00434 #define UI_BLINK        0x00001000
00435 #define UI_INVERSE      0x00002000
00436 #define UI_PULSE        0x00004000
00437 
00438 #if defined(_DEBUG) && !defined(BSPC)
00439     #define HUNK_DEBUG
00440 #endif
00441 
00442 typedef enum {
00443     h_high,
00444     h_low,
00445     h_dontcare
00446 } ha_pref;
00447 
00448 #ifdef HUNK_DEBUG
00449 #define Hunk_Alloc( size, preference )              Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__)
00450 void *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line );
00451 #else
00452 void *Hunk_Alloc( int size, ha_pref preference );
00453 #endif
00454 
00455 #ifdef __linux__
00456 // https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=371
00457 // custom Snd_Memset implementation for glibc memset bug workaround
00458 void Snd_Memset (void* dest, const int val, const size_t count);
00459 #else
00460 #define Snd_Memset Com_Memset
00461 #endif
00462 
00463 #if !( defined __VECTORC )
00464 void Com_Memset (void* dest, const int val, const size_t count);
00465 void Com_Memcpy (void* dest, const void* src, const size_t count);
00466 #else
00467 #define Com_Memset memset
00468 #define Com_Memcpy memcpy
00469 #endif
00470 
00471 #define CIN_system  1
00472 #define CIN_loop    2
00473 #define CIN_hold    4
00474 #define CIN_silent  8
00475 #define CIN_shader  16
00476 
00477 /*
00478 ==============================================================
00479 
00480 MATHLIB
00481 
00482 ==============================================================
00483 */
00484 
00485 
00486 typedef float vec_t;
00487 typedef vec_t vec2_t[2];
00488 typedef vec_t vec3_t[3];
00489 typedef vec_t vec4_t[4];
00490 typedef vec_t vec5_t[5];
00491 
00492 typedef int fixed4_t;
00493 typedef int fixed8_t;
00494 typedef int fixed16_t;
00495 
00496 #ifndef M_PI
00497 #define M_PI        3.14159265358979323846f // matches value in gcc v2 math.h
00498 #endif
00499 
00500 #define NUMVERTEXNORMALS    162
00501 extern  vec3_t  bytedirs[NUMVERTEXNORMALS];
00502 
00503 // all drawing is done to a 640*480 virtual screen size
00504 // and will be automatically scaled to the real resolution
00505 #define SCREEN_WIDTH        640
00506 #define SCREEN_HEIGHT       480
00507 
00508 #define TINYCHAR_WIDTH      (SMALLCHAR_WIDTH)
00509 #define TINYCHAR_HEIGHT     (SMALLCHAR_HEIGHT/2)
00510 
00511 #define SMALLCHAR_WIDTH     8
00512 #define SMALLCHAR_HEIGHT    16
00513 
00514 #define BIGCHAR_WIDTH       16
00515 #define BIGCHAR_HEIGHT      16
00516 
00517 #define GIANTCHAR_WIDTH     32
00518 #define GIANTCHAR_HEIGHT    48
00519 
00520 extern  vec4_t      colorBlack;
00521 extern  vec4_t      colorRed;
00522 extern  vec4_t      colorGreen;
00523 extern  vec4_t      colorBlue;
00524 extern  vec4_t      colorYellow;
00525 extern  vec4_t      colorMagenta;
00526 extern  vec4_t      colorCyan;
00527 extern  vec4_t      colorWhite;
00528 extern  vec4_t      colorLtGrey;
00529 extern  vec4_t      colorMdGrey;
00530 extern  vec4_t      colorDkGrey;
00531 
00532 #define Q_COLOR_ESCAPE  '^'
00533 #define Q_IsColorString(p)  ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )
00534 
00535 #define COLOR_BLACK     '0'
00536 #define COLOR_RED       '1'
00537 #define COLOR_GREEN     '2'
00538 #define COLOR_YELLOW    '3'
00539 #define COLOR_BLUE      '4'
00540 #define COLOR_CYAN      '5'
00541 #define COLOR_MAGENTA   '6'
00542 #define COLOR_WHITE     '7'
00543 #define ColorIndex(c)   ( ( (c) - '0' ) & 7 )
00544 
00545 #define S_COLOR_BLACK   "^0"
00546 #define S_COLOR_RED     "^1"
00547 #define S_COLOR_GREEN   "^2"
00548 #define S_COLOR_YELLOW  "^3"
00549 #define S_COLOR_BLUE    "^4"
00550 #define S_COLOR_CYAN    "^5"
00551 #define S_COLOR_MAGENTA "^6"
00552 #define S_COLOR_WHITE   "^7"
00553 
00554 extern vec4_t   g_color_table[8];
00555 
00556 #define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b
00557 #define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a
00558 
00559 #define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )
00560 #define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )
00561 
00562 struct cplane_s;
00563 
00564 extern  vec3_t  vec3_origin;
00565 extern  vec3_t  axisDefault[3];
00566 
00567 #define nanmask (255<<23)
00568 
00569 #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
00570 
00571 #if idppc
00572 
00573 static inline float Q_rsqrt( float number ) {
00574         float x = 0.5f * number;
00575                 float y;
00576 #ifdef __GNUC__            
00577                 asm("frsqrte %0,%1" : "=f" (y) : "f" (number));
00578 #else
00579         y = __frsqrte( number );
00580 #endif
00581         return y * (1.5f - (x * y * y));
00582     }
00583 
00584 #ifdef __GNUC__            
00585 static inline float Q_fabs(float x) {
00586     float abs_x;
00587     
00588     asm("fabs %0,%1" : "=f" (abs_x) : "f" (x));
00589     return abs_x;
00590 }
00591 #else
00592 #define Q_fabs __fabsf
00593 #endif
00594 
00595 #else
00596 float Q_fabs( float f );
00597 float Q_rsqrt( float f );       // reciprocal square root
00598 #endif
00599 
00600 #define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) )
00601 
00602 signed char ClampChar( int i );
00603 signed short ClampShort( int i );
00604 
00605 // this isn't a real cheap function to call!
00606 int DirToByte( vec3_t dir );
00607 void ByteToDir( int b, vec3_t dir );
00608 
00609 #if 1
00610 
00611 #define DotProduct(x,y)         ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
00612 #define VectorSubtract(a,b,c)   ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
00613 #define VectorAdd(a,b,c)        ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
00614 #define VectorCopy(a,b)         ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
00615 #define VectorScale(v, s, o)    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
00616 #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))
00617 
00618 #else
00619 
00620 #define DotProduct(x,y)         _DotProduct(x,y)
00621 #define VectorSubtract(a,b,c)   _VectorSubtract(a,b,c)
00622 #define VectorAdd(a,b,c)        _VectorAdd(a,b,c)
00623 #define VectorCopy(a,b)         _VectorCopy(a,b)
00624 #define VectorScale(v, s, o)    _VectorScale(v,s,o)
00625 #define VectorMA(v, s, b, o)    _VectorMA(v,s,b,o)
00626 
00627 #endif
00628 
00629 #ifdef __LCC__
00630 #ifdef VectorCopy
00631 #undef VectorCopy
00632 // this is a little hack to get more efficient copies in our interpreter
00633 typedef struct {
00634     float   v[3];
00635 } vec3struct_t;
00636 #define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a)
00637 #define ID_INLINE static
00638 #endif
00639 #endif
00640 
00641 #define VectorClear(a)          ((a)[0]=(a)[1]=(a)[2]=0)
00642 #define VectorNegate(a,b)       ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
00643 #define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
00644 #define Vector4Copy(a,b)        ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
00645 
00646 #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));}
00647 // just in case you do't want to use the macros
00648 vec_t _DotProduct( const vec3_t v1, const vec3_t v2 );
00649 void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out );
00650 void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out );
00651 void _VectorCopy( const vec3_t in, vec3_t out );
00652 void _VectorScale( const vec3_t in, float scale, vec3_t out );
00653 void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc );
00654 
00655 unsigned ColorBytes3 (float r, float g, float b);
00656 unsigned ColorBytes4 (float r, float g, float b, float a);
00657 
00658 float NormalizeColor( const vec3_t in, vec3_t out );
00659 
00660 float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
00661 void ClearBounds( vec3_t mins, vec3_t maxs );
00662 void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
00663 
00664 #ifndef __LCC__
00665 static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
00666     if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
00667         return 0;
00668     }           
00669     return 1;
00670 }
00671 
00672 static ID_INLINE vec_t VectorLength( const vec3_t v ) {
00673     return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
00674 }
00675 
00676 static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {
00677     return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
00678 }
00679 
00680 static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
00681     vec3_t  v;
00682 
00683     VectorSubtract (p2, p1, v);
00684     return VectorLength( v );
00685 }
00686 
00687 static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
00688     vec3_t  v;
00689 
00690     VectorSubtract (p2, p1, v);
00691     return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
00692 }
00693 
00694 // fast vector normalize routine that does not check to make sure
00695 // that length != 0, nor does it return length, uses rsqrt approximation
00696 static ID_INLINE void VectorNormalizeFast( vec3_t v )
00697 {
00698     float ilength;
00699 
00700     ilength = Q_rsqrt( DotProduct( v, v ) );
00701 
00702     v[0] *= ilength;
00703     v[1] *= ilength;
00704     v[2] *= ilength;
00705 }
00706 
00707 static ID_INLINE void VectorInverse( vec3_t v ){
00708     v[0] = -v[0];
00709     v[1] = -v[1];
00710     v[2] = -v[2];
00711 }
00712 
00713 static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {
00714     cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
00715     cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
00716     cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
00717 }
00718 
00719 #else
00720 int VectorCompare( const vec3_t v1, const vec3_t v2 );
00721 
00722 vec_t VectorLength( const vec3_t v );
00723 
00724 vec_t VectorLengthSquared( const vec3_t v );
00725 
00726 vec_t Distance( const vec3_t p1, const vec3_t p2 );
00727 
00728 vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
00729  
00730 void VectorNormalizeFast( vec3_t v );
00731 
00732 void VectorInverse( vec3_t v );
00733 
00734 void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );
00735 
00736 #endif
00737 
00738 vec_t VectorNormalize (vec3_t v);       // returns vector length
00739 vec_t VectorNormalize2( const vec3_t v, vec3_t out );
00740 void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out );
00741 void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out );
00742 int Q_log2(int val);
00743 
00744 float Q_acos(float c);
00745 
00746 int     Q_rand( int *seed );
00747 float   Q_random( int *seed );
00748 float   Q_crandom( int *seed );
00749 
00750 #define random()    ((rand () & 0x7fff) / ((float)0x7fff))
00751 #define crandom()   (2.0 * (random() - 0.5))
00752 
00753 void vectoangles( const vec3_t value1, vec3_t angles);
00754 void AnglesToAxis( const vec3_t angles, vec3_t axis[3] );
00755 
00756 void AxisClear( vec3_t axis[3] );
00757 void AxisCopy( vec3_t in[3], vec3_t out[3] );
00758 
00759 void SetPlaneSignbits( struct cplane_s *out );
00760 int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
00761 
00762 float   AngleMod(float a);
00763 float   LerpAngle (float from, float to, float frac);
00764 float   AngleSubtract( float a1, float a2 );
00765 void    AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 );
00766 
00767 float AngleNormalize360 ( float angle );
00768 float AngleNormalize180 ( float angle );
00769 float AngleDelta ( float angle1, float angle2 );
00770 
00771 qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
00772 void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
00773 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
00774 void RotateAroundDirection( vec3_t axis[3], float yaw );
00775 void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up );
00776 // perpendicular vector could be replaced by this
00777 
00778 //int   PlaneTypeForNormal (vec3_t normal);
00779 
00780 void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]);
00781 void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
00782 void PerpendicularVector( vec3_t dst, const vec3_t src );
00783 
00784 
00785 //=============================================
00786 
00787 float Com_Clamp( float min, float max, float value );
00788 
00789 char    *COM_SkipPath( char *pathname );
00790 void    COM_StripExtension( const char *in, char *out );
00791 void    COM_DefaultExtension( char *path, int maxSize, const char *extension );
00792 
00793 void    COM_BeginParseSession( const char *name );
00794 int     COM_GetCurrentParseLine( void );
00795 char    *COM_Parse( char **data_p );
00796 char    *COM_ParseExt( char **data_p, qboolean allowLineBreak );
00797 int     COM_Compress( char *data_p );
00798 void    COM_ParseError( char *format, ... );
00799 void    COM_ParseWarning( char *format, ... );
00800 //int       COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
00801 
00802 #define MAX_TOKENLENGTH     1024
00803 
00804 #ifndef TT_STRING
00805 //token types
00806 #define TT_STRING                   1           // string
00807 #define TT_LITERAL                  2           // literal
00808 #define TT_NUMBER                   3           // number
00809 #define TT_NAME                     4           // name
00810 #define TT_PUNCTUATION              5           // punctuation
00811 #endif
00812 
00813 typedef struct pc_token_s
00814 {
00815     int type;
00816     int subtype;
00817     int intvalue;
00818     float floatvalue;
00819     char string[MAX_TOKENLENGTH];
00820 } pc_token_t;
00821 
00822 // data is an in/out parm, returns a parsed out token
00823 
00824 void    COM_MatchToken( char**buf_p, char *match );
00825 
00826 void SkipBracedSection (char **program);
00827 void SkipRestOfLine ( char **data );
00828 
00829 void Parse1DMatrix (char **buf_p, int x, float *m);
00830 void Parse2DMatrix (char **buf_p, int y, int x, float *m);
00831 void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m);
00832 
00833 void    QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
00834 
00835 
00836 // mode parm for FS_FOpenFile
00837 typedef enum {
00838     FS_READ,
00839     FS_WRITE,
00840     FS_APPEND,
00841     FS_APPEND_SYNC
00842 } fsMode_t;
00843 
00844 typedef enum {
00845     FS_SEEK_CUR,
00846     FS_SEEK_END,
00847     FS_SEEK_SET
00848 } fsOrigin_t;
00849 
00850 //=============================================
00851 
00852 int Q_isprint( int c );
00853 int Q_islower( int c );
00854 int Q_isupper( int c );
00855 int Q_isalpha( int c );
00856 
00857 // portable case insensitive compare
00858 int     Q_stricmp (const char *s1, const char *s2);
00859 int     Q_strncmp (const char *s1, const char *s2, int n);
00860 int     Q_stricmpn (const char *s1, const char *s2, int n);
00861 char    *Q_strlwr( char *s1 );
00862 char    *Q_strupr( char *s1 );
00863 char    *Q_strrchr( const char* string, int c );
00864 
00865 // buffer size safe library replacements
00866 void    Q_strncpyz( char *dest, const char *src, int destsize );
00867 void    Q_strcat( char *dest, int size, const char *src );
00868 
00869 // strlen that discounts Quake color sequences
00870 int Q_PrintStrlen( const char *string );
00871 // removes color sequences from string
00872 char *Q_CleanStr( char *string );
00873 
00874 //=============================================
00875 
00876 // 64-bit integers for global rankings interface
00877 // implemented as a struct for qvm compatibility
00878 typedef struct
00879 {
00880     byte    b0;
00881     byte    b1;
00882     byte    b2;
00883     byte    b3;
00884     byte    b4;
00885     byte    b5;
00886     byte    b6;
00887     byte    b7;
00888 } qint64;
00889 
00890 //=============================================
00891 /*
00892 short   BigShort(short l);
00893 short   LittleShort(short l);
00894 int     BigLong (int l);
00895 int     LittleLong (int l);
00896 qint64  BigLong64 (qint64 l);
00897 qint64  LittleLong64 (qint64 l);
00898 float   BigFloat (const float *l);
00899 float   LittleFloat (const float *l);
00900 
00901 void    Swap_Init (void);
00902 */
00903 char    * QDECL va(char *format, ...);
00904 
00905 //=============================================
00906 
00907 //
00908 // key / value info strings
00909 //
00910 char *Info_ValueForKey( const char *s, const char *key );
00911 void Info_RemoveKey( char *s, const char *key );
00912 void Info_RemoveKey_big( char *s, const char *key );
00913 void Info_SetValueForKey( char *s, const char *key, const char *value );
00914 void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
00915 qboolean Info_Validate( const char *s );
00916 void Info_NextPair( const char **s, char *key, char *value );
00917 
00918 // this is only here so the functions in q_shared.c and bg_*.c can link
00919 void    QDECL Com_Error( int level, const char *error, ... );
00920 void    QDECL Com_Printf( const char *msg, ... );
00921 
00922 
00923 /*
00924 ==========================================================
00925 
00926 CVARS (console variables)
00927 
00928 Many variables can be used for cheating purposes, so when
00929 cheats is zero, force all unspecified variables to their
00930 default values.
00931 ==========================================================
00932 */
00933 
00934 #define CVAR_ARCHIVE        1   // set to cause it to be saved to vars.rc
00935                                 // used for system variables, not for player
00936                                 // specific configurations
00937 #define CVAR_USERINFO       2   // sent to server on connect or change
00938 #define CVAR_SERVERINFO     4   // sent in response to front end requests
00939 #define CVAR_SYSTEMINFO     8   // these cvars will be duplicated on all clients
00940 #define CVAR_INIT           16  // don't allow change from console at all,
00941                                 // but can be set from the command line
00942 #define CVAR_LATCH          32  // will only change when C code next does
00943                                 // a Cvar_Get(), so it can't be changed
00944                                 // without proper initialization.  modified
00945                                 // will be set, even though the value hasn't
00946                                 // changed yet
00947 #define CVAR_ROM            64  // display only, cannot be set by user at all
00948 #define CVAR_USER_CREATED   128 // created by a set command
00949 #define CVAR_TEMP           256 // can be set even when cheats are disabled, but is not archived
00950 #define CVAR_CHEAT          512 // can not be changed if cheats are disabled
00951 #define CVAR_NORESTART      1024    // do not clear when a cvar_restart is issued
00952 
00953 // nothing outside the Cvar_*() functions should modify these fields!
00954 typedef struct cvar_s {
00955     char        *name;
00956     char        *string;
00957     char        *resetString;       // cvar_restart will reset to this value
00958     char        *latchedString;     // for CVAR_LATCH vars
00959     int         flags;
00960     qboolean    modified;           // set each time the cvar is changed
00961     int         modificationCount;  // incremented each time the cvar is changed
00962     float       value;              // atof( string )
00963     int         integer;            // atoi( string )
00964     struct cvar_s *next;
00965     struct cvar_s *hashNext;
00966 } cvar_t;
00967 
00968 #define MAX_CVAR_VALUE_STRING   256
00969 
00970 typedef int cvarHandle_t;
00971 
00972 // the modules that run in the virtual machine can't access the cvar_t directly,
00973 // so they must ask for structured updates
00974 typedef struct {
00975     cvarHandle_t    handle;
00976     int         modificationCount;
00977     float       value;
00978     int         integer;
00979     char        string[MAX_CVAR_VALUE_STRING];
00980 } vmCvar_t;
00981 
00982 /*
00983 ==============================================================
00984 
00985 COLLISION DETECTION
00986 
00987 ==============================================================
00988 */
00989 
00990 #include "surfaceflags.h"           // shared with the q3map utility
00991 
00992 // plane types are used to speed some tests
00993 // 0-2 are axial planes
00994 #define PLANE_X         0
00995 #define PLANE_Y         1
00996 #define PLANE_Z         2
00997 #define PLANE_NON_AXIAL 3
00998 
00999 
01000 /*
01001 =================
01002 PlaneTypeForNormal
01003 =================
01004 */
01005 
01006 #define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) )
01007 
01008 // plane_t structure
01009 // !!! if this is changed, it must be changed in asm code too !!!
01010 typedef struct cplane_s {
01011     vec3_t  normal;
01012     float   dist;
01013     byte    type;           // for fast side tests: 0,1,2 = axial, 3 = nonaxial
01014     byte    signbits;       // signx + (signy<<1) + (signz<<2), used as lookup during collision
01015     byte    pad[2];
01016 } cplane_t;
01017 
01018 
01019 // a trace is returned when a box is swept through the world
01020 typedef struct {
01021     qboolean    allsolid;   // if true, plane is not valid
01022     qboolean    startsolid; // if true, the initial point was in a solid area
01023     float       fraction;   // time completed, 1.0 = didn't hit anything
01024     vec3_t      endpos;     // final position
01025     cplane_t    plane;      // surface normal at impact, transformed to world space
01026     int         surfaceFlags;   // surface hit
01027     int         contents;   // contents on other side of surface hit
01028     int         entityNum;  // entity the contacted sirface is a part of
01029 } trace_t;
01030 
01031 // trace->entityNum can also be 0 to (MAX_GENTITIES-1)
01032 // or ENTITYNUM_NONE, ENTITYNUM_WORLD
01033 
01034 
01035 // markfragments are returned by CM_MarkFragments()
01036 typedef struct {
01037     int     firstPoint;
01038     int     numPoints;
01039 } markFragment_t;
01040 
01041 
01042 
01043 typedef struct {
01044     vec3_t      origin;
01045     vec3_t      axis[3];
01046 } orientation_t;
01047 
01048 //=====================================================================
01049 
01050 
01051 // in order from highest priority to lowest
01052 // if none of the catchers are active, bound key strings will be executed
01053 #define KEYCATCH_CONSOLE        0x0001
01054 #define KEYCATCH_UI                 0x0002
01055 #define KEYCATCH_MESSAGE        0x0004
01056 #define KEYCATCH_CGAME          0x0008
01057 
01058 
01059 // sound channels
01060 // channel 0 never willingly overrides
01061 // other channels will allways override a playing sound on that channel
01062 typedef enum {
01063     CHAN_AUTO,
01064     CHAN_LOCAL,     // menu sounds, etc
01065     CHAN_WEAPON,
01066     CHAN_VOICE,
01067     CHAN_ITEM,
01068     CHAN_BODY,
01069     CHAN_LOCAL_SOUND,   // chat messages, etc
01070     CHAN_ANNOUNCER      // announcer voices, etc
01071 } soundChannel_t;
01072 
01073 
01074 /*
01075 ========================================================================
01076 
01077   ELEMENTS COMMUNICATED ACROSS THE NET
01078 
01079 ========================================================================
01080 */
01081 
01082 #define ANGLE2SHORT(x)  ((int)((x)*65536/360) & 65535)
01083 #define SHORT2ANGLE(x)  ((x)*(360.0/65536))
01084 
01085 #define SNAPFLAG_RATE_DELAYED   1
01086 #define SNAPFLAG_NOT_ACTIVE     2   // snapshot used during connection and for zombies
01087 #define SNAPFLAG_SERVERCOUNT    4   // toggled every map_restart so transitions can be detected
01088 
01089 //
01090 // per-level limits
01091 //
01092 #define MAX_CLIENTS         64      // absolute limit
01093 #define MAX_LOCATIONS       64
01094 
01095 #define GENTITYNUM_BITS     10      // don't need to send any more
01096 #define MAX_GENTITIES       (1<<GENTITYNUM_BITS)
01097 
01098 // entitynums are communicated with GENTITY_BITS, so any reserved
01099 // values that are going to be communcated over the net need to
01100 // also be in this range
01101 #define ENTITYNUM_NONE      (MAX_GENTITIES-1)
01102 #define ENTITYNUM_WORLD     (MAX_GENTITIES-2)
01103 #define ENTITYNUM_MAX_NORMAL    (MAX_GENTITIES-2)
01104 
01105 
01106 #define MAX_MODELS          256     // these are sent over the net as 8 bits
01107 #define MAX_SOUNDS          256     // so they cannot be blindly increased
01108 
01109 
01110 #define MAX_CONFIGSTRINGS   1024
01111 
01112 // these are the only configstrings that the system reserves, all the
01113 // other ones are strictly for servergame to clientgame communication
01114 #define CS_SERVERINFO       0       // an info string with all the serverinfo cvars
01115 #define CS_SYSTEMINFO       1       // an info string for server system to client system configuration (timescale, etc)
01116 
01117 #define RESERVED_CONFIGSTRINGS  2   // game can't modify below this, only the system can
01118 
01119 #define MAX_GAMESTATE_CHARS 16000
01120 typedef struct {
01121     int         stringOffsets[MAX_CONFIGSTRINGS];
01122     char        stringData[MAX_GAMESTATE_CHARS];
01123     int         dataCount;
01124 } gameState_t;
01125 
01126 //=========================================================
01127 
01128 // bit field limits
01129 #define MAX_STATS               16
01130 #define MAX_PERSISTANT          16
01131 #define MAX_POWERUPS            16
01132 #define MAX_WEAPONS             16      
01133 
01134 #define MAX_PS_EVENTS           2
01135 
01136 #define PS_PMOVEFRAMECOUNTBITS  6
01137 
01138 // playerState_t is the information needed by both the client and server
01139 // to predict player motion and actions
01140 // nothing outside of pmove should modify these, or some degree of prediction error
01141 // will occur
01142 
01143 // you can't add anything to this without modifying the code in msg.c
01144 
01145 // playerState_t is a full superset of entityState_t as it is used by players,
01146 // so if a playerState_t is transmitted, the entityState_t can be fully derived
01147 // from it.
01148 typedef struct playerState_s {
01149     int         commandTime;    // cmd->serverTime of last executed command
01150     int         pm_type;
01151     int         bobCycle;       // for view bobbing and footstep generation
01152     int         pm_flags;       // ducked, jump_held, etc
01153     int         pm_time;
01154 
01155     vec3_t      origin;
01156     vec3_t      velocity;
01157     int         weaponTime;
01158     int         gravity;
01159     int         speed;
01160     int         delta_angles[3];    // add to command angles to get view direction
01161                                     // changed by spawns, rotating objects, and teleporters
01162 
01163     int         groundEntityNum;// ENTITYNUM_NONE = in air
01164 
01165     int         legsTimer;      // don't change low priority animations until this runs out
01166     int         legsAnim;       // mask off ANIM_TOGGLEBIT
01167 
01168     int         torsoTimer;     // don't change low priority animations until this runs out
01169     int         torsoAnim;      // mask off ANIM_TOGGLEBIT
01170 
01171     int         movementDir;    // a number 0 to 7 that represents the reletive angle
01172                                 // of movement to the view angle (axial and diagonals)
01173                                 // when at rest, the value will remain unchanged
01174                                 // used to twist the legs during strafing
01175 
01176     vec3_t      grapplePoint;   // location of grapple to pull towards if PMF_GRAPPLE_PULL
01177 
01178     int         eFlags;         // copied to entityState_t->eFlags
01179 
01180     int         eventSequence;  // pmove generated events
01181     int         events[MAX_PS_EVENTS];
01182     int         eventParms[MAX_PS_EVENTS];
01183 
01184     int         externalEvent;  // events set on player from another source
01185     int         externalEventParm;
01186     int         externalEventTime;
01187 
01188     int         clientNum;      // ranges from 0 to MAX_CLIENTS-1
01189     int         weapon;         // copied to entityState_t->weapon
01190     int         weaponstate;
01191 
01192     vec3_t      viewangles;     // for fixed views
01193     int         viewheight;
01194 
01195     // damage feedback
01196     int         damageEvent;    // when it changes, latch the other parms
01197     int         damageYaw;
01198     int         damagePitch;
01199     int         damageCount;
01200 
01201     int         stats[MAX_STATS];
01202     int         persistant[MAX_PERSISTANT]; // stats that aren't cleared on death
01203     int         powerups[MAX_POWERUPS]; // level.time that the powerup runs out
01204     int         ammo[MAX_WEAPONS];
01205 
01206     int         generic1;
01207     int         loopSound;
01208     int         jumppad_ent;    // jumppad entity hit this frame
01209 
01210     // not communicated over the net at all
01211     int         ping;           // server to game info for scoreboard
01212     int         pmove_framecount;   // FIXME: don't transmit over the network
01213     int         jumppad_frame;
01214     int         entityEventSequence;
01215 } playerState_t;
01216 
01217 
01218 //====================================================================
01219 
01220 
01221 //
01222 // usercmd_t->button bits, many of which are generated by the client system,
01223 // so they aren't game/cgame only definitions
01224 //
01225 #define BUTTON_ATTACK       1
01226 #define BUTTON_TALK         2           // displays talk balloon and disables actions
01227 #define BUTTON_USE_HOLDABLE 4
01228 #define BUTTON_GESTURE      8
01229 #define BUTTON_WALKING      16          // walking can't just be infered from MOVE_RUN
01230                                         // because a key pressed late in the frame will
01231                                         // only generate a small move value for that frame
01232                                         // walking will use different animations and
01233                                         // won't generate footsteps
01234 #define BUTTON_AFFIRMATIVE  32
01235 #define BUTTON_NEGATIVE     64
01236 
01237 #define BUTTON_GETFLAG      128
01238 #define BUTTON_GUARDBASE    256
01239 #define BUTTON_PATROL       512
01240 #define BUTTON_FOLLOWME     1024
01241 
01242 #define BUTTON_ANY          2048            // any key whatsoever
01243 
01244 #define MOVE_RUN            120         // if forwardmove or rightmove are >= MOVE_RUN,
01245                                         // then BUTTON_WALKING should be set
01246 
01247 // usercmd_t is sent to the server each client frame
01248 typedef struct usercmd_s {
01249     int             serverTime;
01250     int             angles[3];
01251     int             buttons;
01252     byte            weapon;           // weapon 
01253     signed char forwardmove, rightmove, upmove;
01254 } usercmd_t;
01255 
01256 //===================================================================
01257 
01258 // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
01259 #define SOLID_BMODEL    0xffffff
01260 
01261 typedef enum {
01262     TR_STATIONARY,
01263     TR_INTERPOLATE,             // non-parametric, but interpolate between snapshots
01264     TR_LINEAR,
01265     TR_LINEAR_STOP,
01266     TR_SINE,                    // value = base + sin( time / duration ) * delta
01267     TR_GRAVITY
01268 } trType_t;
01269 
01270 typedef struct {
01271     trType_t    trType;
01272     int     trTime;
01273     int     trDuration;         // if non 0, trTime + trDuration = stop time
01274     vec3_t  trBase;
01275     vec3_t  trDelta;            // velocity, etc
01276 } trajectory_t;
01277 
01278 // entityState_t is the information conveyed from the server
01279 // in an update message about entities that the client will
01280 // need to render in some way
01281 // Different eTypes may use the information in different ways
01282 // The messages are delta compressed, so it doesn't really matter if
01283 // the structure size is fairly large
01284 
01285 typedef struct entityState_s {
01286     int     number;         // entity index
01287     int     eType;          // entityType_t
01288     int     eFlags;
01289 
01290     trajectory_t    pos;    // for calculating position
01291     trajectory_t    apos;   // for calculating angles
01292 
01293     int     time;
01294     int     time2;
01295 
01296     vec3_t  origin;
01297     vec3_t  origin2;
01298 
01299     vec3_t  angles;
01300     vec3_t  angles2;
01301 
01302     int     otherEntityNum; // shotgun sources, etc
01303     int     otherEntityNum2;
01304 
01305     int     groundEntityNum;    // -1 = in air
01306 
01307     int     constantLight;  // r + (g<<8) + (b<<16) + (intensity<<24)
01308     int     loopSound;      // constantly loop this sound
01309 
01310     int     modelindex;
01311     int     modelindex2;
01312     int     clientNum;      // 0 to (MAX_CLIENTS - 1), for players and corpses
01313     int     frame;
01314 
01315     int     solid;          // for client side prediction, trap_linkentity sets this properly
01316 
01317     int     event;          // impulse events -- muzzle flashes, footsteps, etc
01318     int     eventParm;
01319 
01320     // for players
01321     int     powerups;       // bit flags
01322     int     weapon;         // determines weapon and flash model, etc
01323     int     legsAnim;       // mask off ANIM_TOGGLEBIT
01324     int     torsoAnim;      // mask off ANIM_TOGGLEBIT
01325 
01326     int     generic1;
01327 } entityState_t;
01328 
01329 typedef enum {
01330     CA_UNINITIALIZED,
01331     CA_DISCONNECTED,    // not talking to a server
01332     CA_AUTHORIZING,     // not used any more, was checking cd key 
01333     CA_CONNECTING,      // sending request packets to the server
01334     CA_CHALLENGING,     // sending challenge packets to the server
01335     CA_CONNECTED,       // netchan_t established, getting gamestate
01336     CA_LOADING,         // only during cgame initialization, never during main loop
01337     CA_PRIMED,          // got gamestate, waiting for first frame
01338     CA_ACTIVE,          // game views should be displayed
01339     CA_CINEMATIC        // playing a cinematic or a static pic, not connected to a server
01340 } connstate_t;
01341 
01342 // font support 
01343 
01344 #define GLYPH_START 0
01345 #define GLYPH_END 255
01346 #define GLYPH_CHARSTART 32
01347 #define GLYPH_CHAREND 127
01348 #define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1
01349 typedef struct {
01350   int height;       // number of scan lines
01351   int top;          // top of glyph in buffer
01352   int bottom;       // bottom of glyph in buffer
01353   int pitch;        // width for copying
01354   int xSkip;        // x adjustment
01355   int imageWidth;   // width of actual image
01356   int imageHeight;  // height of actual image
01357   float s;          // x offset in image where glyph starts
01358   float t;          // y offset in image where glyph starts
01359   float s2;
01360   float t2;
01361   qhandle_t glyph;  // handle to the shader with the glyph
01362   char shaderName[32];
01363 } glyphInfo_t;
01364 
01365 typedef struct {
01366   glyphInfo_t glyphs [GLYPHS_PER_FONT];
01367   float glyphScale;
01368   char name[MAX_QPATH];
01369 } fontInfo_t;
01370 
01371 #define Square(x) ((x)*(x))
01372 
01373 // real time
01374 //=============================================
01375 
01376 
01377 typedef struct qtime_s {
01378     int tm_sec;     /* seconds after the minute - [0,59] */
01379     int tm_min;     /* minutes after the hour - [0,59] */
01380     int tm_hour;    /* hours since midnight - [0,23] */
01381     int tm_mday;    /* day of the month - [1,31] */
01382     int tm_mon;     /* months since January - [0,11] */
01383     int tm_year;    /* years since 1900 */
01384     int tm_wday;    /* days since Sunday - [0,6] */
01385     int tm_yday;    /* days since January 1 - [0,365] */
01386     int tm_isdst;   /* daylight savings time flag */
01387 } qtime_t;
01388 
01389 
01390 // server browser sources
01391 // TTimo: AS_MPLAYER is no longer used
01392 #define AS_LOCAL            0
01393 #define AS_MPLAYER      1
01394 #define AS_GLOBAL           2
01395 #define AS_FAVORITES    3
01396 
01397 
01398 // cinematic states
01399 typedef enum {
01400     FMV_IDLE,
01401     FMV_PLAY,       // play
01402     FMV_EOF,        // all other conditions, i.e. stop/EOF/abort
01403     FMV_ID_BLT,
01404     FMV_ID_IDLE,
01405     FMV_LOOPED,
01406     FMV_ID_WAIT
01407 } e_status;
01408 
01409 typedef enum _flag_status {
01410     FLAG_ATBASE = 0,
01411     FLAG_TAKEN,         // CTF
01412     FLAG_TAKEN_RED,     // One Flag CTF
01413     FLAG_TAKEN_BLUE,    // One Flag CTF
01414     FLAG_DROPPED
01415 } flagStatus_t;
01416 
01417 
01418 
01419 #define MAX_GLOBAL_SERVERS              4096
01420 #define MAX_OTHER_SERVERS                   128
01421 #define MAX_PINGREQUESTS                    32
01422 #define MAX_SERVERSTATUSREQUESTS    16
01423 
01424 #define SAY_ALL     0
01425 #define SAY_TEAM    1
01426 #define SAY_TELL    2
01427 
01428 #define CDKEY_LEN 16
01429 #define CDCHKSUM_LEN 2
01430 
01431 
01432 #endif  // __Q_SHARED_H

Generated on Thu Aug 25 12:37:34 2005 for Quake III Arena by  doxygen 1.3.9.1