codemp/game/q_shared.h

Go to the documentation of this file.
00001 // Copyright (C) 1999-2000 Id Software, Inc.
00002 //
00003 #ifndef __Q_SHARED_H
00004 #define __Q_SHARED_H
00005 
00006 // q_shared.h -- included first by ALL program modules.
00007 // A user mod should never modify this file
00008 
00009 //NOTENOTE: Only change this to re-point ICARUS to a new script directory
00010 #define Q3_SCRIPT_DIR   "scripts"
00011 
00012 #define MAX_TEAMNAME 32
00013 
00014 #include "../qcommon/disablewarnings.h"
00015 
00016 #include "teams.h" //npc team stuff
00017 
00018 #define MAX_WORLD_COORD         ( 64 * 1024 )
00019 #define MIN_WORLD_COORD         ( -64 * 1024 )
00020 #define WORLD_SIZE                      ( MAX_WORLD_COORD - MIN_WORLD_COORD )
00021 
00022 //Pointer safety utilities
00023 #define VALID( a )              ( a != NULL )
00024 #define VALIDATE( a )   ( assert( a ) )
00025 
00026 #define VALIDATEV( a )  if ( a == NULL ) {      assert(0);      return;                 }
00027 #define VALIDATEB( a )  if ( a == NULL ) {      assert(0);      return qfalse;  }
00028 #define VALIDATEP( a )  if ( a == NULL ) {      assert(0);      return NULL;    }
00029 
00030 #define VALIDSTRING( a )        ( ( a != 0 ) && ( a[0] != 0 ) )
00031 
00032 /*
00033 #define G2_EHNANCEMENTS
00034 
00035 #ifdef G2_EHNANCEMENTS
00036 //these two will probably explode if they're defined independant of one another.
00037 //rww - RAGDOLL_BEGIN
00038 #define JK2_RAGDOLL
00039 //rww - RAGDOLL_END
00040 //rww - Bone cache for multiplayer base.
00041 #define MP_BONECACHE
00042 #endif
00043 */
00044 
00045 #ifndef FINAL_BUILD
00046 #define G2_PERFORMANCE_ANALYSIS
00047 #define _FULL_G2_LEAK_CHECKING
00048 extern int g_Ghoul2Allocations;
00049 extern int g_G2ServerAlloc;
00050 extern int g_G2ClientAlloc;
00051 extern int g_G2AllocServer;
00052 #endif
00053 
00054 /**********************************************************************
00055   VM Considerations
00056 
00057   The VM can not use the standard system headers because we aren't really
00058   using the compiler they were meant for.  We use bg_lib.h which contains
00059   prototypes for the functions we define for our own use in bg_lib.c.
00060 
00061   When writing mods, please add needed headers HERE, do not start including
00062   stuff like <stdio.h> in the various .c files that make up each of the VMs
00063   since you will be including system headers files can will have issues.
00064 
00065   Remember, if you use a C library function that is not defined in bg_lib.c,
00066   you will have to add your own version for support in the VM.
00067 
00068  **********************************************************************/
00069 
00070 #ifdef Q3_VM
00071 
00072 #include "bg_lib.h"
00073 
00074 #define assert(exp)     ((void)0)
00075 
00076 #define min(x,y) ((x)<(y)?(x):(y))
00077 #define max(x,y) ((x)>(y)?(x):(y))
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 // Special min treatment for Xbox C++ version
00092 
00093 #ifdef _XBOX
00094 #define min(x,y) ((x)<(y)?(x):(y))
00095 #define max(x,y) ((x)>(y)?(x):(y))
00096 
00097 #define tvector(T) std::vector< T >
00098 #define tdeque(T) std::deque< T >
00099 
00100 #define tlist(T) std::list< T >
00101 #define tslist(T) std::slist< T >
00102 
00103 #define tset(T) std::set< T, std::less< T > >
00104 #define tmultiset(T) std::multiset< T, std::less< T > >
00105 
00106 #define tcset(T,C) std::set< T, C >
00107 #define tcmultiset(T,C) std::multiset< T, C >
00108 
00109 #define tmap(K,T) std::map< K, T, std::less< K > >
00110 #define tmultimap(K,T) std::multimap< K, T, std::less< K > >
00111 
00112 #define tcmap(K,T,C) std::map< K, T, C >
00113 #define tcmultimap(K,T,C) std::multimap< K, T, C >
00114 #endif
00115 
00116 #endif
00117 
00118 #ifdef _WIN32
00119 
00120 //#pragma intrinsic( memset, memcpy )
00121 
00122 #endif
00123 
00124 // this is the define for determining if we have an asm version of a C function
00125 #if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__
00126 #define id386   1
00127 #else
00128 #define id386   0
00129 #endif
00130 
00131 #if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
00132 #define idppc   1
00133 #else
00134 #define idppc   0
00135 #endif
00136 
00137 // for windows fastcall option
00138 
00139 #define QDECL
00140 
00141 short   ShortSwap (short l);
00142 int             LongSwap (int l);
00143 float   FloatSwap (const float *f);
00144 
00145 //======================= WIN32 DEFINES =================================
00146 
00147 #ifdef WIN32
00148 
00149 #define MAC_STATIC
00150 
00151 #undef QDECL
00152 #define QDECL   __cdecl
00153 
00154 // buildstring will be incorporated into the version string
00155 #ifdef NDEBUG
00156 #ifdef _M_IX86
00157 #define CPUSTRING       "win-x86"
00158 #elif defined _M_ALPHA
00159 #define CPUSTRING       "win-AXP"
00160 #endif
00161 #else
00162 #ifdef _M_IX86
00163 #define CPUSTRING       "win-x86-debug"
00164 #elif defined _M_ALPHA
00165 #define CPUSTRING       "win-AXP-debug"
00166 #endif
00167 #endif
00168 
00169 #define ID_INLINE __inline 
00170 
00171 static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
00172 #define LittleShort
00173 static ID_INLINE int BigLong(int l) { return LongSwap(l); }
00174 #define LittleLong
00175 static ID_INLINE float BigFloat(const float *l) { FloatSwap(l); }
00176 #define LittleFloat
00177 
00178 #define PATH_SEP '\\'
00179 
00180 #endif
00181 
00182 //======================= MAC OS X DEFINES =====================
00183 
00184 #if defined(MACOS_X)
00185 
00186 #define MAC_STATIC
00187 #define __cdecl
00188 #define __declspec(x)
00189 #define stricmp strcasecmp
00190 #define ID_INLINE inline 
00191 
00192 #ifdef __ppc__
00193 #define CPUSTRING       "MacOSX-ppc"
00194 #elif defined __i386__
00195 #define CPUSTRING       "MacOSX-i386"
00196 #else
00197 #define CPUSTRING       "MacOSX-other"
00198 #endif
00199 
00200 #define PATH_SEP        '/'
00201 
00202 #define __rlwimi(out, in, shift, maskBegin, maskEnd) asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), "i" (shift), "i" (maskBegin), "i" (maskEnd))
00203 #define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset))
00204 
00205 static inline unsigned int __lwbrx(register void *addr, register int offset) {
00206     register unsigned int word;
00207     
00208     asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
00209     return word;
00210 }
00211 
00212 static inline unsigned short __lhbrx(register void *addr, register int offset) {
00213     register unsigned short halfword;
00214     
00215     asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset));
00216     return halfword;
00217 }
00218 
00219 static inline float __fctiw(register float f) {
00220     register float fi;
00221     
00222     asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
00223 
00224     return fi;
00225 }
00226 
00227 #define BigShort
00228 static inline short LittleShort(short l) { return ShortSwap(l); }
00229 #define BigLong
00230 static inline int LittleLong (int l) { return LongSwap(l); }
00231 #define BigFloat
00232 static inline float LittleFloat (const float l) { return FloatSwap(&l); }
00233 
00234 #endif
00235 
00236 //======================= MAC DEFINES =================================
00237 
00238 #ifdef __MACOS__
00239 
00240 #include <MacTypes.h>
00241 #define MAC_STATIC
00242 #define ID_INLINE inline 
00243 
00244 #define CPUSTRING       "MacOS-PPC"
00245 
00246 #define PATH_SEP ':'
00247 
00248 void Sys_PumpEvents( void );
00249 
00250 #define BigShort
00251 static inline short LittleShort(short l) { return ShortSwap(l); }
00252 #define BigLong
00253 static inline int LittleLong (int l) { return LongSwap(l); }
00254 #define BigFloat
00255 static inline float LittleFloat (const float l) { return FloatSwap(&l); }
00256 
00257 #endif
00258 
00259 //======================= LINUX DEFINES =================================
00260 
00261 // the mac compiler can't handle >32k of locals, so we
00262 // just waste space and make big arrays static...
00263 #ifdef __linux__
00264 
00265 // bk001205 - from Makefile
00266 #define stricmp strcasecmp
00267 
00268 #define MAC_STATIC // bk: FIXME
00269 #define ID_INLINE inline 
00270 
00271 #ifdef __i386__
00272 #define CPUSTRING       "linux-i386"
00273 #elif defined __axp__
00274 #define CPUSTRING       "linux-alpha"
00275 #else
00276 #define CPUSTRING       "linux-other"
00277 #endif
00278 
00279 #define PATH_SEP '/'
00280 
00281 // bk001205 - try
00282 #ifdef Q3_STATIC
00283 #define GAME_HARD_LINKED
00284 #define CGAME_HARD_LINKED
00285 #define UI_HARD_LINKED
00286 #define BOTLIB_HARD_LINKED
00287 #endif
00288 
00289 #if !idppc
00290 inline static short BigShort( short l) { return ShortSwap(l); }
00291 #define LittleShort
00292 inline static int BigLong(int l) { return LongSwap(l); }
00293 #define LittleLong
00294 inline static float BigFloat(const float *l) { return FloatSwap(l); }
00295 #define LittleFloat
00296 #else
00297 #define BigShort
00298 inline static short LittleShort(short l) { return ShortSwap(l); }
00299 #define BigLong
00300 inline static int LittleLong (int l) { return LongSwap(l); }
00301 #define BigFloat
00302 inline static float LittleFloat (const float *l) { return FloatSwap(l); }
00303 #endif
00304 
00305 #endif
00306 
00307 //======================= FreeBSD DEFINES =====================
00308 #ifdef __FreeBSD__ // rb010123
00309 
00310 #define stricmp strcasecmp
00311 
00312 #define MAC_STATIC
00313 #define ID_INLINE inline 
00314 
00315 #ifdef __i386__
00316 #define CPUSTRING       "freebsd-i386"
00317 #elif defined __axp__
00318 #define CPUSTRING       "freebsd-alpha"
00319 #else
00320 #define CPUSTRING       "freebsd-other"
00321 #endif
00322 
00323 #define PATH_SEP '/'
00324 
00325 // bk010116 - omitted Q3STATIC (see Linux above), broken target
00326 
00327 #if !idppc
00328 static short BigShort( short l) { return ShortSwap(l); }
00329 #define LittleShort
00330 static int BigLong(int l) { LongSwap(l); }
00331 #define LittleLong
00332 static float BigFloat(const float *l) { FloatSwap(l); }
00333 #define LittleFloat
00334 #else
00335 #define BigShort
00336 static short LittleShort(short l) { return ShortSwap(l); }
00337 #define BigLong
00338 static int LittleLong (int l) { return LongSwap(l); }
00339 #define BigFloat
00340 static float LittleFloat (const float *l) { return FloatSwap(l); }
00341 #endif
00342 
00343 #endif
00344 
00345 //=============================================================
00346 
00347 //=============================================================
00348 
00349 typedef unsigned char           byte;
00350 typedef unsigned short          word;
00351 typedef unsigned long           ulong;
00352 
00353 typedef enum {qfalse, qtrue}    qboolean;
00354 #ifdef _XBOX
00355 #define qboolean        int             //don't want strict type checking on the qboolean
00356 #endif
00357 
00358 typedef int             qhandle_t;
00359 typedef int             thandle_t; //rwwRMG - inserted
00360 typedef int             fxHandle_t;
00361 typedef int             sfxHandle_t;
00362 typedef int             fileHandle_t;
00363 typedef int             clipHandle_t;
00364 
00365 #ifndef NULL
00366 #define NULL ((void *)0)
00367 #endif
00368 
00369 #define MAX_QINT                        0x7fffffff
00370 #define MIN_QINT                        (-MAX_QINT-1)
00371 
00372 
00373 // angle indexes
00374 #define PITCH                           0               // up / down
00375 #define YAW                                     1               // left / right
00376 #define ROLL                            2               // fall over
00377 
00378 // the game guarantees that no string from the network will ever
00379 // exceed MAX_STRING_CHARS
00380 #define MAX_STRING_CHARS        1024    // max length of a string passed to Cmd_TokenizeString
00381 #define MAX_STRING_TOKENS       1024    // max tokens resulting from Cmd_TokenizeString
00382 #define MAX_TOKEN_CHARS         1024    // max length of an individual token
00383 
00384 #define MAX_INFO_STRING         1024
00385 #define MAX_INFO_KEY            1024
00386 #define MAX_INFO_VALUE          1024
00387 
00388 #define BIG_INFO_STRING         8192  // used for system info key only
00389 #define BIG_INFO_KEY              8192
00390 #define BIG_INFO_VALUE          8192
00391 
00392 
00393 #define MAX_QPATH                       64              // max length of a quake game pathname
00394 #ifdef PATH_MAX
00395 #define MAX_OSPATH                      PATH_MAX
00396 #else
00397 #define MAX_OSPATH                      256             // max length of a filesystem pathname
00398 #endif
00399 
00400 #define MAX_NAME_LENGTH         32              // max length of a client name
00401 
00402 #define MAX_SAY_TEXT    150
00403 
00404 // paramters for command buffer stuffing
00405 typedef enum {
00406         EXEC_NOW,                       // don't return until completed, a VM should NEVER use this,
00407                                                 // because some commands might cause the VM to be unloaded...
00408         EXEC_INSERT,            // insert at current position, but don't run yet
00409         EXEC_APPEND                     // add to end of the command buffer (normal case)
00410 } cbufExec_t;
00411 
00412 
00413 //
00414 // these aren't needed by any of the VMs.  put in another header?
00415 //
00416 #define MAX_MAP_AREA_BYTES              32              // bit vector of area visibility
00417 
00418 
00419 #define LS_STYLES_START                 0
00420 #define LS_NUM_STYLES                   32
00421 #define LS_SWITCH_START                 (LS_STYLES_START+LS_NUM_STYLES)
00422 #define LS_NUM_SWITCH                   32
00423 #if !defined MAX_LIGHT_STYLES
00424 #define MAX_LIGHT_STYLES                64
00425 #endif
00426 
00427 //For system-wide prints
00428 enum WL_e {
00429         WL_ERROR=1,
00430         WL_WARNING,
00431         WL_VERBOSE,
00432         WL_DEBUG
00433 };
00434 
00435 extern float forceSpeedLevels[4];
00436 
00437 // print levels from renderer (FIXME: set up for game / cgame?)
00438 typedef enum {
00439         PRINT_ALL,
00440         PRINT_DEVELOPER,                // only print when "developer 1"
00441         PRINT_WARNING,
00442         PRINT_ERROR
00443 } printParm_t;
00444 
00445 
00446 #ifdef ERR_FATAL
00447 #undef ERR_FATAL                        // this is be defined in malloc.h
00448 #endif
00449 
00450 // parameters to the main Error routine
00451 typedef enum {
00452         ERR_FATAL,                                      // exit the entire game with a popup window
00453         ERR_DROP,                                       // print to console and disconnect from game
00454         ERR_SERVERDISCONNECT,           // don't kill server
00455         ERR_DISCONNECT,                         // client disconnected from the server
00456         ERR_NEED_CD                                     // pop up the need-cd dialog
00457 } errorParm_t;
00458 
00459 
00460 // font rendering values used by ui and cgame
00461 
00462 /*#define PROP_GAP_WIDTH                        3
00463 #define PROP_SPACE_WIDTH                8
00464 #define PROP_HEIGHT                             27
00465 #define PROP_SMALL_SIZE_SCALE   0.75*/
00466 
00467 #define PROP_GAP_WIDTH                  2
00468 //#define PROP_GAP_WIDTH                        3
00469 #define PROP_SPACE_WIDTH                4
00470 #define PROP_HEIGHT                             16
00471 
00472 #define PROP_TINY_SIZE_SCALE    1
00473 #define PROP_SMALL_SIZE_SCALE   1
00474 #define PROP_BIG_SIZE_SCALE             1
00475 #define PROP_GIANT_SIZE_SCALE   2
00476 
00477 #define PROP_TINY_HEIGHT                10
00478 #define PROP_GAP_TINY_WIDTH             1
00479 #define PROP_SPACE_TINY_WIDTH   3
00480 
00481 #define PROP_BIG_HEIGHT                 24
00482 #define PROP_GAP_BIG_WIDTH              3
00483 #define PROP_SPACE_BIG_WIDTH    6
00484 
00485 #define BLINK_DIVISOR                   200
00486 #define PULSE_DIVISOR                   75
00487 
00488 #define UI_LEFT                 0x00000000      // default
00489 #define UI_CENTER               0x00000001
00490 #define UI_RIGHT                0x00000002
00491 #define UI_FORMATMASK   0x00000007
00492 #define UI_SMALLFONT    0x00000010
00493 #define UI_BIGFONT              0x00000020      // default
00494 //#define UI_GIANTFONT  0x00000040
00495 #define UI_DROPSHADOW   0x00000800
00496 #define UI_BLINK                0x00001000
00497 #define UI_INVERSE              0x00002000
00498 #define UI_PULSE                0x00004000
00499 
00500 #if defined(_DEBUG) && !defined(BSPC) && !defined(_XBOX)
00501         #define HUNK_DEBUG
00502 #endif
00503 
00504 typedef enum {
00505         h_high,
00506         h_low,
00507         h_dontcare
00508 } ha_pref;
00509 
00510 void *Hunk_Alloc( int size, ha_pref preference );
00511 
00512 void Com_Memset (void* dest, const int val, const size_t count);
00513 void Com_Memcpy (void* dest, const void* src, const size_t count);
00514 
00515 #define CIN_system      1
00516 #define CIN_loop        2
00517 #define CIN_hold        4
00518 #define CIN_silent      8
00519 #define CIN_shader      16
00520 
00521 /*
00522 ==============================================================
00523 
00524 MATHLIB
00525 
00526 ==============================================================
00527 */
00528 
00529 
00530 typedef float vec_t;
00531 typedef vec_t vec2_t[2];
00532 typedef vec_t vec3_t[3];
00533 typedef vec_t vec4_t[4];
00534 typedef vec_t vec5_t[5];
00535 
00536 //rwwRMG - new vec types
00537 typedef vec3_t  vec3pair_t[2];
00538 
00539 typedef int ivec3_t[3];
00540 typedef int ivec4_t[4];
00541 typedef int ivec5_t[5];
00542 
00543 typedef int     fixed4_t;
00544 typedef int     fixed8_t;
00545 typedef int     fixed16_t;
00546 
00547 #ifndef M_PI
00548 #define M_PI            3.14159265358979323846f // matches value in gcc v2 math.h
00549 #endif
00550 
00551 
00552 typedef enum {
00553         BLK_NO,
00554         BLK_TIGHT,              // Block only attacks and shots around the saber itself, a bbox of around 12x12x12
00555         BLK_WIDE                // Block all attacks in an area around the player in a rough arc of 180 degrees
00556 } saberBlockType_t;
00557 
00558 typedef enum {
00559         BLOCKED_NONE,
00560         BLOCKED_BOUNCE_MOVE,
00561         BLOCKED_PARRY_BROKEN,
00562         BLOCKED_ATK_BOUNCE,
00563         BLOCKED_UPPER_RIGHT,
00564         BLOCKED_UPPER_LEFT,
00565         BLOCKED_LOWER_RIGHT,
00566         BLOCKED_LOWER_LEFT,
00567         BLOCKED_TOP,
00568         BLOCKED_UPPER_RIGHT_PROJ,
00569         BLOCKED_UPPER_LEFT_PROJ,
00570         BLOCKED_LOWER_RIGHT_PROJ,
00571         BLOCKED_LOWER_LEFT_PROJ,
00572         BLOCKED_TOP_PROJ
00573 } saberBlockedType_t;
00574 
00575 
00576 
00577 typedef enum
00578 {
00579         SABER_RED,
00580         SABER_ORANGE,
00581         SABER_YELLOW,
00582         SABER_GREEN,
00583         SABER_BLUE,
00584         SABER_PURPLE,
00585         NUM_SABER_COLORS
00586 
00587 };
00588 typedef int saber_colors_t;
00589 
00590 typedef enum
00591 {
00592         FP_FIRST = 0,//marker
00593         FP_HEAL = 0,//instant
00594         FP_LEVITATION,//hold/duration
00595         FP_SPEED,//duration
00596         FP_PUSH,//hold/duration
00597         FP_PULL,//hold/duration
00598         FP_TELEPATHY,//instant
00599         FP_GRIP,//hold/duration
00600         FP_LIGHTNING,//hold/duration
00601         FP_RAGE,//duration
00602         FP_PROTECT,
00603         FP_ABSORB,
00604         FP_TEAM_HEAL,
00605         FP_TEAM_FORCE,
00606         FP_DRAIN,
00607         FP_SEE,
00608         FP_SABER_OFFENSE,
00609         FP_SABER_DEFENSE,
00610         FP_SABERTHROW,
00611         NUM_FORCE_POWERS
00612 };
00613 typedef int forcePowers_t;
00614 
00615 typedef enum
00616 {
00617         SABER_NONE = 0,
00618         SABER_SINGLE,
00619         SABER_STAFF,
00620         SABER_DAGGER,
00621         SABER_BROAD,
00622         SABER_PRONG,
00623         SABER_ARC,
00624         SABER_SAI,
00625         SABER_CLAW,
00626         SABER_LANCE,
00627         SABER_STAR,
00628         SABER_TRIDENT,
00629         SABER_SITH_SWORD,
00630         NUM_SABERS
00631 } saberType_t;
00632 
00633 typedef struct 
00634 {
00635         // Actual trail stuff
00636         int             inAction;       // controls whether should we even consider starting one
00637         int             duration;       // how long each trail seg stays in existence
00638         int             lastTime;       // time a saber segement was last stored
00639         vec3_t  base;
00640         vec3_t  tip;
00641 
00642         vec3_t  dualbase;
00643         vec3_t  dualtip;
00644 
00645         // Marks stuff
00646         qboolean        haveOldPos[2];
00647         vec3_t          oldPos[2];              
00648         vec3_t          oldNormal[2];   // store this in case we don't have a connect-the-dots situation
00649                                                         //      ..then we'll need the normal to project a mark blob onto the impact point
00650 } saberTrail_t;
00651 
00652 typedef struct
00653 {
00654         qboolean        active;
00655         saber_colors_t  color;
00656         float           radius;
00657         float           length;
00658         float           lengthMax;
00659         float           lengthOld;
00660         float           desiredLength;
00661         vec3_t          muzzlePoint;
00662         vec3_t          muzzlePointOld;
00663         vec3_t          muzzleDir;
00664         vec3_t          muzzleDirOld;
00665         saberTrail_t    trail;
00666         int                     hitWallDebounceTime;
00667         int                     storageTime;
00668         int                     extendDebounce;
00669 } bladeInfo_t;
00670 #define MAX_BLADES 8
00671 
00672 typedef enum
00673 {
00674         SS_NONE = 0,
00675         SS_FAST,
00676         SS_MEDIUM,
00677         SS_STRONG,
00678         SS_DESANN,
00679         SS_TAVION,
00680         SS_DUAL,
00681         SS_STAFF,
00682         SS_NUM_SABER_STYLES
00683 } saber_styles_t;
00684 
00685 //SABER FLAGS
00686 //Old bools converted to a flag now
00687 #define SFL_NOT_LOCKABLE                        (1<<0)//can't get into a saberlock
00688 #define SFL_NOT_THROWABLE                       (1<<1)//can't be thrown - FIXME: maybe make this a max level of force saber throw that can be used with this saber?
00689 #define SFL_NOT_DISARMABLE                      (1<<2)//can't be dropped
00690 #define SFL_NOT_ACTIVE_BLOCKING         (1<<3)//don't to try to block incoming shots with this saber
00691 #define SFL_TWO_HANDED                          (1<<4)//uses both hands
00692 #define SFL_SINGLE_BLADE_THROWABLE      (1<<5)//can throw this saber if only the first blade is on
00693 #define SFL_RETURN_DAMAGE                       (1<<6)//when returning from a saber throw, it keeps spinning and doing damage
00694 //NEW FLAGS
00695 #define SFL_ON_IN_WATER                         (1<<7)//if set, weapon stays active even in water
00696 #define SFL_BOUNCE_ON_WALLS                     (1<<8)//if set, the saber will bounce back when it hits solid architecture (good for real-sword type mods)
00697 #define SFL_BOLT_TO_WRIST                       (1<<9)//if set, saber model is bolted to wrist, not in hand... useful for things like claws & shields, etc.
00698 //#define SFL_STICK_ON_IMPACT           (1<<?)//if set, the saber will stick in the wall when thrown and hits solid architecture (good for sabers that are meant to be thrown).
00699 //#define SFL_NO_ATTACK                         (1<<?)//if set, you cannot attack with the saber (for sabers/weapons that are meant to be thrown only, not used as melee weapons).
00700 //Move Restrictions
00701 #define SFL_NO_PULL_ATTACK                      (1<<10)//if set, cannot do pull+attack move (move not available in MP anyway)
00702 #define SFL_NO_BACK_ATTACK                      (1<<11)//if set, cannot do back-stab moves
00703 #define SFL_NO_STABDOWN                         (1<<12)//if set, cannot do stabdown move (when enemy is on ground)
00704 #define SFL_NO_WALL_RUNS                        (1<<13)//if set, cannot side-run or forward-run on walls
00705 #define SFL_NO_WALL_FLIPS                       (1<<14)//if set, cannot do backflip off wall or side-flips off walls
00706 #define SFL_NO_WALL_GRAB                        (1<<15)//if set, cannot grab wall & jump off
00707 #define SFL_NO_ROLLS                            (1<<16)//if set, cannot roll
00708 #define SFL_NO_FLIPS                            (1<<17)//if set, cannot do flips
00709 #define SFL_NO_CARTWHEELS                       (1<<18)//if set, cannot do cartwheels
00710 #define SFL_NO_KICKS                            (1<<19)//if set, cannot do kicks (can't do kicks anyway if using a throwable saber/sword)
00711 #define SFL_NO_MIRROR_ATTACKS           (1<<20)//if set, cannot do the simultaneous attack left/right moves (only available in Dual Lightsaber Combat Style)
00712 #define SFL_NO_ROLL_STAB                        (1<<21)//if set, cannot do roll-stab move at end of roll
00713 //SABER FLAGS2
00714 //Primary Blade Style
00715 #define SFL2_NO_WALL_MARKS                      (1<<0)//if set, stops the saber from drawing marks on the world (good for real-sword type mods)
00716 #define SFL2_NO_DLIGHT                          (1<<1)//if set, stops the saber from drawing a dynamic light (good for real-sword type mods)
00717 #define SFL2_NO_BLADE                           (1<<2)//if set, stops the saber from drawing a blade (good for real-sword type mods)
00718 #define SFL2_NO_CLASH_FLARE                     (1<<3)//if set, the saber will not do the big, white clash flare with other sabers
00719 #define SFL2_NO_DISMEMBERMENT           (1<<4)//if set, the saber never does dismemberment (good for pointed/blunt melee weapons)
00720 #define SFL2_NO_IDLE_EFFECT                     (1<<5)//if set, the saber will not do damage or any effects when it is idle (not in an attack anim).  (good for real-sword type mods)
00721 #define SFL2_ALWAYS_BLOCK                       (1<<6)//if set, the blades will always be blocking (good for things like shields that should always block)
00722 #define SFL2_NO_MANUAL_DEACTIVATE       (1<<7)//if set, the blades cannot manually be toggled on and off
00723 #define SFL2_TRANSITION_DAMAGE          (1<<8)//if set, the blade does damage in start, transition and return anims (like strong style does)
00724 //Secondary Blade Style
00725 #define SFL2_NO_WALL_MARKS2                     (1<<9)//if set, stops the saber from drawing marks on the world (good for real-sword type mods)
00726 #define SFL2_NO_DLIGHT2                         (1<<10)//if set, stops the saber from drawing a dynamic light (good for real-sword type mods)
00727 #define SFL2_NO_BLADE2                          (1<<11)//if set, stops the saber from drawing a blade (good for real-sword type mods)
00728 #define SFL2_NO_CLASH_FLARE2            (1<<12)//if set, the saber will not do the big, white clash flare with other sabers
00729 #define SFL2_NO_DISMEMBERMENT2          (1<<13)//if set, the saber never does dismemberment (good for pointed/blunt melee weapons)
00730 #define SFL2_NO_IDLE_EFFECT2            (1<<14)//if set, the saber will not do damage or any effects when it is idle (not in an attack anim).  (good for real-sword type mods)
00731 #define SFL2_ALWAYS_BLOCK2                      (1<<15)//if set, the blades will always be blocking (good for things like shields that should always block)
00732 #define SFL2_NO_MANUAL_DEACTIVATE2      (1<<16)//if set, the blades cannot manually be toggled on and off
00733 #define SFL2_TRANSITION_DAMAGE2         (1<<17)//if set, the blade does damage in start, transition and return anims (like strong style does)
00734 
00735 typedef struct
00736 {
00737         char            name[64];                                               //entry in sabers.cfg, if any
00738         char            fullName[64];                           //the "Proper Name" of the saber, shown in UI
00739         saberType_t     type;                                           //none, single or staff
00740         char            model[MAX_QPATH];                                               //hilt model
00741         qhandle_t       skin;                                           //registered skin id
00742         int                     soundOn;                                        //game soundindex for turning on sound
00743         int                     soundLoop;                                      //game soundindex for hum/loop sound
00744         int                     soundOff;                                       //game soundindex for turning off sound
00745         int                     numBlades;
00746         bladeInfo_t     blade[MAX_BLADES];                      //blade info - like length, trail, origin, dir, etc.
00747         int                     stylesLearned;                          //styles you get when you get this saber, if any
00748         int                     stylesForbidden;                        //styles you cannot use with this saber, if any
00749         int                     maxChain;                                       //how many moves can be chained in a row with this weapon (-1 is infinite, 0 is use default behavior)
00750         int                     forceRestrictions;                      //force powers that cannot be used while this saber is on (bitfield) - FIXME: maybe make this a limit on the max level, per force power, that can be used with this type?
00751         int                     lockBonus;                                      //in saberlocks, this type of saber pushes harder or weaker
00752         int                     parryBonus;                                     //added to strength of parry with this saber
00753         int                     breakParryBonus;                        //added to strength when hit a parry
00754         int                     breakParryBonus2;                       //for bladeStyle2 (see bladeStyle2Start below)
00755         int                     disarmBonus;                            //added to disarm chance when win saberlock or have a good parry (knockaway)
00756         int                     disarmBonus2;                           //for bladeStyle2 (see bladeStyle2Start below)
00757         saber_styles_t  singleBladeStyle;               //makes it so that you use a different style if you only have the first blade active
00758 //      char            *brokenSaber1;                          //if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your right hand
00759 //      char            *brokenSaber2;                          //if saber is actually hit by another saber, it can be cut in half/broken and will be replaced with this saber in your left hand
00760 //===NEW========================================================================================
00761         //these values are global to the saber, like all of the ones above
00762         int                     saberFlags;                                     //from SFL_ list above
00763         int                     saberFlags2;                            //from SFL2_ list above
00764 
00765         //done in cgame (client-side code)
00766         qhandle_t       spinSound;                                      //none - if set, plays this sound as it spins when thrown
00767         qhandle_t       swingSound[3];                          //none - if set, plays one of these 3 sounds when swung during an attack - NOTE: must provide all 3!!!
00768 
00769         //done in game (server-side code)
00770         float           moveSpeedScale;                         //1.0 - you move faster/slower when using this saber
00771         float           animSpeedScale;                         //1.0 - plays normal attack animations faster/slower
00772 
00773         //done in both cgame and game (BG code)
00774         int     kataMove;                               //LS_INVALID - if set, player will execute this move when they press both attack buttons at the same time 
00775         int     lungeAtkMove;                   //LS_INVALID - if set, player will execute this move when they crouch+fwd+attack 
00776         int     jumpAtkUpMove;                  //LS_INVALID - if set, player will execute this move when they jump+attack 
00777         int     jumpAtkFwdMove;                 //LS_INVALID - if set, player will execute this move when they jump+fwd+attack 
00778         int     jumpAtkBackMove;                //LS_INVALID - if set, player will execute this move when they jump+back+attack
00779         int     jumpAtkRightMove;               //LS_INVALID - if set, player will execute this move when they jump+rightattack
00780         int     jumpAtkLeftMove;                //LS_INVALID - if set, player will execute this move when they jump+left+attack
00781         int     readyAnim;                              //-1 - anim to use when standing idle
00782         int     drawAnim;                               //-1 - anim to use when drawing weapon
00783         int     putawayAnim;                    //-1 - anim to use when putting weapon away
00784         int     tauntAnim;                              //-1 - anim to use when hit "taunt"
00785         int     bowAnim;                                //-1 - anim to use when hit "bow"
00786         int     meditateAnim;                   //-1 - anim to use when hit "meditate"
00787         int     flourishAnim;                   //-1 - anim to use when hit "flourish"
00788         int     gloatAnim;                              //-1 - anim to use when hit "gloat"
00789 
00790         //***NOTE: you can only have a maximum of 2 "styles" of blades, so this next value, "bladeStyle2Start" is the number of the first blade to use these value on... all blades before this use the normal values above, all blades at and after this number use the secondary values below***
00791         int                     bladeStyle2Start;                       //0 - if set, blades from this number and higher use the following values (otherwise, they use the normal values already set)
00792 
00793         //***The following can be different for the extra blades - not setting them individually defaults them to the value for the whole saber (and first blade)***
00794         
00795         //===PRIMARY BLADES=====================
00796         //done in cgame (client-side code)
00797         int                     trailStyle;                                     //0 - default (0) is normal, 1 is a motion blur and 2 is no trail at all (good for real-sword type mods)
00798         int                     g2MarksShader;                          //none - if set, the game will use this shader for marks on enemies instead of the default "gfx/damage/saberglowmark"
00799         int                     g2WeaponMarkShader;                     //none - if set, the game will ry to project this shader onto the weapon when it damages a person (good for a blood splatter on the weapon)
00800         //int           bladeShader;                            //none - if set, overrides the shader used for the saber blade?
00801         //int           trailShader;                            //none - if set, overrides the shader used for the saber trail?
00802         qhandle_t       hitSound[3];                            //none - if set, plays one of these 3 sounds when saber hits a person - NOTE: must provide all 3!!!
00803         qhandle_t       blockSound[3];                          //none - if set, plays one of these 3 sounds when saber/sword hits another saber/sword - NOTE: must provide all 3!!!
00804         qhandle_t       bounceSound[3];                         //none - if set, plays one of these 3 sounds when saber/sword hits a wall and bounces off (must set bounceOnWall to 1 to use these sounds) - NOTE: must provide all 3!!!
00805         int                     blockEffect;                            //none - if set, plays this effect when the saber/sword hits another saber/sword (instead of "saber/saber_block.efx")
00806         int                     hitPersonEffect;                        //none - if set, plays this effect when the saber/sword hits a person (instead of "saber/blood_sparks_mp.efx")
00807         int                     hitOtherEffect;                         //none - if set, plays this effect when the saber/sword hits something else damagable (instead of "saber/saber_cut.efx")
00808         int                     bladeEffect;                            //none - if set, plays this effect at the blade tag
00809 
00810         //done in game (server-side code)
00811         float           knockbackScale;                         //0 - if non-zero, uses damage done to calculate an appropriate amount of knockback
00812         float           damageScale;                            //1 - scale up or down the damage done by the saber
00813         float           splashRadius;                           //0 - radius of splashDamage
00814         int                     splashDamage;                           //0 - amount of splashDamage, 100% at a distance of 0, 0% at a distance = splashRadius
00815         float           splashKnockback;                        //0 - amount of splashKnockback, 100% at a distance of 0, 0% at a distance = splashRadius
00816         
00817         //===SECONDARY BLADES===================
00818         //done in cgame (client-side code)
00819         int                     trailStyle2;                            //0 - default (0) is normal, 1 is a motion blur and 2 is no trail at all (good for real-sword type mods)
00820         int                     g2MarksShader2;                         //none - if set, the game will use this shader for marks on enemies instead of the default "gfx/damage/saberglowmark"
00821         int                     g2WeaponMarkShader2;            //none - if set, the game will ry to project this shader onto the weapon when it damages a person (good for a blood splatter on the weapon)
00822         //int           bladeShader2;                           //none - if set, overrides the shader used for the saber blade?
00823         //int           trailShader2;                           //none - if set, overrides the shader used for the saber trail?
00824         qhandle_t       hit2Sound[3];                           //none - if set, plays one of these 3 sounds when saber hits a person - NOTE: must provide all 3!!!
00825         qhandle_t       block2Sound[3];                         //none - if set, plays one of these 3 sounds when saber/sword hits another saber/sword - NOTE: must provide all 3!!!
00826         qhandle_t       bounce2Sound[3];                        //none - if set, plays one of these 3 sounds when saber/sword hits a wall and bounces off (must set bounceOnWall to 1 to use these sounds) - NOTE: must provide all 3!!!
00827         int                     blockEffect2;                           //none - if set, plays this effect when the saber/sword hits another saber/sword (instead of "saber/saber_block.efx")
00828         int                     hitPersonEffect2;                       //none - if set, plays this effect when the saber/sword hits a person (instead of "saber/blood_sparks_mp.efx")
00829         int                     hitOtherEffect2;                        //none - if set, plays this effect when the saber/sword hits something else damagable (instead of "saber/saber_cut.efx")
00830         int                     bladeEffect2;                           //none - if set, plays this effect at the blade tag
00831 
00832         //done in game (server-side code)
00833         float           knockbackScale2;                        //0 - if non-zero, uses damage done to calculate an appropriate amount of knockback
00834         float           damageScale2;                           //1 - scale up or down the damage done by the saber
00835         float           splashRadius2;                          //0 - radius of splashDamage
00836         int                     splashDamage2;                          //0 - amount of splashDamage, 100% at a distance of 0, 0% at a distance = splashRadius
00837         float           splashKnockback2;                       //0 - amount of splashKnockback, 100% at a distance of 0, 0% at a distance = splashRadius
00838 //=========================================================================================================================================
00839 
00840 } saberInfo_t;
00841 #define MAX_SABERS 2
00842 
00843 typedef enum
00844 {
00845         FORCE_LEVEL_0,
00846         FORCE_LEVEL_1,
00847         FORCE_LEVEL_2,
00848         FORCE_LEVEL_3,
00849         NUM_FORCE_POWER_LEVELS
00850 };
00851 
00852 #define FORCE_LEVEL_4 (FORCE_LEVEL_3+1)
00853 #define FORCE_LEVEL_5 (FORCE_LEVEL_4+1)
00854 
00855 //rww - a C-ified structure version of the class which fires off callbacks and gives arguments to update ragdoll status.
00856 enum sharedERagPhase
00857 {
00858         RP_START_DEATH_ANIM,
00859         RP_END_DEATH_ANIM,
00860         RP_DEATH_COLLISION,
00861         RP_CORPSE_SHOT,
00862         RP_GET_PELVIS_OFFSET,  // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
00863         RP_SET_PELVIS_OFFSET,  // this actually does nothing but set the pelvisAnglesOffset, and pelvisPositionOffset
00864         RP_DISABLE_EFFECTORS  // this removes effectors given by the effectorsToTurnOff member
00865 };
00866 
00867 enum sharedERagEffector
00868 {
00869         RE_MODEL_ROOT=                  0x00000001, //"model_root"
00870         RE_PELVIS=                              0x00000002, //"pelvis"
00871         RE_LOWER_LUMBAR=                0x00000004, //"lower_lumbar"
00872         RE_UPPER_LUMBAR=                0x00000008, //"upper_lumbar"
00873         RE_THORACIC=                    0x00000010, //"thoracic"
00874         RE_CRANIUM=                             0x00000020, //"cranium"
00875         RE_RHUMEROUS=                   0x00000040, //"rhumerus"
00876         RE_LHUMEROUS=                   0x00000080, //"lhumerus"
00877         RE_RRADIUS=                             0x00000100, //"rradius"
00878         RE_LRADIUS=                             0x00000200, //"lradius"
00879         RE_RFEMURYZ=                    0x00000400, //"rfemurYZ"
00880         RE_LFEMURYZ=                    0x00000800, //"lfemurYZ"
00881         RE_RTIBIA=                              0x00001000, //"rtibia"
00882         RE_LTIBIA=                              0x00002000, //"ltibia"
00883         RE_RHAND=                               0x00004000, //"rhand"
00884         RE_LHAND=                               0x00008000, //"lhand"
00885         RE_RTARSAL=                             0x00010000, //"rtarsal"
00886         RE_LTARSAL=                             0x00020000, //"ltarsal"
00887         RE_RTALUS=                              0x00040000, //"rtalus"
00888         RE_LTALUS=                              0x00080000, //"ltalus"
00889         RE_RRADIUSX=                    0x00100000, //"rradiusX"
00890         RE_LRADIUSX=                    0x00200000, //"lradiusX"
00891         RE_RFEMURX=                             0x00400000, //"rfemurX"
00892         RE_LFEMURX=                             0x00800000, //"lfemurX"
00893         RE_CEYEBROW=                    0x01000000 //"ceyebrow"
00894 };
00895 
00896 typedef struct
00897 {
00898         vec3_t angles;
00899         vec3_t position;
00900         vec3_t scale;
00901         vec3_t pelvisAnglesOffset;    // always set on return, an argument for RP_SET_PELVIS_OFFSET
00902         vec3_t pelvisPositionOffset; // always set on return, an argument for RP_SET_PELVIS_OFFSET
00903 
00904         float fImpactStrength; //should be applicable when RagPhase is RP_DEATH_COLLISION
00905         float fShotStrength; //should be applicable for setting velocity of corpse on shot (probably only on RP_CORPSE_SHOT)
00906         int me; //index of entity giving this update
00907 
00908         //rww - we have convenient animation/frame access in the game, so just send this info over from there.
00909         int startFrame;
00910         int endFrame;
00911 
00912         int collisionType; // 1 = from a fall, 0 from effectors, this will be going away soon, hence no enum 
00913 
00914         qboolean CallRagDollBegin; // a return value, means that we are now begininng ragdoll and the NPC stuff needs to happen
00915 
00916         int RagPhase;
00917 
00918 // effector control, used for RP_DISABLE_EFFECTORS call
00919 
00920         int effectorsToTurnOff;  // set this to an | of the above flags for a RP_DISABLE_EFFECTORS
00921 
00922 } sharedRagDollParams_t;
00923 
00924 //And one for updating during model animation.
00925 typedef struct
00926 {
00927         vec3_t angles;
00928         vec3_t position;
00929         vec3_t scale;
00930         vec3_t velocity;
00931         int     me;
00932         int settleFrame;
00933 } sharedRagDollUpdateParams_t;
00934 
00935 //rww - update parms for ik bone stuff
00936 typedef struct
00937 {
00938         char boneName[512]; //name of bone
00939         vec3_t desiredOrigin; //world coordinate that this bone should be attempting to reach
00940         vec3_t origin; //world coordinate of the entity who owns the g2 instance that owns the bone
00941         float movementSpeed; //how fast the bone should move toward the destination
00942 } sharedIKMoveParams_t;
00943 
00944 
00945 typedef struct
00946 {
00947         vec3_t pcjMins; //ik joint limit
00948         vec3_t pcjMaxs; //ik joint limit
00949         vec3_t origin; //origin of caller
00950         vec3_t angles; //angles of caller
00951         vec3_t scale; //scale of caller
00952         float radius; //bone rad
00953         int blendTime; //bone blend time
00954         int pcjOverrides; //override ik bone flags
00955         int startFrame; //base pose start
00956         int endFrame; //base pose end
00957         qboolean forceAnimOnBone; //normally if the bone has specified start/end frames already it will leave it alone.. if this is true, then the animation will be restarted on the bone with the specified frames anyway.
00958 } sharedSetBoneIKStateParams_t;
00959 
00960 enum sharedEIKMoveState
00961 {
00962         IKS_NONE = 0,
00963         IKS_DYNAMIC
00964 };
00965 
00966 //material stuff needs to be shared
00967 typedef enum //# material_e
00968 {
00969         MAT_METAL = 0,  // scorched blue-grey metal
00970         MAT_GLASS,              // not a real chunk type, just plays an effect with glass sprites
00971         MAT_ELECTRICAL, // sparks only
00972         MAT_ELEC_METAL, // sparks/electrical type metal
00973         MAT_DRK_STONE,  // brown
00974         MAT_LT_STONE,   // tan
00975         MAT_GLASS_METAL,// glass sprites and METAl chunk
00976         MAT_METAL2,             // electrical metal type
00977         MAT_NONE,               // no chunks
00978         MAT_GREY_STONE, // grey
00979         MAT_METAL3,             // METAL and METAL2 chunks
00980         MAT_CRATE1,             // yellow multi-colored crate chunks
00981         MAT_GRATE1,             // grate chunks
00982         MAT_ROPE,               // for yavin trial...no chunks, just wispy bits
00983         MAT_CRATE2,             // read multi-colored crate chunks
00984         MAT_WHITE_METAL,// white angular chunks
00985         MAT_SNOWY_ROCK, // gray & brown chunks
00986 
00987         NUM_MATERIALS
00988 
00989 };
00990 typedef int material_t;
00991 
00992 //rww - bot stuff that needs to be shared
00993 #define MAX_WPARRAY_SIZE 4096
00994 #define MAX_NEIGHBOR_SIZE 32
00995 
00996 #define MAX_NEIGHBOR_LINK_DISTANCE 128
00997 #define MAX_NEIGHBOR_FORCEJUMP_LINK_DISTANCE 400
00998 
00999 #define DEFAULT_GRID_SPACING 400
01000 
01001 typedef struct wpneighbor_s
01002 {
01003         int num;
01004         int forceJumpTo;
01005 } wpneighbor_t;
01006 
01007 typedef struct wpobject_s
01008 {
01009         vec3_t origin;
01010         int inuse;
01011         int index;
01012         float weight;
01013         float disttonext;
01014         int flags;
01015         int associated_entity;
01016 
01017         int forceJumpTo;
01018 
01019         int neighbornum;
01020         wpneighbor_t neighbors[MAX_NEIGHBOR_SIZE];
01021 } wpobject_t;
01022 
01023 
01024 #define NUMVERTEXNORMALS        162
01025 extern  vec3_t  bytedirs[NUMVERTEXNORMALS];
01026 
01027 // all drawing is done to a 640*480 virtual screen size
01028 // and will be automatically scaled to the real resolution
01029 #define SCREEN_WIDTH            640
01030 #define SCREEN_HEIGHT           480
01031 
01032 #define TINYCHAR_WIDTH          (SMALLCHAR_WIDTH)
01033 #define TINYCHAR_HEIGHT         (SMALLCHAR_HEIGHT/2)
01034 
01035 #define SMALLCHAR_WIDTH         8
01036 #define SMALLCHAR_HEIGHT        16
01037 
01038 #define BIGCHAR_WIDTH           16
01039 #define BIGCHAR_HEIGHT          16
01040 
01041 #define GIANTCHAR_WIDTH         32
01042 #define GIANTCHAR_HEIGHT        48
01043 
01044 typedef enum
01045 {
01046 CT_NONE,
01047 CT_BLACK,
01048 CT_RED,
01049 CT_GREEN,
01050 CT_BLUE,
01051 CT_YELLOW,
01052 CT_MAGENTA,
01053 CT_CYAN,
01054 CT_WHITE,
01055 CT_LTGREY,
01056 CT_MDGREY,
01057 CT_DKGREY,
01058 CT_DKGREY2,
01059 
01060 CT_VLTORANGE,
01061 CT_LTORANGE,
01062 CT_DKORANGE,
01063 CT_VDKORANGE,
01064 
01065 CT_VLTBLUE1,
01066 CT_LTBLUE1,
01067 CT_DKBLUE1,
01068 CT_VDKBLUE1,
01069 
01070 CT_VLTBLUE2,
01071 CT_LTBLUE2,
01072 CT_DKBLUE2,
01073 CT_VDKBLUE2,
01074 
01075 CT_VLTBROWN1,
01076 CT_LTBROWN1,
01077 CT_DKBROWN1,
01078 CT_VDKBROWN1,
01079 
01080 CT_VLTGOLD1,
01081 CT_LTGOLD1,
01082 CT_DKGOLD1,
01083 CT_VDKGOLD1,
01084 
01085 CT_VLTPURPLE1,
01086 CT_LTPURPLE1,
01087 CT_DKPURPLE1,
01088 CT_VDKPURPLE1,
01089 
01090 CT_VLTPURPLE2,
01091 CT_LTPURPLE2,
01092 CT_DKPURPLE2,
01093 CT_VDKPURPLE2,
01094 
01095 CT_VLTPURPLE3,
01096 CT_LTPURPLE3,
01097 CT_DKPURPLE3,
01098 CT_VDKPURPLE3,
01099 
01100 CT_VLTRED1,
01101 CT_LTRED1,
01102 CT_DKRED1,
01103 CT_VDKRED1,
01104 CT_VDKRED,
01105 CT_DKRED,
01106 
01107 CT_VLTAQUA,
01108 CT_LTAQUA,
01109 CT_DKAQUA,
01110 CT_VDKAQUA,
01111 
01112 CT_LTPINK,
01113 CT_DKPINK,
01114 CT_LTCYAN,
01115 CT_DKCYAN,
01116 CT_LTBLUE3,
01117 CT_BLUE3,
01118 CT_DKBLUE3,
01119 
01120 CT_HUD_GREEN,
01121 CT_HUD_RED,
01122 CT_ICON_BLUE,
01123 CT_NO_AMMO_RED,
01124 CT_HUD_ORANGE,
01125 
01126 CT_MAX
01127 } ct_table_t;
01128 
01129 extern vec4_t colorTable[CT_MAX];
01130 
01131 extern  vec4_t          colorBlack;
01132 extern  vec4_t          colorRed;
01133 extern  vec4_t          colorGreen;
01134 extern  vec4_t          colorBlue;
01135 extern  vec4_t          colorYellow;
01136 extern  vec4_t          colorMagenta;
01137 extern  vec4_t          colorCyan;
01138 extern  vec4_t          colorWhite;
01139 extern  vec4_t          colorLtGrey;
01140 extern  vec4_t          colorMdGrey;
01141 extern  vec4_t          colorDkGrey;
01142 extern  vec4_t          colorLtBlue;
01143 extern  vec4_t          colorDkBlue;
01144 
01145 #define Q_COLOR_ESCAPE  '^'
01146 // you MUST have the last bit on here about colour strings being less than 7 or taiwanese strings register as colour!!!!
01147 #define Q_IsColorString(p)      ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE && *((p)+1) <= '7' && *((p)+1) >= '0' )
01148 
01149 
01150 #define COLOR_BLACK             '0'
01151 #define COLOR_RED               '1'
01152 #define COLOR_GREEN             '2'
01153 #define COLOR_YELLOW    '3'
01154 #define COLOR_BLUE              '4'
01155 #define COLOR_CYAN              '5'
01156 #define COLOR_MAGENTA   '6'
01157 #define COLOR_WHITE             '7'
01158 #define ColorIndex(c)   ( ( (c) - '0' ) & 7 )
01159 
01160 #define S_COLOR_BLACK   "^0"
01161 #define S_COLOR_RED             "^1"
01162 #define S_COLOR_GREEN   "^2"
01163 #define S_COLOR_YELLOW  "^3"
01164 #define S_COLOR_BLUE    "^4"
01165 #define S_COLOR_CYAN    "^5"
01166 #define S_COLOR_MAGENTA "^6"
01167 #define S_COLOR_WHITE   "^7"
01168 
01169 extern vec4_t   g_color_table[8];
01170 
01171 #define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b
01172 #define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a
01173 
01174 #define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )
01175 #define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )
01176 
01177 struct cplane_s;
01178 
01179 extern  vec3_t  vec3_origin;
01180 extern  vec3_t  axisDefault[3];
01181 
01182 #define nanmask (255<<23)
01183 
01184 #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
01185 
01186 #ifdef _XBOX
01187 inline void Q_CastShort2Float(float *f, const short *s)
01188 {
01189         *f = ((float)*s);
01190 }
01191 
01192 inline void Q_CastUShort2Float(float *f, const unsigned short *s)
01193 {
01194         *f = ((float)*s);
01195 }
01196 
01197 inline void Q_CastShort2FloatScale(float *f, const short *s, float scale)
01198 {
01199         *f = ((float)*s) * scale;
01200 }
01201 
01202 inline void Q_CastUShort2FloatScale(float *f, const unsigned short *s, float scale)
01203 {
01204         *f = ((float)*s) * scale;
01205 }
01206 #endif // _XBOX
01207 
01208 #if idppc
01209 
01210 static inline float Q_rsqrt( float number ) {
01211                 float x = 0.5f * number;
01212                 float y;
01213 #ifdef __GNUC__            
01214                 asm("frsqrte %0,%1" : "=f" (y) : "f" (number));
01215 #else
01216                 y = __frsqrte( number );
01217 #endif
01218                 return y * (1.5f - (x * y * y));
01219         }
01220 
01221 #ifdef __GNUC__            
01222 static inline float Q_fabs(float x) {
01223     float abs_x;
01224     
01225     asm("fabs %0,%1" : "=f" (abs_x) : "f" (x));
01226     return abs_x;
01227 }
01228 #else
01229 #define Q_fabs __fabsf
01230 #endif
01231 
01232 #else
01233 float Q_fabs( float f );
01234 float Q_rsqrt( float f );               // reciprocal square root
01235 #endif
01236 
01237 #define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) )
01238 
01239 signed char ClampChar( int i );
01240 signed short ClampShort( int i );
01241 
01242 float powf ( float x, int y );
01243 
01244 // this isn't a real cheap function to call!
01245 int DirToByte( vec3_t dir );
01246 void ByteToDir( int b, vec3_t dir );
01247 
01248 #ifdef _XBOX
01249 // SSE Vectorized math functions
01250 inline vec_t DotProduct( const vec3_t v1, const vec3_t v2 ) {
01251 #if defined (_XBOX)             
01252         float res;
01253     __asm {
01254         mov     edx, v1
01255         movss   xmm1, [edx]
01256         movhps  xmm1, [edx+4]
01257 
01258         mov     edx, v2
01259         movss   xmm2, [edx]
01260         movhps  xmm2, [edx+4]
01261 
01262         mulps   xmm1, xmm2
01263 
01264         movaps  xmm0, xmm1
01265 
01266         shufps  xmm0, xmm0, 32h
01267         addps   xmm1, xmm0
01268 
01269         shufps  xmm0, xmm0, 32h
01270         addps   xmm1, xmm0
01271 
01272         movss   [res], xmm1
01273     }
01274     return res;
01275 #else
01276         return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
01277 #endif
01278 }
01279 
01280 inline void VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t o ) {
01281 #ifdef _XBOX
01282         __asm {
01283         mov      ecx, veca
01284         movss    xmm0, [ecx]
01285         movhps   xmm0, [ecx+4]
01286 
01287         mov      edx, vecb
01288         movss    xmm1, [edx]
01289         movhps   xmm1, [edx+4]
01290 
01291         subps    xmm0, xmm1
01292 
01293         mov      eax, o
01294         movss    [eax], xmm0
01295         movhps   [eax+4], xmm0
01296     }
01297 #else
01298         o[0] = veca[0]-vecb[0];
01299         o[1] = veca[1]-vecb[1];
01300         o[2] = veca[2]-vecb[2];
01301 #endif
01302 }
01303 
01304 inline void VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t o ) {
01305 #ifdef _XBOX
01306   __asm {
01307         mov      ecx, veca
01308         movss    xmm0, [ecx]
01309         movhps   xmm0, [ecx+4]
01310 
01311         mov      edx, vecb
01312         movss    xmm1, [edx]
01313         movhps   xmm1, [edx+4]
01314 
01315         addps    xmm0, xmm1
01316 
01317         mov      eax, o
01318         movss    [eax], xmm0
01319         movhps   [eax+4], xmm0
01320     }
01321 #else
01322         o[0] = veca[0]+vecb[0];
01323         o[1] = veca[1]+vecb[1];
01324         o[2] = veca[2]+vecb[2];
01325 #endif
01326 }
01327 
01328 inline void VectorScale( const vec3_t i, vec_t scale, vec3_t o ) {
01329 #ifdef _XBOX
01330 __asm {
01331         movss    xmm0, scale
01332         shufps   xmm0, xmm0, 0h
01333 
01334         mov      edx, i
01335         movss    xmm1, [edx]
01336         movhps   xmm1, [edx+4]
01337 
01338         mulps    xmm0, xmm1
01339 
01340         mov      eax, o
01341         movss    [eax], xmm0
01342         movhps   [eax+4], xmm0
01343     }
01344 #else
01345         o[0] = i[0]*scale;
01346         o[1] = i[1]*scale;
01347         o[2] = i[2]*scale;
01348 #endif
01349 }
01350 #endif  // _XBOX
01351 
01352 #if     1
01353 //rwwRMG - added math defines
01354 #define minimum(x,y) ((x)<(y)?(x):(y))
01355 #define maximum(x,y) ((x)>(y)?(x):(y))
01356 
01357 #ifndef _XBOX   // Done above to use SSE
01358 #define DotProduct(x,y)                                 ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
01359 #define VectorSubtract(a,b,c)                   ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
01360 #define VectorAdd(a,b,c)                                ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
01361 #define VectorScale(v, s, o)                    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
01362 #endif
01363 #define VectorCopy(a,b)                                 ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
01364 #define VectorCopy4(a,b)                                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
01365 #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))
01366 #define VectorInc(v)                                    ((v)[0] += 1.0f,(v)[1] += 1.0f,(v)[2] +=1.0f)
01367 #define VectorDec(v)                                    ((v)[0] -= 1.0f,(v)[1] -= 1.0f,(v)[2] -=1.0f)
01368 #define VectorInverseScaleVector(a,b,c) ((c)[0]=(a)[0]/(b)[0],(c)[1]=(a)[1]/(b)[1],(c)[2]=(a)[2]/(b)[2])
01369 #define VectorScaleVectorAdd(c,a,b,o)   ((o)[0]=(c)[0]+((a)[0]*(b)[0]),(o)[1]=(c)[1]+((a)[1]*(b)[1]),(o)[2]=(c)[2]+((a)[2]*(b)[2]))
01370 #define VectorAdvance(a,s,b,c)                  (((c)[0]=(a)[0] + s * ((b)[0] - (a)[0])),((c)[1]=(a)[1] + s * ((b)[1] - (a)[1])),((c)[2]=(a)[2] + s * ((b)[2] - (a)[2])))
01371 #define VectorAverage(a,b,c)                    (((c)[0]=((a)[0]+(b)[0])*0.5f),((c)[1]=((a)[1]+(b)[1])*0.5f),((c)[2]=((a)[2]+(b)[2])*0.5f))
01372 #define VectorScaleVector(a,b,c)                (((c)[0]=(a)[0]*(b)[0]),((c)[1]=(a)[1]*(b)[1]),((c)[2]=(a)[2]*(b)[2]))
01373 
01374 #else
01375 
01376 #define DotProduct(x,y)                 _DotProduct(x,y)
01377 #define VectorSubtract(a,b,c)   _VectorSubtract(a,b,c)
01378 #define VectorAdd(a,b,c)                _VectorAdd(a,b,c)
01379 #define VectorCopy(a,b)                 _VectorCopy(a,b)
01380 #define VectorScale(v, s, o)    _VectorScale(v,s,o)
01381 #define VectorMA(v, s, b, o)    _VectorMA(v,s,b,o)
01382 
01383 #endif
01384 
01385 #ifdef __LCC__
01386 #ifdef VectorCopy
01387 #undef VectorCopy
01388 // this is a little hack to get more efficient copies in our interpreter
01389 typedef struct {
01390         float   v[3];
01391 } vec3struct_t;
01392 #define VectorCopy(a,b) *(vec3struct_t *)b=*(vec3struct_t *)a;
01393 #define ID_INLINE static
01394 #endif
01395 #endif
01396 
01397 #define VectorClear(a)                  ((a)[0]=(a)[1]=(a)[2]=0)
01398 #define VectorNegate(a,b)               ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
01399 #define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
01400 #define VectorSet5(v,x,y,z,a,b) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z), (v)[3]=(a), (v)[4]=(b)) //rwwRMG - added
01401 #define Vector4Copy(a,b)                ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
01402 
01403 #ifdef __linux__
01404 #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));}
01405 #else 
01406 #ifndef __LCC__
01407 //pitiful attempt to reduce _ftol2 calls -rww
01408 static ID_INLINE void SnapVector( float *v )
01409 {
01410         static int i;
01411         static float f;
01412 
01413         f = *v;
01414         __asm   fld             f;
01415         __asm   fistp   i;
01416         *v = i;
01417         v++;
01418         f = *v;
01419         __asm   fld             f;
01420         __asm   fistp   i;
01421         *v = i;
01422         v++;
01423         f = *v;
01424         __asm   fld             f;
01425         __asm   fistp   i;
01426         *v = i;
01427 }
01428 #else
01429 #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));}
01430 #endif // __LCC__
01431 #endif // __linux__
01432 
01433 // just in case you do't want to use the macros
01434 vec_t _DotProduct( const vec3_t v1, const vec3_t v2 );
01435 void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out );
01436 void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out );
01437 void _VectorCopy( const vec3_t in, vec3_t out );
01438 void _VectorScale( const vec3_t in, float scale, vec3_t out );
01439 void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc );
01440 
01441 unsigned ColorBytes3 (float r, float g, float b);
01442 unsigned ColorBytes4 (float r, float g, float b, float a);
01443 
01444 float NormalizeColor( const vec3_t in, vec3_t out );
01445 
01446 float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
01447 void ClearBounds( vec3_t mins, vec3_t maxs );
01448 vec_t DistanceHorizontal( const vec3_t p1, const vec3_t p2 );
01449 vec_t DistanceHorizontalSquared( const vec3_t p1, const vec3_t p2 );
01450 void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
01451 
01452 #ifndef __LCC__
01453 static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
01454         if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
01455                 return 0;
01456         }                       
01457         return 1;
01458 }
01459 
01460 static ID_INLINE vec_t VectorLength( const vec3_t v ) {
01461 #ifdef _XBOX
01462         float res;
01463 
01464         __asm {
01465         mov     edx, v
01466         movss   xmm1, [edx]
01467         movhps  xmm1, [edx+4]
01468 
01469         movaps  xmm2, xmm1
01470 
01471         mulps   xmm1, xmm2
01472 
01473         movaps  xmm0, xmm1
01474 
01475         shufps  xmm0, xmm0, 32h
01476         addps   xmm1, xmm0
01477 
01478         shufps  xmm0, xmm0, 32h
01479         addps   xmm1, xmm0
01480 
01481         sqrtss  xmm1, xmm1
01482         movss   [res], xmm1
01483     }
01484 
01485     return res;
01486 #else
01487         return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
01488 #endif
01489 }
01490 
01491 static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) {
01492 #ifdef _XBOX
01493         float res;
01494         __asm {
01495         mov     edx, v
01496         movss   xmm1, [edx]
01497         movhps  xmm1, [edx+4]
01498 
01499         movaps  xmm2, xmm1
01500 
01501         mulps   xmm1, xmm2
01502 
01503         movaps  xmm0, xmm1
01504 
01505         shufps  xmm0, xmm0, 32h
01506         addps   xmm1, xmm0
01507 
01508         shufps  xmm0, xmm0, 32h
01509         addps   xmm1, xmm0
01510 
01511         movss   [res], xmm1
01512     }
01513 
01514     return res;
01515 #else
01516         return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
01517 #endif
01518 }
01519 
01520 static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
01521         vec3_t  v;
01522 
01523         VectorSubtract (p2, p1, v);
01524         return VectorLength( v );
01525 }
01526 
01527 static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
01528         vec3_t  v;
01529 
01530         VectorSubtract (p2, p1, v);
01531         return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
01532 }
01533 
01534 // fast vector normalize routine that does not check to make sure
01535 // that length != 0, nor does it return length, uses rsqrt approximation
01536 static ID_INLINE void VectorNormalizeFast( vec3_t v )
01537 {
01538         float ilength;
01539 
01540         ilength = Q_rsqrt( DotProduct( v, v ) );
01541 
01542         v[0] *= ilength;
01543         v[1] *= ilength;
01544         v[2] *= ilength;
01545 }
01546 
01547 static ID_INLINE void VectorInverse( vec3_t v ){
01548         v[0] = -v[0];
01549         v[1] = -v[1];
01550         v[2] = -v[2];
01551 }
01552 
01553 static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {
01554         cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
01555         cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
01556         cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
01557 }
01558 
01559 #else
01560 int VectorCompare( const vec3_t v1, const vec3_t v2 );
01561 
01562 vec_t VectorLength( const vec3_t v );
01563 
01564 vec_t VectorLengthSquared( const vec3_t v );
01565 
01566 vec_t Distance( const vec3_t p1, const vec3_t p2 );
01567 
01568 vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 );
01569  
01570 void VectorNormalizeFast( vec3_t v );
01571 
01572 void VectorInverse( vec3_t v );
01573 
01574 void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross );
01575 
01576 #endif
01577 
01578 vec_t VectorNormalize (vec3_t v);               // returns vector length
01579 vec_t VectorNormalize2( const vec3_t v, vec3_t out );
01580 void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out );
01581 void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out );
01582 int Q_log2(int val);
01583 
01584 float Q_acos(float c);
01585 float Q_asin(float c);
01586 
01587 int             Q_rand( int *seed );
01588 float   Q_random( int *seed );
01589 float   Q_crandom( int *seed );
01590 
01591 #define random()        ((rand () & 0x7fff) / ((float)0x7fff))
01592 #define crandom()       (2.0 * (random() - 0.5))
01593 
01594 void vectoangles( const vec3_t value1, vec3_t angles);
01595 void AnglesToAxis( const vec3_t angles, vec3_t axis[3] );
01596 
01597 void AxisClear( vec3_t axis[3] );
01598 void AxisCopy( vec3_t in[3], vec3_t out[3] );
01599 
01600 void SetPlaneSignbits( struct cplane_s *out );
01601 int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane);
01602 
01603 double  fmod( double x, double y );
01604 float   AngleMod(float a);
01605 float   LerpAngle (float from, float to, float frac);
01606 float   AngleSubtract( float a1, float a2 );
01607 void    AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 );
01608 
01609 float AngleNormalize360 ( float angle );
01610 float AngleNormalize180 ( float angle );
01611 float AngleDelta ( float angle1, float angle2 );
01612 
01613 qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c );
01614 void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
01615 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
01616 void RotateAroundDirection( vec3_t axis[3], float yaw );
01617 void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up );
01618 // perpendicular vector could be replaced by this
01619 
01620 //int   PlaneTypeForNormal (vec3_t normal);
01621 
01622 void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]);
01623 void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
01624 void PerpendicularVector( vec3_t dst, const vec3_t src );
01625 void NormalToLatLong( const vec3_t normal, byte bytes[2] ); //rwwRMG - added
01626 
01627 //=============================================
01628 
01629 int Com_Clampi( int min, int max, int value ); //rwwRMG - added
01630 float Com_Clamp( float min, float max, float value );
01631 
01632 char    *COM_SkipPath( char *pathname );
01633 void    COM_StripExtension( const char *in, char *out );
01634 void    COM_DefaultExtension( char *path, int maxSize, const char *extension );
01635 
01636 void    COM_BeginParseSession( const char *name );
01637 int             COM_GetCurrentParseLine( void );
01638 const char      *SkipWhitespace( const char *data, qboolean *hasNewLines );
01639 char    *COM_Parse( const char **data_p );
01640 char    *COM_ParseExt( const char **data_p, qboolean allowLineBreak );
01641 int             COM_Compress( char *data_p );
01642 void    COM_ParseError( char *format, ... );
01643 void    COM_ParseWarning( char *format, ... );
01644 qboolean COM_ParseString( const char **data, const char **s );
01645 qboolean COM_ParseInt( const char **data, int *i );
01646 qboolean COM_ParseFloat( const char **data, float *f );
01647 qboolean COM_ParseVec4( const char **buffer, vec4_t *c);
01648 //int           COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] );
01649 
01650 #define MAX_TOKENLENGTH         1024
01651 
01652 #ifndef TT_STRING
01653 //token types
01654 #define TT_STRING                                       1                       // string
01655 #define TT_LITERAL                                      2                       // literal
01656 #define TT_NUMBER                                       3                       // number
01657 #define TT_NAME                                         4                       // name
01658 #define TT_PUNCTUATION                          5                       // punctuation
01659 #endif
01660 
01661 typedef struct pc_token_s
01662 {
01663         int type;
01664         int subtype;
01665         int intvalue;
01666         float floatvalue;
01667         char string[MAX_TOKENLENGTH];
01668 } pc_token_t;
01669 
01670 // data is an in/out parm, returns a parsed out token
01671 
01672 void    COM_MatchToken( const char**buf_p, char *match );
01673 
01674 void SkipBracedSection (const char **program);
01675 void SkipRestOfLine ( const char **data );
01676 
01677 void Parse1DMatrix (const char **buf_p, int x, float *m);
01678 void Parse2DMatrix (const char **buf_p, int y, int x, float *m);
01679 void Parse3DMatrix (const char **buf_p, int z, int y, int x, float *m);
01680 
01681 void    QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
01682 
01683 
01684 // mode parm for FS_FOpenFile
01685 typedef enum {
01686         FS_READ,
01687         FS_WRITE,
01688         FS_APPEND,
01689         FS_APPEND_SYNC
01690 } fsMode_t;
01691 
01692 typedef enum {
01693         FS_SEEK_CUR,
01694         FS_SEEK_END,
01695         FS_SEEK_SET
01696 } fsOrigin_t;
01697 
01698 //=============================================
01699 
01700 int Q_isprint( int c );
01701 int Q_islower( int c );
01702 int Q_isupper( int c );
01703 int Q_isalpha( int c );
01704 
01705 // portable case insensitive compare
01706 int             Q_stricmp (const char *s1, const char *s2);
01707 int             Q_strncmp (const char *s1, const char *s2, int n);
01708 int             Q_stricmpn (const char *s1, const char *s2, int n);
01709 char    *Q_strlwr( char *s1 );
01710 char    *Q_strupr( char *s1 );
01711 char    *Q_strrchr( const char* string, int c );
01712 
01713 // buffer size safe library replacements
01714 void    Q_strncpyz( char *dest, const char *src, int destsize );
01715 void    Q_strcat( char *dest, int size, const char *src );
01716 
01717 // strlen that discounts Quake color sequences
01718 int Q_PrintStrlen( const char *string );
01719 // removes color sequences from string
01720 char *Q_CleanStr( char *string );
01721 
01722 //=============================================
01723 
01724 // 64-bit integers for global rankings interface
01725 // implemented as a struct for qvm compatibility
01726 typedef struct
01727 {
01728         byte    b0;
01729         byte    b1;
01730         byte    b2;
01731         byte    b3;
01732         byte    b4;
01733         byte    b5;
01734         byte    b6;
01735         byte    b7;
01736 } qint64;
01737 
01738 //=============================================
01739 /*
01740 short   BigShort(short l);
01741 short   LittleShort(short l);
01742 int             BigLong (int l);
01743 int             LittleLong (int l);
01744 qint64  BigLong64 (qint64 l);
01745 qint64  LittleLong64 (qint64 l);
01746 float   BigFloat (const float *l);
01747 float   LittleFloat (const float *l);
01748 
01749 void    Swap_Init (void);
01750 */
01751 char    * QDECL va(const char *format, ...);
01752 
01753 //=============================================
01754 
01755 //
01756 // key / value info strings
01757 //
01758 char *Info_ValueForKey( const char *s, const char *key );
01759 void Info_RemoveKey( char *s, const char *key );
01760 void Info_RemoveKey_big( char *s, const char *key );
01761 void Info_SetValueForKey( char *s, const char *key, const char *value );
01762 void Info_SetValueForKey_Big( char *s, const char *key, const char *value );
01763 qboolean Info_Validate( const char *s );
01764 void Info_NextPair( const char **s, char *key, char *value );
01765 
01766 // this is only here so the functions in q_shared.c and bg_*.c can link
01767 void    QDECL Com_Error( int level, const char *error, ... );
01768 void    QDECL Com_Printf( const char *msg, ... );
01769 
01770 
01771 /*
01772 ==========================================================
01773 
01774 CVARS (console variables)
01775 
01776 Many variables can be used for cheating purposes, so when
01777 cheats is zero, force all unspecified variables to their
01778 default values.
01779 ==========================================================
01780 */
01781 
01782 #define CVAR_ARCHIVE            0x00000001              // set to cause it to be saved to vars.rc
01783                                                                                         // used for system variables, not for player
01784                                                                                         // specific configurations
01785 #define CVAR_USERINFO           0x00000002              // sent to server on connect or change
01786 #define CVAR_SERVERINFO         0x00000004              // sent in response to front end requests
01787 #define CVAR_SYSTEMINFO         0x00000008              // these cvars will be duplicated on all clients
01788 #define CVAR_INIT                       0x00000010              // don't allow change from console at all,
01789                                                                                         // but can be set from the command line
01790 #define CVAR_LATCH                      0x00000020              // will only change when C code next does
01791                                                                                         // a Cvar_Get(), so it can't be changed
01792                                                                                         // without proper initialization.  modified
01793                                                                                         // will be set, even though the value hasn't
01794                                                                                         // changed yet
01795 #define CVAR_ROM                        0x00000040              // display only, cannot be set by user at all (can be set by code)
01796 #define CVAR_USER_CREATED       0x00000080              // created by a set command
01797 #define CVAR_TEMP                       0x00000100              // can be set even when cheats are disabled, but is not archived
01798 #define CVAR_CHEAT                      0x00000200              // can not be changed if cheats are disabled
01799 #define CVAR_NORESTART          0x00000400              // do not clear when a cvar_restart is issued
01800 #define CVAR_INTERNAL           0x00000800              // cvar won't be displayed, ever (for passwords and such)
01801 #define CVAR_PARENTAL           0x00001000              // lets cvar system know that parental stuff needs to be updated
01802 
01803 // nothing outside the Cvar_*() functions should modify these fields!
01804 typedef struct cvar_s {
01805         char            *name;
01806         char            *string;
01807         char            *resetString;           // cvar_restart will reset to this value
01808         char            *latchedString;         // for CVAR_LATCH vars
01809         int                     flags;
01810         qboolean        modified;                       // set each time the cvar is changed
01811         int                     modificationCount;      // incremented each time the cvar is changed
01812         float           value;                          // atof( string )
01813         int                     integer;                        // atoi( string )
01814         struct cvar_s *next;
01815         struct cvar_s *hashNext;
01816 } cvar_t;
01817 
01818 #define MAX_CVAR_VALUE_STRING   256
01819 
01820 typedef int     cvarHandle_t;
01821 
01822 // the modules that run in the virtual machine can't access the cvar_t directly,
01823 // so they must ask for structured updates
01824 typedef struct {
01825         cvarHandle_t    handle;
01826         int                     modificationCount;
01827         float           value;
01828         int                     integer;
01829         char            string[MAX_CVAR_VALUE_STRING];
01830 } vmCvar_t;
01831 
01832 /*
01833 ==============================================================
01834 
01835 COLLISION DETECTION
01836 
01837 ==============================================================
01838 */
01839 
01840 #include "surfaceflags.h"                       // shared with the q3map utility
01841 
01842 // plane types are used to speed some tests
01843 // 0-2 are axial planes
01844 #define PLANE_X                 0
01845 #define PLANE_Y                 1
01846 #define PLANE_Z                 2
01847 #define PLANE_NON_AXIAL 3
01848 
01849 
01850 /*
01851 =================
01852 PlaneTypeForNormal
01853 =================
01854 */
01855 
01856 #define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) )
01857 
01858 // plane_t structure
01859 // !!! if this is changed, it must be changed in asm code too !!!
01860 typedef struct cplane_s {
01861         vec3_t  normal;
01862         float   dist;
01863         byte    type;                   // for fast side tests: 0,1,2 = axial, 3 = nonaxial
01864         byte    signbits;               // signx + (signy<<1) + (signz<<2), used as lookup during collision
01865         byte    pad[2];
01866 } cplane_t;
01867 /*
01868 Ghoul2 Insert Start
01869 */
01870 typedef struct
01871 {
01872         float           mDistance;
01873         int                     mEntityNum;
01874         int                     mModelIndex;
01875         int                     mPolyIndex;
01876         int                     mSurfaceIndex;
01877         vec3_t          mCollisionPosition;
01878         vec3_t          mCollisionNormal;
01879         int                     mFlags;
01880         int                     mMaterial;
01881         int                     mLocation;
01882         float           mBarycentricI; // two barycentic coodinates for the hit point
01883         float           mBarycentricJ; // K = 1-I-J
01884 }CollisionRecord_t;
01885 
01886 #define MAX_G2_COLLISIONS 16
01887 
01888 typedef CollisionRecord_t G2Trace_t[MAX_G2_COLLISIONS]; // map that describes all of the parts of ghoul2 models that got hit
01889 
01890 /*
01891 Ghoul2 Insert End
01892 */
01893 // a trace is returned when a box is swept through the world
01894 typedef struct {
01895         byte            allsolid;       // if true, plane is not valid
01896         byte            startsolid;     // if true, the initial point was in a solid area
01897         short           entityNum;      // entity the contacted sirface is a part of
01898 
01899         float           fraction;       // time completed, 1.0 = didn't hit anything
01900         vec3_t          endpos;         // final position
01901         cplane_t        plane;          // surface normal at impact, transformed to world space
01902         int                     surfaceFlags;   // surface hit
01903         int                     contents;       // contents on other side of surface hit
01904 /*
01905 Ghoul2 Insert Start
01906 */
01907         //rww - removed this for now, it's just wasting space in the trace structure.
01908 //      CollisionRecord_t G2CollisionMap[MAX_G2_COLLISIONS];    // map that describes all of the parts of ghoul2 models that got hit
01909 /*
01910 Ghoul2 Insert End
01911 */
01912 } trace_t;
01913 
01914 // trace->entityNum can also be 0 to (MAX_GENTITIES-1)
01915 // or ENTITYNUM_NONE, ENTITYNUM_WORLD
01916 
01917 
01918 // markfragments are returned by CM_MarkFragments()
01919 typedef struct {
01920         int             firstPoint;
01921         int             numPoints;
01922 } markFragment_t;
01923 
01924 
01925 
01926 typedef struct {
01927         vec3_t          origin;
01928         vec3_t          axis[3];
01929 } orientation_t;
01930 
01931 //=====================================================================
01932 
01933 
01934 // in order from highest priority to lowest
01935 // if none of the catchers are active, bound key strings will be executed
01936 #define KEYCATCH_CONSOLE                0x0001
01937 #define KEYCATCH_UI                                     0x0002
01938 #define KEYCATCH_MESSAGE                0x0004
01939 #define KEYCATCH_CGAME                  0x0008
01940 
01941 
01942 // sound channels
01943 // channel 0 never willingly overrides
01944 // other channels will allways override a playing sound on that channel
01945 typedef enum {
01946         CHAN_AUTO,      //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # Auto-picks an empty channel to play sound on
01947         CHAN_LOCAL,     //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # menu sounds, etc
01948         CHAN_WEAPON,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" 
01949         CHAN_VOICE, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Voice sounds cause mouth animation
01950         CHAN_VOICE_ATTEN, //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation but still use normal sound falloff 
01951         CHAN_ITEM,  //## %s !!"W:\game\base\!!sound\*.wav;*.mp3"
01952         CHAN_BODY,      //## %s !!"W:\game\base\!!sound\*.wav;*.mp3"
01953         CHAN_AMBIENT,//## %s !!"W:\game\base\!!sound\*.wav;*.mp3" # added for ambient sounds
01954         CHAN_LOCAL_SOUND,       //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #chat messages, etc
01955         CHAN_ANNOUNCER,         //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #announcer voices, etc
01956         CHAN_LESS_ATTEN,        //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #attenuates similar to chan_voice, but uses empty channel auto-pick behaviour
01957         CHAN_MENU1,             //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #menu stuff, etc
01958         CHAN_VOICE_GLOBAL,  //## %s !!"W:\game\base\!!sound\voice\*.wav;*.mp3" # Causes mouth animation and is broadcast, like announcer
01959         CHAN_MUSIC,     //## %s !!"W:\game\base\!!sound\*.wav;*.mp3" #music played as a looping sound - added by BTO (VV)
01960 };
01961 typedef int soundChannel_t;
01962 
01963 
01964 /*
01965 ========================================================================
01966 
01967   ELEMENTS COMMUNICATED ACROSS THE NET
01968 
01969 ========================================================================
01970 */
01971 
01972 #define ANGLE2SHORT(x)  ((int)((x)*65536/360) & 65535)
01973 #define SHORT2ANGLE(x)  ((x)*(360.0/65536))
01974 
01975 #define SNAPFLAG_RATE_DELAYED   1
01976 #define SNAPFLAG_NOT_ACTIVE             2       // snapshot used during connection and for zombies
01977 #define SNAPFLAG_SERVERCOUNT    4       // toggled every map_restart so transitions can be detected
01978 
01979 //
01980 // per-level limits
01981 //
01982 #ifdef _XBOX
01983 #define MAX_CLIENTS                     16
01984 #else
01985 #define MAX_CLIENTS                     32              // absolute limit
01986 #endif
01987 #define MAX_RADAR_ENTITIES      MAX_GENTITIES
01988 #define MAX_TERRAINS            1//32 //rwwRMG: inserted
01989 #define MAX_LOCATIONS           64
01990 
01991 #ifdef _XBOX
01992 #define GENTITYNUM_BITS 9               // don't need to send any more
01993 #else
01994 #define GENTITYNUM_BITS 10              // don't need to send any more
01995 #endif
01996 #define MAX_GENTITIES   (1<<GENTITYNUM_BITS)
01997 
01998 //I am reverting. I guess. For now.
01999 /*
02000 #define GENTITYNUM_BITS         11
02001                                                         //rww - I am raising this 1 bit. SP actually has room for 1024 ents - none - world - 1 client.
02002                                                         //Which means 1021 useable entities. However we have 32 clients.. so if we keep our limit
02003                                                         //at 1024 we are not going to be able to load any SP levels at the edge of the ent limit.
02004 #define         MAX_GENTITIES   (1024+(MAX_CLIENTS-1))
02005                                                         //rww - we do have enough room to send over 2048 ents now. However, I cannot live with the guilt of
02006                                                         //actually increasing the entity limit to 2048 (as it would slow down countless things, and
02007                                                         //there are tons of ent list traversals all over the place). So I am merely going to give enough
02008                                                         //to compensate for our larger maxclients.
02009 */
02010 
02011 // entitynums are communicated with GENTITY_BITS, so any reserved
02012 // values thatare going to be communcated over the net need to
02013 // also be in this range
02014 #define ENTITYNUM_NONE          (MAX_GENTITIES-1)
02015 #define ENTITYNUM_WORLD         (MAX_GENTITIES-2)
02016 #define ENTITYNUM_MAX_NORMAL    (MAX_GENTITIES-2)
02017 
02018 
02019 // these are also in be_aas_def.h - argh (rjr)
02020 #define MAX_MODELS                      512             // these are sent over the net as -12 bits
02021 #define MAX_SOUNDS                      256             // so they cannot be blindly increased
02022 #define MAX_ICONS                       64              // max registered icons you can have per map 
02023 #define MAX_FX                          64              // max effects strings, I'm hoping that 64 will be plenty
02024 
02025 #define MAX_SUB_BSP                     32 //rwwRMG - added
02026 
02027 /*
02028 Ghoul2 Insert Start
02029 */
02030 #define MAX_G2BONES             64              //rww - changed from MAX_CHARSKINS to MAX_G2BONES. value still equal.
02031 /*
02032 Ghoul2 Insert End
02033 */
02034 
02035 #define MAX_AMBIENT_SETS                256 //rww - ambient soundsets must be sent over in config strings.
02036 
02037 #define MAX_CONFIGSTRINGS       1700 //this is getting pretty high. Try not to raise it anymore than it already is.
02038 
02039 // these are the only configstrings that the system reserves, all the
02040 // other ones are strictly for servergame to clientgame communication
02041 #define CS_SERVERINFO           0               // an info string with all the serverinfo cvars
02042 #define CS_SYSTEMINFO           1               // an info string for server system to client system configuration (timescale, etc)
02043 
02044 #define RESERVED_CONFIGSTRINGS  2       // game can't modify below this, only the system can
02045 
02046 #define MAX_GAMESTATE_CHARS     16000
02047 typedef struct {
02048         int                     stringOffsets[MAX_CONFIGSTRINGS];
02049         char            stringData[MAX_GAMESTATE_CHARS];
02050         int                     dataCount;
02051 } gameState_t;
02052 
02053 //=========================================================
02054 
02055 // all the different tracking "channels"
02056 typedef enum {
02057         TRACK_CHANNEL_NONE = 50,
02058         TRACK_CHANNEL_1,
02059         TRACK_CHANNEL_2,
02060         TRACK_CHANNEL_3,
02061         TRACK_CHANNEL_4,
02062         TRACK_CHANNEL_5,
02063         NUM_TRACK_CHANNELS
02064 } trackchan_t;
02065 
02066 #define TRACK_CHANNEL_MAX (NUM_TRACK_CHANNELS-50)
02067 
02068 typedef struct forcedata_s {
02069         int                     forcePowerDebounce[NUM_FORCE_POWERS];   //for effects that must have an interval
02070         int                     forcePowersKnown;
02071         int                     forcePowersActive;
02072         int                     forcePowerSelected;
02073         int                     forceButtonNeedRelease;
02074         int                     forcePowerDuration[NUM_FORCE_POWERS];
02075         int                     forcePower;
02076         int                     forcePowerMax;
02077         int                     forcePowerRegenDebounceTime;
02078         int                     forcePowerLevel[NUM_FORCE_POWERS];              //so we know the max forceJump power you have
02079         int                     forcePowerBaseLevel[NUM_FORCE_POWERS];
02080         int                     forceUsingAdded;
02081         float           forceJumpZStart;                                        //So when you land, you don't get hurt as much
02082         float           forceJumpCharge;                                        //you're current forceJump charge-up level, increases the longer you hold the force jump button down
02083         int                     forceJumpSound;
02084         int                     forceJumpAddTime;
02085         int                     forceGripEntityNum;                                     //what entity I'm gripping
02086         int                     forceGripDamageDebounceTime;            //debounce for grip damage
02087         float           forceGripBeingGripped;                          //if > level.time then client is in someone's grip
02088         int                     forceGripCripple;                                       //if != 0 then make it so this client can't move quickly (he's being gripped)
02089         int                     forceGripUseTime;                                       //can't use if > level.time
02090         float           forceGripSoundTime;
02091         float           forceGripStarted;                                       //level.time when the grip was activated
02092         int                     forceHealTime;
02093         int                     forceHealAmount;
02094 
02095         //This hurts me somewhat to do, but there's no other real way to allow completely "dynamic" mindtricking.
02096         int                     forceMindtrickTargetIndex; //0-15
02097         int                     forceMindtrickTargetIndex2; //16-32
02098         int                     forceMindtrickTargetIndex3; //33-48
02099         int                     forceMindtrickTargetIndex4; //49-64
02100 
02101         int                     forceRageRecoveryTime;
02102         int                     forceDrainEntNum;
02103         float           forceDrainTime;
02104 
02105         int                     forceDoInit;
02106 
02107         int                     forceSide;
02108         int                     forceRank;
02109 
02110         int                     forceDeactivateAll;
02111 
02112         int                     killSoundEntIndex[TRACK_CHANNEL_MAX]; //this goes here so it doesn't get wiped over respawn
02113 
02114         qboolean        sentryDeployed;
02115 
02116         int                     saberAnimLevelBase;//sigh...
02117         int                     saberAnimLevel;
02118         int                     saberDrawAnimLevel;
02119 
02120         int                     suicides;
02121 
02122         int                     privateDuelTime;
02123 } forcedata_t;
02124 
02125 
02126 typedef enum {
02127         SENTRY_NOROOM = 1,
02128         SENTRY_ALREADYPLACED,
02129         SHIELD_NOROOM,
02130         SEEKER_ALREADYDEPLOYED
02131 } itemUseFail_t;
02132 
02133 // bit field limits
02134 #define MAX_STATS                               16
02135 #define MAX_PERSISTANT                  16
02136 #define MAX_POWERUPS                    16
02137 #define MAX_WEAPONS                             19              
02138 
02139 #define MAX_PS_EVENTS                   2
02140 
02141 #define PS_PMOVEFRAMECOUNTBITS  6
02142 
02143 #define FORCE_LIGHTSIDE                 1
02144 #define FORCE_DARKSIDE                  2
02145 
02146 #define MAX_FORCE_RANK                  7
02147 
02148 #define FALL_FADE_TIME                  3000
02149 
02150 //#define _ONEBIT_COMBO
02151 //Crazy optimization attempt to take all those 1 bit values and shove them into a single
02152 //send. May help us not have to send so many 1/0 bits to acknowledge modified values. -rww
02153 
02154 #define _OPTIMIZED_VEHICLE_NETWORKING
02155 //Instead of sending 2 full playerStates for the pilot and the vehicle, send a smaller,
02156 //specialized pilot playerState and vehicle playerState.  Also removes some vehicle
02157 //fields from the normal playerState -mcg
02158 
02159 // playerState_t is the information needed by both the client and server
02160 // to predict player motion and actions
02161 // nothing outside of pmove should modify these, or some degree of prediction error
02162 // will occur
02163 
02164 // you can't add anything to this without modifying the code in msg.c
02165 
02166 // playerState_t is a full superset of entityState_t as it is used by players,
02167 // so if a playerState_t is transmitted, the entityState_t can be fully derived
02168 // from it.
02169 typedef struct playerState_s {
02170         int                     commandTime;    // cmd->serverTime of last executed command
02171         int                     pm_type;
02172         int                     bobCycle;               // for view bobbing and footstep generation
02173         int                     pm_flags;               // ducked, jump_held, etc
02174         int                     pm_time;
02175 
02176         vec3_t          origin;
02177         vec3_t          velocity;
02178 
02179         vec3_t          moveDir; //NOT sent over the net - nor should it be.
02180 
02181         int                     weaponTime;
02182         int                     weaponChargeTime;
02183         int                     weaponChargeSubtractTime;
02184         int                     gravity;
02185         float           speed;
02186         int                     basespeed; //used in prediction to know base server g_speed value when modifying speed between updates
02187         int                     delta_angles[3];        // add to command angles to get view direction
02188                                                                         // changed by spawns, rotating objects, and teleporters
02189 
02190         int                     slopeRecalcTime; //this is NOT sent across the net and is maintained seperately on game and cgame in pmove code.
02191 
02192         int                     useTime;
02193 
02194         int                     groundEntityNum;// ENTITYNUM_NONE = in air
02195 
02196         int                     legsTimer;              // don't change low priority animations until this runs out
02197         int                     legsAnim;
02198 
02199         int                     torsoTimer;             // don't change low priority animations until this runs out
02200         int                     torsoAnim;
02201 
02202         qboolean        legsFlip; //set to opposite when the same anim needs restarting, sent over in only 1 bit. Cleaner and makes porting easier than having that god forsaken ANIM_TOGGLEBIT.
02203         qboolean        torsoFlip;
02204 
02205         int                     movementDir;    // a number 0 to 7 that represents the reletive angle
02206                                                                 // of movement to the view angle (axial and diagonals)
02207                                                                 // when at rest, the value will remain unchanged
02208                                                                 // used to twist the legs during strafing
02209 
02210         int                     eFlags;                 // copied to entityState_t->eFlags
02211         int                     eFlags2;                // copied to entityState_t->eFlags2, EF2_??? used much less frequently
02212 
02213         int                     eventSequence;  // pmove generated events
02214         int                     events[MAX_PS_EVENTS];
02215         int                     eventParms[MAX_PS_EVENTS];
02216 
02217         int                     externalEvent;  // events set on player from another source
02218         int                     externalEventParm;
02219         int                     externalEventTime;
02220 
02221         int                     clientNum;              // ranges from 0 to MAX_CLIENTS-1
02222         int                     weapon;                 // copied to entityState_t->weapon
02223         int                     weaponstate;
02224 
02225         vec3_t          viewangles;             // for fixed views
02226         int                     viewheight;
02227 
02228         // damage feedback
02229         int                     damageEvent;    // when it changes, latch the other parms
02230         int                     damageYaw;
02231         int                     damagePitch;
02232         int                     damageCount;
02233         int                     damageType;
02234 
02235         int                     painTime;               // used for both game and client side to process the pain twitch - NOT sent across the network
02236         int                     painDirection;  // NOT sent across the network
02237         float           yawAngle;               // NOT sent across the network
02238         qboolean        yawing;                 // NOT sent across the network
02239         float           pitchAngle;             // NOT sent across the network
02240         qboolean        pitching;               // NOT sent across the network
02241 
02242         int                     stats[MAX_STATS];
02243         int                     persistant[MAX_PERSISTANT];     // stats that aren't cleared on death
02244         int                     powerups[MAX_POWERUPS]; // level.time that the powerup runs out
02245         int                     ammo[MAX_WEAPONS];
02246 
02247         int                     generic1;
02248         int                     loopSound;
02249         int                     jumppad_ent;    // jumppad entity hit this frame
02250 
02251         // not communicated over the net at all
02252         int                     ping;                   // server to game info for scoreboard
02253         int                     pmove_framecount;       // FIXME: don't transmit over the network
02254         int                     jumppad_frame;
02255         int                     entityEventSequence;
02256 
02257         int                     lastOnGround;   //last time you were on the ground
02258 
02259         qboolean        saberInFlight;
02260 
02261         int                     saberMove;
02262         int                     saberBlocking;
02263         int                     saberBlocked;
02264 
02265         int                     saberLockTime;
02266         int                     saberLockEnemy;
02267         int                     saberLockFrame; //since we don't actually have the ability to get the current anim frame
02268         int                     saberLockHits; //every x number of buttons hits, allow one push forward in a saber lock (server only)
02269         int                     saberLockHitCheckTime; //so we don't allow more than 1 push per server frame
02270         int                     saberLockHitIncrementTime; //so we don't add a hit per attack button press more than once per server frame
02271         qboolean        saberLockAdvance; //do an advance (sent across net as 1 bit)
02272 
02273         int                     saberEntityNum;
02274         float           saberEntityDist;
02275         int                     saberEntityState;
02276         int                     saberThrowDelay;
02277         qboolean        saberCanThrow;
02278         int                     saberDidThrowTime;
02279         int                     saberDamageDebounceTime;
02280         int                     saberHitWallSoundDebounceTime;
02281         int                     saberEventFlags;
02282 
02283         int                     rocketLockIndex;
02284         float           rocketLastValidTime;
02285         float           rocketLockTime;
02286         float           rocketTargetTime;
02287 
02288         int                     emplacedIndex;
02289         float           emplacedTime;
02290 
02291         qboolean        isJediMaster;
02292         qboolean        forceRestricted;
02293         qboolean        trueJedi;
02294         qboolean        trueNonJedi;
02295         int                     saberIndex;
02296 
02297         int                     genericEnemyIndex;
02298         float           droneFireTime;
02299         float           droneExistTime;
02300 
02301         int                     activeForcePass;
02302 
02303         qboolean        hasDetPackPlanted; //better than taking up an eFlag isn't it?
02304 
02305         float           holocronsCarried[NUM_FORCE_POWERS];
02306         int                     holocronCantTouch;
02307         float           holocronCantTouchTime; //for keeping track of the last holocron that just popped out of me (if any)
02308         int                     holocronBits;
02309 
02310         int                     electrifyTime;
02311 
02312         int                     saberAttackSequence;
02313         int                     saberIdleWound;
02314         int                     saberAttackWound;
02315         int                     saberBlockTime;
02316 
02317         int                     otherKiller;
02318         int                     otherKillerTime;
02319         int                     otherKillerDebounceTime;
02320 
02321         forcedata_t     fd;
02322         qboolean        forceJumpFlip;
02323         int                     forceHandExtend;
02324         int                     forceHandExtendTime;
02325 
02326         int                     forceRageDrainTime;
02327 
02328         int                     forceDodgeAnim;
02329         qboolean        quickerGetup;
02330 
02331         int                     groundTime;             // time when first left ground
02332 
02333         int                     footstepTime;
02334 
02335         int                     otherSoundTime;
02336         float           otherSoundLen;
02337 
02338         int                     forceGripMoveInterval;
02339         int                     forceGripChangeMovetype;
02340 
02341         int                     forceKickFlip;
02342 
02343         int                     duelIndex;
02344         int                     duelTime;
02345         qboolean        duelInProgress;
02346 
02347         int                     saberAttackChainCount;
02348 
02349         int                     saberHolstered;
02350 
02351         int                     forceAllowDeactivateTime;
02352 
02353         // zoom key
02354         int                     zoomMode;               // 0 - not zoomed, 1 - disruptor weapon
02355         int                     zoomTime;
02356         qboolean        zoomLocked;
02357         float           zoomFov;
02358         int                     zoomLockTime;
02359 
02360         int                     fallingToDeath;
02361 
02362         int                     useDelay;
02363 
02364         qboolean        inAirAnim;
02365 
02366         vec3_t          lastHitLoc;
02367 
02368         int                     heldByClient; //can only be a client index - this client should be holding onto my arm using IK stuff.
02369 
02370         int                     ragAttach; //attach to ent while ragging
02371 
02372         int                     iModelScale;
02373 
02374         int                     brokenLimbs;
02375 
02376         //for looking at an entity's origin (NPCs and players)
02377         qboolean        hasLookTarget;
02378         int                     lookTarget;
02379 
02380         int                     customRGBA[4];
02381 
02382         int                     standheight;
02383         int                     crouchheight;
02384 
02385         //If non-0, this is the index of the vehicle a player/NPC is riding.
02386         int                     m_iVehicleNum;
02387 
02388         //lovely hack for keeping vehicle orientation in sync with prediction
02389         vec3_t          vehOrientation;
02390         qboolean        vehBoarding;
02391         int                     vehSurfaces;
02392 
02393         //vehicle turnaround stuff (need this in ps so it doesn't jerk too much in prediction)
02394         int                     vehTurnaroundIndex;
02395         int                     vehTurnaroundTime;
02396 
02397         //vehicle has weapons linked
02398         qboolean        vehWeaponsLinked;
02399 
02400         //when hyperspacing, you just go forward really fast for HYPERSPACE_TIME
02401         int                     hyperSpaceTime;
02402         vec3_t          hyperSpaceAngles;
02403 
02404         //hacking when > time
02405         int                     hackingTime;
02406         //actual hack amount - only for the proper percentage display when
02407         //drawing progress bar (is there a less bandwidth-eating way to do
02408         //this without a lot of hassle?)
02409         int                     hackingBaseTime;
02410 
02411         //keeps track of jetpack fuel
02412         int                     jetpackFuel;
02413 
02414         //keeps track of cloak fuel
02415         int                     cloakFuel;
02416 
02417         //rww - spare values specifically for use by mod authors.
02418         //See psf_overrides.txt if you want to increase the send
02419         //amount of any of these above 1 bit.
02420 #ifndef _XBOX
02421         int                     userInt1;
02422         int                     userInt2;
02423         int                     userInt3;
02424         float           userFloat1;
02425         float           userFloat2;
02426         float           userFloat3;
02427         vec3_t          userVec1;
02428         vec3_t          userVec2;
02429 #endif
02430 
02431 #ifdef _ONEBIT_COMBO
02432         int                     deltaOneBits;
02433         int                     deltaNumBits;
02434 #endif
02435 } playerState_t;
02436 
02437 typedef struct siegePers_s
02438 {
02439         qboolean        beatingTime;
02440         int                     lastTeam;
02441         int                     lastTime;
02442 } siegePers_t;
02443 
02444 //====================================================================
02445 
02446 
02447 //
02448 // usercmd_t->button bits, many of which are generated by the client system,
02449 // so they aren't game/cgame only definitions
02450 //
02451 #define BUTTON_ATTACK                   1
02452 #define BUTTON_TALK                             2                       // displays talk balloon and disables actions
02453 #define BUTTON_USE_HOLDABLE             4
02454 #define BUTTON_GESTURE                  8
02455 #define BUTTON_WALKING                  16                      // walking can't just be infered from MOVE_RUN
02456                                                                                 // because a key pressed late in the frame will
02457                                                                                 // only generate a small move value for that frame
02458                                                                                 // walking will use different animations and
02459                                                                                 // won't generate footsteps
02460 #define BUTTON_USE                              32                      // the ol' use key returns!
02461 #define BUTTON_FORCEGRIP                64                      // 
02462 #define BUTTON_ALT_ATTACK               128
02463 
02464 #define BUTTON_ANY                              256                     // any key whatsoever
02465 
02466 #define BUTTON_FORCEPOWER               512                     // use the "active" force power
02467 
02468 #define BUTTON_FORCE_LIGHTNING  1024
02469 
02470 #define BUTTON_FORCE_DRAIN              2048
02471 
02472 // Here's an interesting bit.  The bots in TA used buttons to do additional gestures.
02473 // I ripped them out because I didn't want too many buttons given the fact that I was already adding some for JK2.
02474 // We can always add some back in if we want though.
02475 /*
02476 #define BUTTON_AFFIRMATIVE      32
02477 #define BUTTON_NEGATIVE         64
02478 
02479 #define BUTTON_GETFLAG          128
02480 #define BUTTON_GUARDBASE        256
02481 #define BUTTON_PATROL           512
02482 #define BUTTON_FOLLOWME         1024
02483 */
02484 
02485 #define MOVE_RUN                        120                     // if forwardmove or rightmove are >= MOVE_RUN,
02486                                                                                 // then BUTTON_WALKING should be set
02487 
02488 typedef enum
02489 {
02490         GENCMD_SABERSWITCH = 1,
02491         GENCMD_ENGAGE_DUEL,
02492         GENCMD_FORCE_HEAL,
02493         GENCMD_FORCE_SPEED,
02494         GENCMD_FORCE_THROW,
02495         GENCMD_FORCE_PULL,
02496         GENCMD_FORCE_DISTRACT,
02497         GENCMD_FORCE_RAGE,
02498         GENCMD_FORCE_PROTECT,
02499         GENCMD_FORCE_ABSORB,
02500         GENCMD_FORCE_HEALOTHER,
02501         GENCMD_FORCE_FORCEPOWEROTHER,
02502         GENCMD_FORCE_SEEING,
02503         GENCMD_USE_SEEKER,
02504         GENCMD_USE_FIELD,
02505         GENCMD_USE_BACTA,
02506         GENCMD_USE_ELECTROBINOCULARS,
02507         GENCMD_ZOOM,
02508         GENCMD_USE_SENTRY,
02509         GENCMD_USE_JETPACK,
02510         GENCMD_USE_BACTABIG,
02511         GENCMD_USE_HEALTHDISP,
02512         GENCMD_USE_AMMODISP,
02513         GENCMD_USE_EWEB,
02514         GENCMD_USE_CLOAK,
02515         GENCMD_SABERATTACKCYCLE,
02516         GENCMD_TAUNT,
02517         GENCMD_BOW,
02518         GENCMD_MEDITATE,
02519         GENCMD_FLOURISH,
02520         GENCMD_GLOAT
02521 } genCmds_t;
02522 
02523 // usercmd_t is sent to the server each client frame
02524 typedef struct usercmd_s {
02525         int                             serverTime;
02526         int                             angles[3];
02527         int                     buttons;
02528         byte                    weapon;           // weapon 
02529         byte                    forcesel;
02530         byte                    invensel;
02531         byte                    generic_cmd;
02532         signed char     forwardmove, rightmove, upmove;
02533 } usercmd_t;
02534 
02535 //===================================================================
02536 
02537 //rww - unsightly hack to allow us to make an FX call that takes a horrible amount of args
02538 typedef struct addpolyArgStruct_s {
02539         vec3_t                          p[4];
02540         vec2_t                          ev[4];
02541         int                                     numVerts;
02542         vec3_t                          vel;
02543         vec3_t                          accel;
02544         float                           alpha1;
02545         float                           alpha2;
02546         float                           alphaParm;
02547         vec3_t                          rgb1;
02548         vec3_t                          rgb2;
02549         float                           rgbParm;
02550         vec3_t                          rotationDelta;
02551         float                           bounce;
02552         int                                     motionDelay;
02553         int                                     killTime;
02554         qhandle_t                       shader;
02555         int                                     flags;
02556 } addpolyArgStruct_t;
02557 
02558 typedef struct addbezierArgStruct_s {
02559         vec3_t start;
02560         vec3_t end;
02561         vec3_t control1;
02562         vec3_t control1Vel;
02563         vec3_t control2;
02564         vec3_t control2Vel;
02565         float size1;
02566         float size2;
02567         float sizeParm;
02568         float alpha1;
02569         float alpha2;
02570         float alphaParm;
02571         vec3_t sRGB;
02572         vec3_t eRGB;
02573         float rgbParm;
02574         int killTime;
02575         qhandle_t shader;
02576         int flags;
02577 } addbezierArgStruct_t;
02578 
02579 typedef struct addspriteArgStruct_s
02580 {
02581         vec3_t origin;
02582         vec3_t vel;
02583         vec3_t accel;
02584         float scale;
02585         float dscale;
02586         float sAlpha;
02587         float eAlpha;
02588         float rotation;
02589         float bounce;
02590         int life;
02591         qhandle_t shader;
02592         int flags;
02593 } addspriteArgStruct_t;
02594 
02595 typedef struct
02596 {
02597         vec3_t  origin;
02598 
02599         // very specifc case, we can modulate the color and the alpha
02600         vec3_t  rgb;
02601         vec3_t  destrgb;
02602         vec3_t  curRGB;
02603 
02604         float   alpha;
02605         float   destAlpha;
02606         float   curAlpha;
02607 
02608         // this is a very specific case thing...allow interpolating the st coords so we can map the texture
02609         //      properly as this segement progresses through it's life
02610         float   ST[2];
02611         float   destST[2];
02612         float   curST[2];
02613 } effectTrailVertStruct_t;
02614 
02615 typedef struct effectTrailArgStruct_s {
02616         effectTrailVertStruct_t         mVerts[4];
02617         qhandle_t                                       mShader;
02618         int                                                     mSetFlags;
02619         int                                                     mKillTime;
02620 } effectTrailArgStruct_t;
02621 
02622 typedef struct
02623 {
02624         vec3_t start;
02625         vec3_t end;
02626         float size1;
02627         float size2;
02628         float sizeParm;
02629         float alpha1;
02630         float alpha2;
02631         float alphaParm;
02632         vec3_t sRGB;
02633         vec3_t eRGB;
02634         float rgbParm;
02635         float chaos;
02636         int killTime;
02637         qhandle_t shader;
02638         int flags;
02639 } addElectricityArgStruct_t;
02640 
02641 // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number
02642 #define SOLID_BMODEL    0xffffff
02643 
02644 typedef enum {
02645         TR_STATIONARY,
02646         TR_INTERPOLATE,                         // non-parametric, but interpolate between snapshots
02647         TR_LINEAR,
02648         TR_LINEAR_STOP,
02649         TR_NONLINEAR_STOP,
02650         TR_SINE,                                        // value = base + sin( time / duration ) * delta
02651         TR_GRAVITY
02652 } trType_t;
02653 
02654 typedef struct {
02655         trType_t        trType;
02656         int             trTime;
02657         int             trDuration;                     // if non 0, trTime + trDuration = stop time
02658         vec3_t  trBase;
02659         vec3_t  trDelta;                        // velocity, etc
02660 } trajectory_t;
02661 
02662 // entityState_t is the information conveyed from the server
02663 // in an update message about entities that the client will
02664 // need to render in some way
02665 // Different eTypes may use the information in different ways
02666 // The messages are delta compressed, so it doesn't really matter if
02667 // the structure size is fairly large
02668 #ifndef _XBOX   // First, real version for the PC, with all members 32-bits
02669 
02670 typedef struct entityState_s {
02671         int             number;                 // entity index
02672         int             eType;                  // entityType_t
02673         int             eFlags;
02674         int             eFlags2;                // EF2_??? used much less frequently
02675 
02676         trajectory_t    pos;    // for calculating position
02677         trajectory_t    apos;   // for calculating angles
02678 
02679         int             time;
02680         int             time2;
02681 
02682         vec3_t  origin;
02683         vec3_t  origin2;
02684 
02685         vec3_t  angles;
02686         vec3_t  angles2;
02687 
02688         //rww - these were originally because we shared g2 info client and server side. Now they
02689         //just get used as generic values everywhere.
02690         int             bolt1;
02691         int             bolt2;
02692 
02693         //rww - this is necessary for determining player visibility during a jedi mindtrick
02694         int             trickedentindex; //0-15
02695         int             trickedentindex2; //16-32
02696         int             trickedentindex3; //33-48
02697         int             trickedentindex4; //49-64
02698 
02699         float   speed;
02700 
02701         int             fireflag;
02702 
02703         int             genericenemyindex;
02704 
02705         int             activeForcePass;
02706 
02707         int             emplacedOwner;
02708 
02709         int             otherEntityNum; // shotgun sources, etc
02710         int             otherEntityNum2;
02711 
02712         int             groundEntityNum;        // -1 = in air
02713 
02714         int             constantLight;  // r + (g<<8) + (b<<16) + (intensity<<24)
02715         int             loopSound;              // constantly loop this sound
02716         qboolean        loopIsSoundset; //qtrue if the loopSound index is actually a soundset index
02717 
02718         int             soundSetIndex;
02719 
02720         int             modelGhoul2;
02721         int             g2radius;
02722         int             modelindex;
02723         int             modelindex2;
02724         int             clientNum;              // 0 to (MAX_CLIENTS - 1), for players and corpses
02725         int             frame;
02726 
02727         qboolean        saberInFlight;
02728         int                     saberEntityNum;
02729         int                     saberMove;
02730         int                     forcePowersActive;
02731         int                     saberHolstered;//sent in only only 2 bits - should be 0, 1 or 2
02732 
02733         qboolean        isJediMaster;
02734 
02735         qboolean        isPortalEnt; //this needs to be seperate for all entities I guess, which is why I couldn't reuse another value.
02736 
02737         int             solid;                  // for client side prediction, trap_linkentity sets this properly
02738 
02739         int             event;                  // impulse events -- muzzle flashes, footsteps, etc
02740         int             eventParm;
02741 
02742         // so crosshair knows what it's looking at
02743         int                     owner;
02744         int                     teamowner;
02745         qboolean        shouldtarget;
02746 
02747         // for players
02748         int             powerups;               // bit flags
02749         int             weapon;                 // determines weapon and flash model, etc
02750         int             legsAnim;
02751         int             torsoAnim;
02752 
02753         qboolean        legsFlip; //set to opposite when the same anim needs restarting, sent over in only 1 bit. Cleaner and makes porting easier than having that god forsaken ANIM_TOGGLEBIT.
02754         qboolean        torsoFlip;
02755 
02756         int             forceFrame;             //if non-zero, force the anim frame
02757 
02758         int             generic1;
02759 
02760         int             heldByClient; //can only be a client index - this client should be holding onto my arm using IK stuff.
02761 
02762         int             ragAttach; //attach to ent while ragging
02763 
02764         int             iModelScale; //rww - transfer a percentage of the normal scale in a single int instead of 3 x-y-z scale values
02765 
02766         int             brokenLimbs;
02767 
02768         int             boltToPlayer; //set to index of a real client+1 to bolt the ent to that client. Must be a real client, NOT an NPC.
02769 
02770         //for looking at an entity's origin (NPCs and players)
02771         qboolean        hasLookTarget;
02772         int                     lookTarget;
02773 
02774         int                     customRGBA[4];
02775 
02776         //I didn't want to do this, but I.. have no choice. However, we aren't setting this for all ents or anything,
02777         //only ones we want health knowledge about on cgame (like siege objective breakables) -rww
02778         int                     health;
02779         int                     maxhealth; //so I know how to draw the stupid health bar
02780 
02781         //NPC-SPECIFIC FIELDS
02782         //------------------------------------------------------------
02783         int             npcSaber1;
02784         int             npcSaber2;
02785 
02786         //index values for each type of sound, gets the folder the sounds
02787         //are in. I wish there were a better way to do this,
02788         int             csSounds_Std;
02789         int             csSounds_Combat;
02790         int             csSounds_Extra;
02791         int             csSounds_Jedi;
02792 
02793         int             surfacesOn; //a bitflag of corresponding surfaces from a lookup table. These surfaces will be forced on.
02794         int             surfacesOff; //same as above, but forced off instead.
02795 
02796         //Allow up to 4 PCJ lookup values to be stored here.
02797         //The resolve to configstrings which contain the name of the
02798         //desired bone.
02799         int             boneIndex1;
02800         int             boneIndex2;
02801         int             boneIndex3;
02802         int             boneIndex4;
02803 
02804         //packed with x, y, z orientations for bone angles
02805         int             boneOrient;
02806 
02807         //I.. feel bad for doing this, but NPCs really just need to
02808         //be able to control this sort of thing from the server sometimes.
02809         //At least it's at the end so this stuff is never going to get sent
02810         //over for anything that isn't an NPC.
02811         vec3_t  boneAngles1; //angles of boneIndex1
02812         vec3_t  boneAngles2; //angles of boneIndex2
02813         vec3_t  boneAngles3; //angles of boneIndex3
02814         vec3_t  boneAngles4; //angles of boneIndex4
02815 
02816         int             NPC_class; //we need to see what it is on the client for a few effects.
02817 
02818         //If non-0, this is the index of the vehicle a player/NPC is riding.
02819         int             m_iVehicleNum;
02820 
02821         //rww - spare values specifically for use by mod authors.
02822         //See netf_overrides.txt if you want to increase the send
02823         //amount of any of these above 1 bit.
02824         int                     userInt1;
02825         int                     userInt2;
02826         int                     userInt3;
02827         float           userFloat1;
02828         float           userFloat2;
02829         float           userFloat3;
02830         vec3_t          userVec1;
02831         vec3_t          userVec2;
02832 } entityState_t;
02833 
02834 #else
02835 // Now, XBOX version with members packed in tightly to save gobs of memory
02836 // This is rather confusing. All members are in 1, 2, or 4 bytes, and then
02837 // re-ordered within the structure to keep everything aligned.
02838 
02839 #pragma pack(push, 1)
02840 
02841 typedef struct entityState_s {
02842         // Large (32-bit) fields first
02843 
02844         int             number;                 // entity index
02845         int             eFlags;
02846 
02847         trajectory_t    pos;    // for calculating position
02848         trajectory_t    apos;   // for calculating angles
02849 
02850         int             time;
02851         int             time2;
02852 
02853         vec3_t  origin;
02854         vec3_t  origin2;
02855 
02856         vec3_t  angles;
02857         vec3_t  angles2;
02858 
02859         float   speed;
02860 
02861         int             genericenemyindex;
02862 
02863         int             emplacedOwner;
02864 
02865         int             constantLight;  // r + (g<<8) + (b<<16) + (intensity<<24)
02866         int             forcePowersActive;
02867 
02868         int             solid;                  // for client side prediction, trap_linkentity sets this properly
02869 
02870         byte    customRGBA[4];
02871 
02872         int             surfacesOn; //a bitflag of corresponding surfaces from a lookup table. These surfaces will be forced on.
02873         int             surfacesOff; //same as above, but forced off instead.
02874 
02875         //I.. feel bad for doing this, but NPCs really just need to
02876         //be able to control this sort of thing from the server sometimes.
02877         //At least it's at the end so this stuff is never going to get sent
02878         //over for anything that isn't an NPC.
02879         vec3_t  boneAngles1; //angles of boneIndex1
02880         vec3_t  boneAngles2; //angles of boneIndex2
02881         vec3_t  boneAngles3; //angles of boneIndex3
02882         vec3_t  boneAngles4; //angles of boneIndex4
02883 
02884 
02885         // Now, the 16-bit members
02886 
02887 
02888         word    bolt2;
02889         word    trickedentindex; //0-15
02890 
02891         word    trickedentindex2; //16-32
02892         word    trickedentindex3; //33-48
02893 
02894         word    trickedentindex4; //49-64
02895         word    otherEntityNum; // shotgun sources, etc
02896 
02897         word    otherEntityNum2;
02898         word    groundEntityNum;        // -1 = in air
02899 
02900         short   modelindex;
02901         word    clientNum;              // 0 to (MAX_CLIENTS - 1), for players and corpses
02902 
02903         word    frame;
02904         word    saberEntityNum;
02905 
02906         word    event;                  // impulse events -- muzzle flashes, footsteps, etc
02907         word    owner; // so crosshair knows what it's looking at
02908 
02909         word    powerups;               // bit flags
02910         word    legsAnim;
02911 
02912         word    torsoAnim;
02913         word    forceFrame;             //if non-zero, force the anim frame
02914 
02915         word    ragAttach; //attach to ent while ragging
02916         short   iModelScale; //rww - transfer a percentage of the normal scale in a single int instead of 3 x-y-z scale values
02917 
02918         word    lookTarget;
02919         word    health;
02920 
02921         word    maxhealth; //so I know how to draw the stupid health bar
02922         word    npcSaber1;
02923 
02924         word    npcSaber2;
02925         word    boneOrient; //packed with x, y, z orientations for bone angles
02926 
02927         //If non-0, this is the index of the vehicle a player/NPC is riding.
02928         word    m_iVehicleNum;
02929 
02930 
02931         // Now, the 8-bit members. These start out two bytes off, thanks to the above word
02932 
02933 
02934         byte    eType;                  // entityType_t
02935         byte    eFlags2;                // EF2_??? used much less frequently
02936 
02937         byte    bolt1;
02938         byte    fireflag;
02939         byte    activeForcePass;
02940         byte    loopSound;              // constantly loop this sound
02941 
02942         byte    loopIsSoundset; //qtrue if the loopSound index is actually a soundset index
02943         byte    soundSetIndex;
02944         byte    modelGhoul2;
02945         byte    g2radius;
02946 
02947         byte    modelindex2;
02948         byte    saberInFlight;
02949         byte    saberMove;
02950         byte    isJediMaster;
02951         byte    saberHolstered;//sent in only 2 bytes, should be 0, 1 or 2
02952 
02953         byte    isPortalEnt; //this needs to be seperate for all entities I guess, which is why I couldn't reuse another value.
02954         byte    eventParm;
02955         byte    teamowner;
02956         byte    shouldtarget;
02957 
02958         byte    weapon;                 // determines weapon and flash model, etc
02959         byte    legsFlip; //set to opposite when the same anim needs restarting, sent over in only 1 bit. Cleaner and makes porting easier than having that god forsaken ANIM_TOGGLEBIT.
02960         byte    torsoFlip;
02961         byte    generic1;
02962 
02963         byte    heldByClient; //can only be a client index - this client should be holding onto my arm using IK stuff.
02964         byte    brokenLimbs;
02965         byte    boltToPlayer; //set to index of a real client+1 to bolt the ent to that client. Must be a real client, NOT an NPC.
02966         byte    hasLookTarget; //for looking at an entity's origin (NPCs and players)
02967 
02968         //index values for each type of sound, gets the folder the sounds
02969         //are in. I wish there were a better way to do this,
02970         byte    csSounds_Std;
02971         byte    csSounds_Combat;
02972         byte    csSounds_Extra;
02973         byte    csSounds_Jedi;
02974 
02975         //Allow up to 4 PCJ lookup values to be stored here.
02976         //The resolve to configstrings which contain the name of the
02977         //desired bone.
02978         byte    boneIndex1;
02979         byte    boneIndex2;
02980         byte    boneIndex3;
02981         byte    boneIndex4;
02982 
02983         byte    NPC_class; //we need to see what it is on the client for a few effects.
02984         byte    alignPad[3];
02985 } entityState_t;
02986 
02987 #pragma pack(pop)
02988 
02989 #endif
02990 
02991 typedef enum {
02992         CA_UNINITIALIZED,
02993         CA_DISCONNECTED,        // not talking to a server
02994         CA_AUTHORIZING,         // not used any more, was checking cd key 
02995         CA_CONNECTING,          // sending request packets to the server
02996         CA_CHALLENGING,         // sending challenge packets to the server
02997         CA_CONNECTED,           // netchan_t established, getting gamestate
02998         CA_LOADING,                     // only during cgame initialization, never during main loop
02999         CA_PRIMED,                      // got gamestate, waiting for first frame
03000         CA_ACTIVE,                      // game views should be displayed
03001         CA_CINEMATIC            // playing a cinematic or a static pic, not connected to a server
03002 } connstate_t;
03003 
03004 
03005 #define Square(x) ((x)*(x))
03006 
03007 // real time
03008 //=============================================
03009 
03010 
03011 typedef struct qtime_s {
03012         int tm_sec;     /* seconds after the minute - [0,59] */
03013         int tm_min;     /* minutes after the hour - [0,59] */
03014         int tm_hour;    /* hours since midnight - [0,23] */
03015         int tm_mday;    /* day of the month - [1,31] */
03016         int tm_mon;     /* months since January - [0,11] */
03017         int tm_year;    /* years since 1900 */
03018         int tm_wday;    /* days since Sunday - [0,6] */
03019         int tm_yday;    /* days since January 1 - [0,365] */
03020         int tm_isdst;   /* daylight savings time flag */
03021 } qtime_t;
03022 
03023 
03024 // server browser sources
03025 #define AS_LOCAL                        0
03026 #define AS_GLOBAL                       1
03027 #define AS_FAVORITES            2
03028 
03029 #define AS_MPLAYER                      3 // (Obsolete)
03030 
03031 // cinematic states
03032 typedef enum {
03033         FMV_IDLE,
03034         FMV_PLAY,               // play
03035         FMV_EOF,                // all other conditions, i.e. stop/EOF/abort
03036         FMV_ID_BLT,
03037         FMV_ID_IDLE,
03038         FMV_LOOPED,
03039         FMV_ID_WAIT
03040 };
03041 typedef int e_status;
03042 
03043 typedef enum _flag_status {
03044         FLAG_ATBASE = 0,
03045         FLAG_TAKEN,                     // CTF
03046         FLAG_TAKEN_RED,         // One Flag CTF
03047         FLAG_TAKEN_BLUE,        // One Flag CTF
03048         FLAG_DROPPED
03049 };
03050 typedef int flagStatus_t;
03051 
03052 
03053 
03054 #ifdef _XBOX
03055 #define MAX_GLOBAL_SERVERS                      50
03056 #define MAX_OTHER_SERVERS                       16
03057 #else
03058 #define MAX_GLOBAL_SERVERS                      2048
03059 #define MAX_OTHER_SERVERS                       128
03060 #endif
03061 #define MAX_PINGREQUESTS                        32
03062 #define MAX_SERVERSTATUSREQUESTS        16
03063 
03064 #define SAY_ALL         0
03065 #define SAY_TEAM        1
03066 #define SAY_TELL        2
03067 
03068 #define CDKEY_LEN 16
03069 #define CDCHKSUM_LEN 2
03070 
03071 void Rand_Init(int seed);
03072 float flrand(float min, float max);
03073 int irand(int min, int max);
03074 int Q_irand(int value1, int value2);
03075 
03076 /*
03077 Ghoul2 Insert Start
03078 */
03079 
03080 typedef struct {
03081         float           matrix[3][4];
03082 } mdxaBone_t;
03083 
03084 // For ghoul2 axis use
03085 
03086 typedef enum Eorientations
03087 {
03088         ORIGIN = 0, 
03089         POSITIVE_X,
03090         POSITIVE_Z,
03091         POSITIVE_Y,
03092         NEGATIVE_X,
03093         NEGATIVE_Z,
03094         NEGATIVE_Y
03095 };
03096 /*
03097 Ghoul2 Insert End
03098 */
03099 
03100 
03101 // define the new memory tags for the zone, used by all modules now
03102 //
03103 #define TAGDEF(blah) TAG_ ## blah
03104 typedef enum {
03105         #include "../qcommon/tags.h"
03106 };
03107 typedef char memtag_t;
03108 
03109 //rww - conveniently toggle "gore" code, for model decals and stuff.
03110 #define _G2_GORE
03111 
03112 typedef struct SSkinGoreData_s
03113 {
03114         vec3_t                  angles;
03115         vec3_t                  position;
03116         int                             currentTime;
03117         int                             entNum;
03118         vec3_t                  rayDirection;   // in world space
03119         vec3_t                  hitLocation;    // in world space
03120         vec3_t                  scale;
03121         float                   SSize;                  // size of splotch in the S texture direction in world units
03122         float                   TSize;                  // size of splotch in the T texture direction in world units
03123         float                   theta;                  // angle to rotate the splotch
03124 
03125         // growing stuff
03126         int                             growDuration;                   // time over which we want this to scale up, set to -1 for no scaling
03127         float                   goreScaleStartFraction; // fraction of the final size at which we want the gore to initially appear
03128 
03129         qboolean                frontFaces;
03130         qboolean                backFaces;
03131         qboolean                baseModelOnly;
03132         int                             lifeTime;                               // effect expires after this amount of time
03133         int                             fadeOutTime;                    //specify the duration of fading, from the lifeTime (e.g. 3000 will start fading 3 seconds before removal and be faded entirely by removal)
03134         int                             shrinkOutTime;                  // unimplemented
03135         float                   alphaModulate;                  // unimplemented
03136         vec3_t                  tint;                                   // unimplemented
03137         float                   impactStrength;                 // unimplemented
03138 
03139         int                             shader; // shader handle 
03140 
03141         int                             myIndex; // used internally
03142 
03143         qboolean                fadeRGB; //specify fade method to modify RGB (by default, the alpha is set instead)
03144 } SSkinGoreData;
03145 
03146 /*
03147 ========================================================================
03148 
03149 String ID Tables
03150 
03151 ========================================================================
03152 */
03153 #define ENUM2STRING(arg)   #arg,arg
03154 typedef struct stringID_table_s
03155 {
03156         char    *name;
03157         int             id;
03158 } stringID_table_t;
03159 
03160 int GetIDForString ( stringID_table_t *table, const char *string );
03161 const char *GetStringForID( stringID_table_t *table, int id );
03162 
03163 
03164 // stuff to help out during development process, force reloading/uncacheing of certain filetypes...
03165 //
03166 typedef enum
03167 {
03168         eForceReload_NOTHING,
03169 //      eForceReload_BSP,       // not used in MP codebase
03170         eForceReload_MODELS,
03171         eForceReload_ALL
03172 
03173 } ForceReload_e;
03174 
03175 
03176 enum {
03177         FONT_NONE,
03178         FONT_SMALL=1,
03179         FONT_MEDIUM,
03180         FONT_LARGE,
03181         FONT_SMALL2
03182 };
03183 
03184 
03185 
03186 #endif  // __Q_SHARED_H