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