1 /* 2 Copyright (C) 1997-2001 Id Software, Inc. 3 4 This program is free software; you can redistribute it and/or 5 modify it under the terms of the GNU General Public License 6 as published by the Free Software Foundation; either version 2 7 of the License, or (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or v 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 */ 19 20 // 21 // shared.h 22 // Included first by ALL program modules 23 // 24 25 #ifndef __SHARED_H__ 26 #define __SHARED_H__ 27 28 #include <assert.h> 29 #include <math.h> 30 #include <stdio.h> 31 #include <stdarg.h> 32 #include <string.h> 33 #include <stdlib.h> 34 #include <time.h> 35 #include <ctype.h> 36 37 // ========================================================================= 38 39 //R1Q2 SPECIFC 40 #define SVF_NOPREDICTION 0x00000008 41 //R1Q2 SPECIFC 42 43 // ========================================================================= 44 // Windows 45 // 46 #ifdef WIN32 47 48 // unknown pragmas are SUPPOSED to be ignored, but.... 49 # pragma warning(disable : 4244) // 'conversion' conversion from 'type1' to 'type2', possible loss of data 50 51 // Off by default, force on for level 3 warning level 52 # pragma warning(3 : 4056) // overflow in floating point constant arithmetic 53 # pragma warning(3 : 4191) // 'operator/operation' : unsafe conversion from 'type of expression' to 'type required' 54 # pragma warning(3 : 4202) // nonstandard extension used : '...': prototype parameter in name list illegal 55 # pragma warning(3 : 4254) // 'operator' : conversion from 'type1' to 'type2', possible loss of data 56 57 # pragma intrinsic(memcmp) 58 59 # define GL_DRIVERNAME "opengl32.dll" 60 # define AL_DRIVERNAME "openal32.dll" 61 62 # define HAVE___INLINE 63 # define HAVE___FASTCALL 64 # define HAVE__SNPRINTF 65 # define HAVE__STRICMP 66 # define HAVE__VSNPRINTF 67 # define HAVE__CDECL 68 69 # define BUILDSTRING "Win32" 70 71 # ifdef NDEBUG 72 # ifdef _M_IX86 73 # define CPUSTRING "x86" 74 # elif defined _M_ALPHA 75 # define CPUSTRING "AXP" 76 # endif 77 # else // NDEBUG 78 # ifdef _M_IX86 79 # define CPUSTRING "x86 Debug" 80 # elif defined _M_ALPHA 81 # define CPUSTRING "AXP Debug" 82 # endif 83 # endif // NDEBUG 84 85 typedef __int16 int16; 86 typedef __int32 int32; 87 typedef __int64 int64; 88 typedef unsigned __int16 uint16; 89 typedef unsigned __int32 uint32; 90 typedef unsigned __int64 uint64; 91 92 # define strdup _strdup 93 94 # define __declspec_naked __declspec(naked) 95 96 // ========================================================================= 97 // Generic Unix 98 // 99 #elif defined __unix__ 100 # define GL_DRIVERNAME "libGL.so.1" 101 # define AL_DRIVERNAME "libopenal.so.0" 102 # define GL_FORCEFINISH 103 104 # define HAVE_INLINE 105 # define HAVE_STRCASECMP 106 107 # define __declspec 108 # define __declspec_naked 109 110 // 111 // Linux 112 // 113 # if defined __linux__ 114 # include <stdint.h> 115 116 # define BUILDSTRING "Linux" 117 118 # ifdef NDEBUG 119 # ifdef __i386__ 120 # define CPUSTRING "i386" 121 # elif defined(__alpha__) 122 # define CPUSTRING "AXP" 123 # endif 124 # else // NDEBUG 125 # ifdef __i386__ 126 # define CPUSTRING "i386 Debug" 127 # elif defined(__alpha__) 128 # define CPUSTRING "AXP Debug" 129 # endif 130 # endif // NDEBUG 131 132 // 133 // FreeBSD 134 // 135 # elif defined __FreeBSD__ 136 # include <machine/param.h> 137 # if __FreeBSD_version < 500000 138 # include <inttypes.h> 139 # else 140 # include <stdint.h> 141 # endif 142 143 # define BUILDSTRING "FreeBSD" 144 145 # ifdef NDEBUG 146 # ifdef __i386__ 147 # define CPUSTRING "i386" 148 # elif defined(__alpha__) 149 # define CPUSTRING "AXP" 150 # endif 151 # else // NDEBUG 152 # ifdef __i386__ 153 # define CPUSTRING "i386 Debug" 154 # elif defined(__alpha__) 155 # define CPUSTRING "AXP Debug" 156 # endif 157 # endif // NDEBUG 158 159 # endif 160 161 typedef int16_t int16; 162 typedef int32_t int32; 163 typedef int64_t int64; 164 typedef uint16_t uint16; 165 typedef uint32_t uint32; 166 typedef uint64_t uint64; 167 168 #endif // __unix__ 169 170 // ========================================================================= 171 172 #ifndef HAVE__CDECL 173 # define __cdecl 174 #endif 175 176 #ifndef HAVE___FASTCALL 177 # define __fastcall 178 #endif 179 180 #ifdef HAVE___INLINE 181 # ifndef inline 182 # define inline __inline 183 # endif 184 #elif !defined(HAVE_INLINE) 185 # ifndef inline 186 # define inline 187 # endif 188 #endif 189 190 #ifdef HAVE__SNPRINTF 191 # ifndef snprintf 192 # define snprintf _snprintf 193 # endif 194 #endif 195 196 #ifdef HAVE_STRCASECMP 197 # ifndef Q_stricmp 198 # define Q_stricmp(s1,s2) strcasecmp ((s1), (s2)) 199 # endif 200 # ifndef Q_strnicmp 201 # define Q_strnicmp(s1,s2,n) strncasecmp ((s1), (s2), (n)) 202 # endif 203 #endif 204 205 #ifdef HAVE__STRICMP 206 # ifndef Q_stricmp 207 # define Q_stricmp(s1, s2) _stricmp((s1), (s2)) 208 # endif 209 # ifndef Q_strnicmp 210 # define Q_strnicmp(s1, s2, n) _strnicmp((s1), (s2), (n)) 211 # endif 212 #endif 213 214 #ifdef HAVE__VSNPRINTF 215 # ifndef vsnprintf 216 # define vsnprintf _vsnprintf 217 # endif 218 #endif 219 220 // ========================================================================= 221 222 #if (defined(_M_IX86) || defined(__i386__)) && !defined(C_ONLY) && !defined(__unix__) // FIXME: make this work with unix 223 # define id386 224 #else 225 # ifdef id386 226 # undef id386 227 # endif 228 #endif 229 230 #ifndef BUILDSTRING 231 # define BUILDSTRING "Unknown" 232 #endif 233 234 #ifndef CPUSTRING 235 # define CPUSTRING "Unknown" 236 #endif 237 238 #ifndef NULL 239 # define NULL ((void *)0) 240 #endif 241 242 // ========================================================================= 243 244 typedef unsigned char byte; 245 typedef enum {qFalse, qTrue} qBool; 246 247 /* 248 ============================================================================= 249 250 PROTOCOL 251 252 ============================================================================= 253 */ 254 255 #define ORIGINAL_PROTOCOL_VERSION 34 256 257 #define ENHANCED_PROTOCOL_VERSION 35 258 #define ENHANCED_COMPATIBILITY_NUMBER 1903 259 260 // 261 // server to client 262 // note: ONLY add things to the bottom, to keep Quake2 compatibility 263 // 264 enum svcTypes { 265 SVC_BAD, 266 267 // 268 // these ops are known to the game dll 269 // 270 SVC_MUZZLEFLASH, 271 SVC_MUZZLEFLASH2, 272 SVC_TEMP_ENTITY, 273 SVC_LAYOUT, 274 SVC_INVENTORY, 275 276 // 277 // the rest are private to the client and server (you can not modify their order!) 278 // 279 SVC_NOP, 280 SVC_DISCONNECT, 281 SVC_RECONNECT, 282 SVC_SOUND, // <see code> 283 SVC_PRINT, // [byte] id [string] null terminated string 284 SVC_STUFFTEXT, // [string] stuffed into client's console buffer, should be \n terminated 285 SVC_SERVERDATA, // [long] protocol ... 286 SVC_CONFIGSTRING, // [short] [string] 287 SVC_SPAWNBASELINE, 288 SVC_CENTERPRINT, // [string] to put in center of the screen 289 SVC_DOWNLOAD, // [short] size [size bytes] 290 SVC_PLAYERINFO, // variable 291 SVC_PACKETENTITIES, // [...] 292 SVC_DELTAPACKETENTITIES, // [...] 293 SVC_FRAME, 294 295 SVC_ZPACKET, // new for ENHANCED_PROTOCOL_VERSION 296 SVC_ZDOWNLOAD, // new for ENHANCED_PROTOCOL_VERSION 297 298 SVC_MAX 299 }; 300 301 // 302 // game print flags 303 // 304 enum gamePrint { 305 PRINT_LOW, // pickup messages 306 PRINT_MEDIUM, // death messages 307 PRINT_HIGH, // critical messages 308 PRINT_CHAT // chat messages 309 }; 310 311 // 312 // destination class for gi.multicast() 313 // 314 typedef enum { 315 MULTICAST_ALL, 316 MULTICAST_PHS, 317 MULTICAST_PVS, 318 MULTICAST_ALL_R, 319 MULTICAST_PHS_R, 320 MULTICAST_PVS_R 321 } multiCast_t; 322 323 // 324 // client connection state 325 // 326 typedef enum caState_s { 327 CA_UNINITIALIZED, // initial state 328 CA_DISCONNECTED, // not talking to a server 329 CA_CONNECTING, // sending request packets to the server 330 CA_CONNECTED, // netChan_t established, waiting for svc_serverdata 331 CA_ACTIVE // game views should be displayed 332 } caState_t; 333 334 // 335 // server state 336 // 337 typedef enum ssState_s { 338 SS_DEAD, // no map loaded 339 SS_LOADING, // spawning level edicts 340 SS_GAME, // actively running 341 SS_CINEMATIC, // playing a cinematic 342 SS_DEMO, // playing a demo 343 SS_PIC // just showing a pic 344 } ssState_t; 345 346 /* 347 ============================================================================== 348 349 MATHLIB 350 351 ============================================================================== 352 */ 353 354 typedef byte bvec2_t[2]; 355 typedef byte bvec3_t[3]; 356 typedef byte bvec4_t[4]; 357 358 typedef double dvec2_t[2]; 359 typedef double dvec3_t[3]; 360 typedef double dvec4_t[4]; 361 362 typedef int32 index_t; 363 typedef int32 ivec2_t[2]; 364 typedef int32 ivec3_t[3]; 365 typedef int32 ivec4_t[4]; 366 367 typedef int16 svec2_t[2]; 368 typedef int16 svec3_t[3]; 369 typedef int16 svec4_t[4]; 370 371 typedef float vec2_t[2]; 372 typedef float vec3_t[3]; 373 typedef float vec4_t[4]; 374 375 typedef float mat_t; 376 typedef float quat_t[4]; 377 typedef float mat3x3_t[3][3]; 378 typedef float mat4x4_t[16]; 379 380 // =========================================================================== 381 382 extern vec2_t vec2Origin; 383 extern vec3_t vec3Origin; 384 extern vec4_t vec4Origin; 385 extern mat4x4_t mat4x4Identity; 386 extern mat3x3_t axisIdentity; 387 extern quat_t quatIdentity; 388 389 // =========================================================================== 390 391 #ifndef M_PI 392 # define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h 393 #endif 394 395 // angle indexes 396 enum { 397 PITCH, // up / down 398 YAW, // left / right 399 ROLL // fall over 400 }; 401 402 #define DEG2RAD(v) ((v) * (M_PI / 180.0f)) 403 #define RAD2DEG(v) ((v) * (180.0f / M_PI)) 404 405 #define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) 406 #define SHORT2ANGLE(x) ((x)*(360.0f/65536)) 407 408 #define ANGLE2BYTE(x) ((int)((x)*256/360) & 255) 409 #define BYTE2ANGLE(x) ((x)*(360.0f/256)) 410 411 #ifndef max 412 # define max(a,b) (((a) > (b)) ? (a) : (b)) 413 #endif 414 415 #ifndef min 416 # define min(a,b) (((a) < (b)) ? (a) : (b)) 417 #endif 418 419 #define bound(a,b,c) ((a) >= (c) ? (a) : (b) < (a) ? (a) : (b) > (c) ? (c) : (b)) 420 #define clamp(a,b,c) ((b) >= (c) ? (b) : (a) < (b) ? (b) : (a) > (c) ? (c) : (a)) 421 #define clampl(a,b,c) ((b) >= (c) ? (a)=(b) : (a) < (b) ? (a)=(b) : (a) > (c) ? (a)=(c) : (a)=(a)) 422 423 // =========================================================================== 424 425 void seedMT (uint32 seed); 426 uint32 randomMT (void); 427 428 #define frand() (randomMT() * 0.00000000023283064365386962890625f) // 0 to 1 429 #define crand() (((int)randomMT() - 0x7FFFFFFF) * 0.000000000465661287307739257812f) // -1 to 1 430 431 // =========================================================================== 432 433 #define LARGE_EPSILON 0.1 434 #define SMALL_EPSILON 0.01 435 #define TINY_EPSILON 0.001 436 437 // =========================================================================== 438 439 #define NUMVERTEXNORMALS 162 440 extern vec3_t m_byteDirs[NUMVERTEXNORMALS]; 441 442 byte DirToByte (vec3_t dirVec); 443 void ByteToDir (byte dirByte, vec3_t dirVec); 444 445 // =========================================================================== 446 447 byte FloatToByte (float x); 448 449 float ColorNormalizef (const float *in, float *out); 450 float ColorNormalizeb (const float *in, byte *out); 451 452 // =========================================================================== 453 454 #define Vec2Add(a,b,out) ((out)[0]=(a)[0]+(b)[0],(out)[1]=(a)[1]+(b)[1]) 455 #define Vec2Clear(in) (*(int *)&(in)[0]=0,*(int *)&(in)[1]=0) 456 #define Vec2Compare(v1,v2) ((v1)[0]==(v2)[0] && (v1)[1]==(v2)[1]) 457 #define Vec2Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1]) 458 #define Vec2Dist(v1,v2) (sqrt((((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])))) 459 #define Vec2DistFast(v1,v2) (Q_FastSqrt((((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])))) 460 #define Vec2Inverse(v) ((v)[0]=-(v)[0],(v)[1]=-(v)[1]) 461 #define Vec2MA(v,s,b,o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s)) 462 #define Vec2Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1]) 463 #define Vec2Scale(in,s,out) ((out)[0]=(in)[0]*(s),(out)[1]=(in)[1]*(s)) 464 #define Vec2Set(v,x,y) ((v)[0]=(x),(v)[1]=(y)) 465 #define Vec2Subtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1]) 466 467 #define CrossProduct(v1,v2,cr) ((cr)[0]=(v1)[1]*(v2)[2]-(v1)[2]*(v2)[1],(cr)[1]=(v1)[2]*(v2)[0]-(v1)[0]*(v2)[2],(cr)[2]=(v1)[0]*(v2)[1]-(v1)[1]*(v2)[0]) 468 #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) 469 470 #define Vec3Add(a,b,out) ((out)[0]=(a)[0]+(b)[0],(out)[1]=(a)[1]+(b)[1],(out)[2]=(a)[2]+(b)[2]) 471 #define Vec3Average(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) 472 #define Vec3Clear(a) (*(int *)&(a)[0]=0,*(int *)&(a)[1]=0,*(int *)&(a)[2]=0) 473 #define Vec3Compare(v1,v2) ((v1)[0]==(v2)[0] && (v1)[1]==(v2)[1] && (v1)[2]==(v2)[2]) 474 #define Vec3Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) 475 #define Vec3Dist(v1,v2) (sqrt((((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])+((v1)[2]-(v2)[2])*((v1)[2]-(v2)[2])))) 476 #define Vec3DistFast(v1,v2) (Q_FastSqrt((((v1)[0]-(v2)[0])*((v1)[0]-(v2)[0])+((v1)[1]-(v2)[1])*((v1)[1]-(v2)[1])+((v1)[2]-(v2)[2])*((v1)[2]-(v2)[2])))) 477 #define Vec3Inverse(v) ((v)[0]=-(v)[0],(v)[1]=-(v)[1],(v)[2]=-(v)[2]) 478 #define Vec3Length(v) (sqrt(DotProduct((v),(v)))) 479 #define Vec3LengthFast(v) (Q_FastSqrt(DotProduct((v),(v)))) 480 #define Vec3MA(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)) 481 #define Vec3Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) 482 #define Vec3Scale(in,s,out) ((out)[0]=(in)[0]*(s),(out)[1]=(in)[1]*(s),(out)[2]=(in)[2]*(s)) 483 #define Vec3Set(v,x,y,z) ((v)[0]=(x),(v)[1]=(y),(v)[2]=(z)) 484 #define Vec3Subtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) 485 486 #define Vec4Add(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2],(c)[3]=(a)[3]+(b)[3]) 487 #define Vec4Average(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,(c)[3]=((a)[3]+(b)[3])*0.5f) 488 #define Vec4Clear(a) (*(int *)&(a)[0]=0,*(int *)&(a)[1]=0,*(int *)&(a)[2]=0,*(int *)&(a)[3]=0) 489 #define Vec4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) 490 #define Vec4Identity(a) ((a)[0]=(a)[1]=(a)[2]=(a)[3]=0) 491 #define Vec4MA(v,s,b,o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s),(o)[3]=(v)[3]+(b)[3]*(s)) 492 #define Vec4Negate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2],(b)[3]=-(a)[3]) 493 #define Vec4Scale(in,s,out) ((out)[0]=(in)[0]*(s),(out)[1]=(in)[1]*(s),(out)[2]=(in)[2]*(s),(out)[3]=(in)[3]*(s)) 494 #define Vec4Set(v,u,x,y,z) ((v)[0]=(u),(v)[1]=(x),(v)[2]=(y),(v)[3]=(z)) 495 #define Vec4Subtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2],(c)[3]=(a)[3]-(b)[3]) 496 497 // =========================================================================== 498 499 #define Q_rint(x) ((x) < 0 ? ((int)((x)-0.5f)) : ((int)((x)+0.5f))) 500 501 #ifdef id386 502 long Q_ftol (float f); 503 float Q_FastSqrt (float value); 504 #else // id386 505 # define Q_ftol(f) ((long)(f)) 506 # define Q_FastSqrt(v) (sqrt(v)) 507 #endif // id386 508 509 float Q_RSqrtf (float number); 510 double Q_RSqrtd (double number); 511 int Q_log2 (int val); 512 void Q_NearestPow (int *var, qBool oneLess); 513 514 float Q_CalcFovY (float fovX, float width, float height); 515 516 // =========================================================================== 517 518 void NormToLatLong (vec3_t normal, byte latLong[2]); 519 void MakeNormalVectorsf (vec3_t forward, vec3_t right, vec3_t up); 520 void MakeNormalVectorsd (dvec3_t forward, dvec3_t right, dvec3_t up); 521 void PerpendicularVector (vec3_t src, vec3_t dst); 522 void RotatePointAroundVector (vec3_t dst, vec3_t dir, vec3_t point, float degrees); 523 float VectorNormalizef (vec3_t in, vec3_t out); 524 double VectorNormalized (dvec3_t in, dvec3_t out); 525 float VectorNormalizeFastf (vec3_t v); 526 double VectorNormalizeFastd (dvec3_t v); 527 528 // 529 // m_angles.c 530 // 531 float AngleModf (float a); 532 void Angles_Matrix3 (vec3_t angles, mat3x3_t axis); 533 void Angles_Vectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); 534 float LerpAngle (float a1, float a2, float frac); 535 void VecToAngles (vec3_t vec, vec3_t angles); 536 void VecToAngleRolled (vec3_t value, float angleYaw, vec3_t angles); 537 float VecToYaw (vec3_t vec); 538 539 // 540 // m_bounds.c 541 // 542 void AddBoundsTo2DBounds (vec2_t inMins, vec2_t inMaxs, vec2_t outMins, vec2_t outMaxs); 543 void AddPointTo2DBounds (vec2_t v, vec2_t mins, vec2_t maxs); 544 void Clear2DBounds (vec2_t mins, vec2_t maxs); 545 546 void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs); 547 qBool BoundsAndSphereIntersect (const vec3_t mins, const vec3_t maxs, const vec3_t centre, float radius); 548 qBool BoundsIntersect (const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2); 549 void ClearBounds (vec3_t mins, vec3_t maxs); 550 void MinMins (vec3_t a, vec3_t b, vec3_t out); 551 void MaxMaxs (vec3_t a, vec3_t b, vec3_t out); 552 float RadiusFromBounds (vec3_t mins, vec3_t maxs); 553 554 // 555 // m_mat3.c 556 // 557 void Matrix3_Angles (mat3x3_t mat, vec3_t angles); 558 qBool Matrix3_Compare (mat3x3_t a, mat3x3_t b); 559 void Matrix3_Copy (mat3x3_t in, mat3x3_t out); 560 void Matrix3_FromPoints (vec3_t v1, vec3_t v2, vec3_t v3, mat3x3_t m); 561 void Matrix3_Identity (mat3x3_t mat); 562 void Matrix3_Matrix4 (mat3x3_t in, vec3_t origin, mat4x4_t out); 563 void Matrix3_Multiply (mat3x3_t in1, mat3x3_t in2, mat3x3_t out); 564 void Matrix3_Quat (mat3x3_t m, quat_t q); 565 void Matrix3_Rotate (mat3x3_t a, mat_t angle, mat_t x, mat_t y, mat_t z); 566 void Matrix3_TransformVector (mat3x3_t m, vec3_t v, vec3_t out); 567 void Matrix3_Transpose (mat3x3_t in, mat3x3_t out); 568 569 // 570 // m_mat4.c 571 // 572 qBool Matrix4_Compare (mat4x4_t a, mat4x4_t b); 573 void Matrix4_Copy (mat4x4_t a, mat4x4_t b); 574 void Matrix4_Identity (mat4x4_t mat); 575 void Matrix4_Matrix3 (mat4x4_t in, mat3x3_t out); 576 void Matrix4_Multiply (mat4x4_t a, mat4x4_t b, mat4x4_t product); 577 void Matrix4_Multiply_Vec3 (mat4x4_t m, vec3_t v, vec3_t out); 578 void Matrix4_Multiply_Vec4 (mat4x4_t m, vec4_t v, vec4_t out); 579 void Matrix4_MultiplyFast (mat4x4_t a, mat4x4_t b, mat4x4_t product); 580 void Matrix4_MultiplyFast2 (const mat4x4_t m1, const mat4x4_t m2, mat4x4_t out); 581 void Matrix4_Rotate (mat4x4_t a, float angle, float x, float y, float z); 582 void Matrix4_Scale (mat4x4_t m, float x, float y, float z); 583 void Matrix4_Translate (mat4x4_t m, float x, float y, float z); 584 void Matrix4_Transpose (mat4x4_t m, mat4x4_t ret); 585 586 // 587 // m_quat.c 588 // 589 void Quat_ConcatTransforms (quat_t q1, vec3_t v1, quat_t q2, vec3_t v2, quat_t q, vec3_t v); 590 void Quat_Copy (quat_t q1, quat_t q2); 591 void Quat_Conjugate (quat_t q1, quat_t q2); 592 void Quat_Identity (quat_t q); 593 mat_t Quat_Inverse (quat_t q1, quat_t q2); 594 mat_t Quat_Normalize (quat_t q); 595 void Quat_Lerp (quat_t q1, quat_t q2, mat_t t, quat_t out); 596 void Quat_Matrix3 (quat_t q, mat3x3_t m); 597 void Quat_Multiply (quat_t q1, quat_t q2, quat_t out); 598 void Quat_TransformVector (quat_t q, vec3_t v, vec3_t out); 599 600 /* 601 ============================================================================== 602 603 PARSING 604 605 ============================================================================== 606 */ 607 608 #define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString 609 #define MAX_STRING_TOKENS 256 // max tokens resulting from Cmd_TokenizeString 610 #define MAX_TOKEN_CHARS 512 // max length of an individual token 611 612 char *Com_Parse (char **dataPtr); 613 void Com_DefaultExtension (char *path, char *extension, size_t size); 614 void Com_FileBase (char *in, char *out); 615 void Com_FileExtension (char *path, char *out, size_t size); 616 void Com_FilePath (char *path, char *out, size_t size); 617 void Com_NormalizePath (char *dest, size_t size, const char *source); 618 char *Com_SkipPath (char *pathname); 619 void Com_SkipRestOfLine (char **dataPtr); 620 char *Com_SkipWhiteSpace (char *dataPtr, qBool *hasNewLines); 621 void Com_StripExtension (char *dest, size_t size, char *src); 622 void Com_StripPadding (char *in, char *dest); 623 624 /* 625 ============================================================================== 626 627 COLOR STRING HANDLING 628 629 ============================================================================== 630 */ 631 632 extern vec4_t Q_colorBlack; 633 extern vec4_t Q_colorRed; 634 extern vec4_t Q_colorGreen; 635 extern vec4_t Q_colorYellow; 636 extern vec4_t Q_colorBlue; 637 extern vec4_t Q_colorCyan; 638 extern vec4_t Q_colorMagenta; 639 extern vec4_t Q_colorWhite; 640 641 extern vec4_t Q_colorLtGrey; 642 extern vec4_t Q_colorMdGrey; 643 extern vec4_t Q_colorDkGrey; 644 645 extern vec4_t Q_strColorTable[10]; 646 647 #define COLOR_ESCAPE '^' 648 649 #define COLOR_BLACK '0' 650 #define COLOR_RED '1' 651 #define COLOR_GREEN '2' 652 #define COLOR_YELLOW '3' 653 #define COLOR_BLUE '4' 654 #define COLOR_CYAN '5' 655 #define COLOR_MAGENTA '6' 656 #define COLOR_WHITE '7' 657 #define COLOR_GREY '8' 658 659 #define STYLE_ITALIC 'I' 660 #define STYLE_RETURN 'R' 661 #define STYLE_SHADOW 'S' 662 663 #define S_COLOR_ESCAPE "^" 664 665 #define S_COLOR_BLACK "^0" 666 #define S_COLOR_RED "^1" 667 #define S_COLOR_GREEN "^2" 668 #define S_COLOR_YELLOW "^3" 669 #define S_COLOR_BLUE "^4" 670 #define S_COLOR_CYAN "^5" 671 #define S_COLOR_MAGENTA "^6" 672 #define S_COLOR_WHITE "^7" 673 #define S_COLOR_GREY "^8" 674 675 #define S_STYLE_ITALIC "^I" 676 #define S_STYLE_RETURN "^R" 677 #define S_STYLE_SHADOW "^S" 678 679 #define Q_StrColorIndex(c) (((c & 127) - '0') % 9) 680 681 qBool Q_IsColorString (const char *p); 682 int Q_ColorCharCount (const char *s, int endPos); 683 int Q_ColorCharOffset (const char *s, int charCount); 684 int Q_ColorStrLastColor (char *s, int byteOfs); 685 int Q_ColorStrLastStyle (char *s, int byteOfs); 686 687 #define COLOR_R(rgba) ((rgba) & 0xFF) 688 #define COLOR_G(rgba) (((rgba) >> 8) & 0xFF) 689 #define COLOR_B(rgba) (((rgba) >> 16) & 0xFF) 690 #define COLOR_A(rgba) (((rgba) >> 24) & 0xFF) 691 #define COLOR_RGB(r,g,b) (((r) << 0)|((g) << 8)|((b) << 16)) 692 #define COLOR_RGBA(r,g,b,a) (((r) << 0)|((g) << 8)|((b) << 16)|((a) << 24)) 693 694 /* 695 ============================================================================== 696 697 STRING RELATED FUNCTIONS 698 699 ============================================================================== 700 */ 701 702 void Q_snprintfz (char *dest, size_t size, const char *fmt, ...); 703 void Q_strcatz (char *dst, const char *src, int dstSize); 704 void Q_strncpyz (char *dest, const char *src, size_t size); 705 706 char *Q_strlwr (char *s); 707 708 #ifdef id386 709 int __cdecl Q_tolower (int c); 710 #else // id386 711 #define Q_tolower(chr) (tolower ((chr))) 712 #endif // id386 713 714 // =========================================================================== 715 716 int Q_WildcardMatch (const char *filter, const char *string, int ignoreCase); 717 char *Q_VarArgs (char *format, ...); 718 719 /* 720 ============================================================================== 721 722 INFO STRINGS 723 724 ============================================================================== 725 */ 726 727 #define MAX_INFO_KEY 64 728 #define MAX_INFO_VALUE 64 729 #define MAX_INFO_STRING 512 730 731 void Info_Print (char *s); 732 char *Info_ValueForKey (char *s, char *key); 733 void Info_RemoveKey (char *s, char *key); 734 void Info_SetValueForKey (char *s, char *key, char *value); 735 qBool Info_Validate (char *s); 736 737 /* 738 ============================================================================== 739 740 BYTE ORDER FUNCTIONS 741 742 ============================================================================== 743 */ 744 745 float LittleFloat (float f); 746 int LittleLong (int l); 747 int16 LittleShort (int16 s); 748 float BigFloat (float f); 749 int BigLong (int l); 750 int16 BigShort (int16 s); 751 752 void Swap_Init (void); 753 754 /* 755 ============================================================================== 756 757 NON-PORTABLE SYSTEM SERVICES 758 759 ============================================================================== 760 */ 761 762 typedef uint32 fileHandle_t; 763 764 #define MAX_QEXT 16 // max length of a quake game pathname extension 765 #define MAX_QPATH 64 // max length of a quake game pathname 766 #define MAX_OSPATH 128 // max length of a filesystem pathname 767 768 // directory searching 769 #define SFF_ARCH 0x01 770 #define SFF_HIDDEN 0x02 771 #define SFF_RDONLY 0x04 772 #define SFF_SUBDIR 0x08 773 #define SFF_SYSTEM 0x10 774 775 // these are used for FS_OpenFile 776 typedef enum fsOpenMode_s { 777 FS_MODE_READ_BINARY, 778 FS_MODE_WRITE_BINARY, 779 FS_MODE_APPEND_BINARY, 780 781 FS_MODE_WRITE_TEXT, 782 FS_MODE_APPEND_TEXT 783 } fsOpenMode_t; 784 785 // these are used for FS_Seek 786 typedef enum fsSeekOrigin_s { 787 FS_SEEK_SET, 788 FS_SEEK_CUR, 789 FS_SEEK_END 790 } fsSeekOrigin_t; 791 792 // for FS_FindFiles 793 #define FS_MAX_FINDFILES 65536 794 795 // 796 // this is only here so the functions in shared/ can link 797 // 798 #define MAX_COMPRINT 4096 799 800 // Com_Printf 801 typedef enum { 802 PRNT_WARNING = 1 << 0, 803 PRNT_ERROR = 1 << 1, 804 PRNT_CONSOLE = 1 << 2, 805 PRNT_CHATHUD = 1 << 3 806 } comPrint_t; 807 void Com_Printf (comPrint_t flags, char *fmt, ...); 808 void Com_DevPrintf (comPrint_t flags, char *fmt, ...); 809 810 // Com_Error 811 typedef enum { 812 ERR_FATAL, // exit the entire game with a popup window 813 ERR_DROP, // print to console and disconnect from game 814 ERR_DISCONNECT // don't kill server 815 } comError_t; 816 void Com_Error (comError_t code, char *fmt, ...); 817 818 // 819 // styles for R_DrawString/Char 820 // 821 enum { 822 FS_ALIGN_CENTER = 1 << 0, 823 FS_ALIGN_RIGHT = 1 << 1, 824 FS_ITALIC = 1 << 2, 825 FS_SECONDARY = 1 << 3, 826 FS_SHADOW = 1 << 4, 827 FS_SQUARE = 1 << 5, // Force the width/height to the character width/height value that's largest 828 }; 829 830 /* 831 ============================================================================== 832 833 CVARS 834 835 Console variables 836 Do NOT modify struct fields, use the functions 837 ============================================================================== 838 */ 839 840 enum { 841 CVAR_ARCHIVE = 1 << 0, // saved to config 842 CVAR_USERINFO = 1 << 1, // added to userinfo when changed 843 CVAR_SERVERINFO = 1 << 2, // added to serverinfo when changed 844 CVAR_READONLY = 1 << 3, // can only be changed when forced through code 845 CVAR_LATCH_SERVER = 1 << 4, // delay changes until server restart 846 CVAR_LATCH_VIDEO = 1 << 5, // delay changes until video restart 847 CVAR_LATCH_AUDIO = 1 << 6, // delay changes until audio restart 848 CVAR_RESET_GAMEDIR = 1 << 7, // reset game dir when this cvar is modified 849 CVAR_CHEAT = 1 << 8, // clamp to the default value when cheats are off 850 }; 851 852 // nothing outside the Cvar_*() functions should modify these fields! 853 typedef struct cVar_s { 854 char *name; 855 char *string; 856 char *latchedString; // for CVAR_LATCH vars 857 int flags; 858 qBool modified; // set each time the cvar is changed 859 float floatVal; 860 861 int intVal; 862 char *defaultString; 863 864 struct cVar_s *hashNext; 865 } cVar_t; 866 867 /* 868 ============================================================================== 869 870 CONTENTS/SURFACE FLAGS 871 872 ============================================================================== 873 */ 874 875 // 876 // lower bits are stronger, and will eat weaker brushes completely 877 // 878 #define CONTENTS_SOLID 1 // an eye is never valid in a solid 879 #define CONTENTS_WINDOW 2 // translucent, but not watery 880 #define CONTENTS_AUX 4 881 #define CONTENTS_LAVA 8 882 #define CONTENTS_SLIME 16 883 #define CONTENTS_WATER 32 884 #define CONTENTS_MIST 64 885 886 // Q3BSP 887 #define CONTENTS_FOG 64 888 // !Q3BSP 889 890 // 891 // remaining contents are non-visible, and don't eat brushes 892 // 893 #define CONTENTS_AREAPORTAL 0x8000 894 895 #define CONTENTS_PLAYERCLIP 0x10000 896 #define CONTENTS_MONSTERCLIP 0x20000 897 898 // 899 // currents can be added to any other contents, and may be mixed 900 // 901 #define CONTENTS_CURRENT_0 0x40000 902 #define CONTENTS_CURRENT_90 0x80000 903 #define CONTENTS_CURRENT_180 0x100000 904 #define CONTENTS_CURRENT_270 0x200000 905 #define CONTENTS_CURRENT_UP 0x400000 906 #define CONTENTS_CURRENT_DOWN 0x800000 907 908 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity 909 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game 910 #define CONTENTS_DEADMONSTER 0x4000000 911 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs 912 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans 913 #define CONTENTS_LADDER 0x20000000 914 915 // Q3BSP 916 #define Q3CNTNTS_TELEPORTER 0x40000 917 #define Q3CNTNTS_JUMPPAD 0x80000 918 #define Q3CNTNTS_CLUSTERPORTAL 0x100000 919 #define Q3CNTNTS_DONOTENTER 0x200000 920 921 #define Q3CNTNTS_ORIGIN 0x1000000 // removed before bsping an entity 922 923 #define Q3CNTNTS_BODY 0x2000000 // should never be on a brush, only in game 924 #define Q3CNTNTS_CORPSE 0x4000000 925 #define Q3CNTNTS_DETAIL 0x8000000 // brushes not used for the bsp 926 #define Q3CNTNTS_STRUCTURAL 0x10000000 // brushes used for the bsp 927 #define Q3CNTNTS_TRANSLUCENT 0x20000000 // don't consume surface fragments inside 928 #define Q3CNTNTS_TRIGGER 0x40000000 929 #define Q3CNTNTS_NODROP 0x80000000 // don't leave bodies or items (death fog, lava) 930 // !Q3BSP 931 932 // 933 // content masks 934 // 935 #define MASK_ALL (-1) 936 #define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW) 937 #define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER) 938 #define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW) 939 #define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER) 940 #define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME) 941 #define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA) 942 #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER) 943 #define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN) 944 945 946 #define SURF_TEXINFO_LIGHT 0x1 // value will hold the light strength 947 #define SURF_TEXINFO_SLICK 0x2 // effects game physics 948 #define SURF_TEXINFO_SKY 0x4 // don't draw, but add to skybox 949 #define SURF_TEXINFO_WARP 0x8 // turbulent water warp 950 #define SURF_TEXINFO_TRANS33 0x10 951 #define SURF_TEXINFO_TRANS66 0x20 952 #define SURF_TEXINFO_FLOWING 0x40 // scroll towards angle 953 #define SURF_TEXINFO_NODRAW 0x80 // don't bother referencing the texture 954 955 #define SURF_TEXINFO_HINT 0x100 // these aren't known to the engine I believe 956 #define SURF_TEXINFO_SKIP 0x200 // only the compiler uses them 957 958 // Q3BSP 959 #define SHREF_NODAMAGE 0x1 // never give falling damage 960 #define SHREF_SLICK 0x2 // effects game physics 961 #define SHREF_SKY 0x4 // lighting from environment map 962 #define SHREF_LADDER 0x8 963 #define SHREF_NOIMPACT 0x10 // don't make missile explosions 964 #define SHREF_NOMARKS 0x20 // don't leave missile marks 965 #define SHREF_FLESH 0x40 // make flesh sounds and effects 966 #define SHREF_NODRAW 0x80 // don't generate a drawsurface at all 967 #define SHREF_HINT 0x100 // make a primary bsp splitter 968 #define SHREF_SKIP 0x200 // completely ignore, allowing non-closed brushes 969 #define SHREF_NOLIGHTMAP 0x400 // surface doesn't need a lightmap 970 #define SHREF_POINTLIGHT 0x800 // generate lighting info at vertexes 971 #define SHREF_METALSTEPS 0x1000 // clanking footsteps 972 #define SHREF_NOSTEPS 0x2000 // no footstep sounds 973 #define SHREF_NONSOLID 0x4000 // don't collide against curves with this set 974 #define SHREF_LIGHTFILTER 0x8000 // act as a light filter during q3map -light 975 #define SHREF_ALPHASHADOW 0x10000 // do per-pixel light shadow casting in q3map 976 #define SHREF_NODLIGHT 0x20000 // never add dynamic lights 977 #define SHREF_DUST 0x40000 // leave a dust trail when walking on this surface 978 // !Q3BSP 979 980 // 981 // gi.BoxEdicts() can return a list of either solid or trigger entities 982 // 983 #define AREA_SOLID 1 984 #define AREA_TRIGGERS 2 985 986 /* 987 ============================================================================== 988 989 CMODEL/PLANE 990 991 ============================================================================== 992 */ 993 994 // 0-2 are axial planes 995 #define PLANE_X 0 996 #define PLANE_Y 1 997 #define PLANE_Z 2 998 #define PLANE_NON_AXIAL 3 999 1000 // 3-5 are non-axial planes snapped to the nearest 1001 #define PLANE_ANYX 3 1002 #define PLANE_ANYY 4 1003 #define PLANE_ANYZ 5 1004 1005 typedef struct cBspPlane_s { 1006 vec3_t normal; 1007 float dist; 1008 byte type; // for fast side tests 1009 byte signBits; // signx + (signy<<1) + (signz<<1) 1010 } cBspPlane_t; 1011 1012 typedef struct cBspSurface_s { 1013 char name[16]; 1014 int flags; 1015 int value; 1016 1017 // Q3BSP 1018 int contents; 1019 } cBspSurface_t; 1020 1021 // A trace is returned when a box is swept through the world 1022 typedef struct trace_s { 1023 qBool allSolid; // if true, plane is not valid 1024 qBool startSolid; // if true, the initial point was in a solid area 1025 float fraction; // time completed, 1.0 = didn't hit anything 1026 vec3_t endPos; // final position 1027 cBspPlane_t plane; // surface normal at impact 1028 cBspSurface_t *surface; // surface hit 1029 int contents; // contents on other side of surface hit 1030 struct edict_s *ent; // not set by CM_*() functions 1031 } trace_t; 1032 1033 // 1034 // m_plane.c 1035 // 1036 #define PlaneDiff(point,plane) (((plane)->type < 3 ? (point)[(plane)->type] : DotProduct((point), (plane)->normal)) - (plane)->dist) 1037 #define BOX_ON_PLANE_SIDE(mins, maxs, p) \ 1038 (((p)->type < 3)? ( \ 1039 ((p)->dist <= (mins)[(p)->type])? 1 : \ 1040 ( \ 1041 ((p)->dist >= (maxs)[(p)->type])? 2 : 3 \ 1042 ) \ 1043 ) : BoxOnPlaneSide((mins), (maxs), (p))) 1044 1045 int BoxOnPlaneSide (vec3_t mins, vec3_t maxs, cBspPlane_t *plane); 1046 int PlaneTypeForNormal (vec3_t normal); 1047 void CategorizePlane (cBspPlane_t *plane); 1048 void PlaneFromPoints (vec3_t verts[3], cBspPlane_t *plane); 1049 qBool ComparePlanes (const vec3_t p1normal, float p1dist, const vec3_t p2normal, float p2dist); 1050 void SnapVector (vec3_t normal); 1051 void ProjectPointOnPlane (vec3_t dst, vec3_t p, vec3_t normal); 1052 int SignbitsForPlane (cBspPlane_t *out); 1053 1054 /* 1055 ============================================================================== 1056 1057 PREDICTION 1058 1059 ============================================================================== 1060 */ 1061 1062 // pMoveState_t is the information necessary for client side movement prediction 1063 enum { 1064 // can accelerate and turn 1065 PMT_NORMAL, 1066 PMT_SPECTATOR, 1067 // no acceleration or turning 1068 PMT_DEAD, 1069 PMT_GIB, // different bounding box 1070 PMT_FREEZE 1071 }; 1072 1073 // pmove->pmFlags 1074 enum { 1075 PMF_DUCKED = 1 << 0, 1076 PMF_JUMP_HELD = 1 << 1, 1077 PMF_ON_GROUND = 1 << 2, 1078 PMF_TIME_WATERJUMP = 1 << 3, // pm_time is waterjump 1079 PMF_TIME_LAND = 1 << 4, // pm_time is time before rejump 1080 PMF_TIME_TELEPORT = 1 << 5, // pm_time is non-moving time 1081 PMF_NO_PREDICTION = 1 << 6 // temporarily disables prediction (used for grappling hook) 1082 }; 1083 1084 // this structure needs to be communicated bit-accurate 1085 // from the server to the client to guarantee that 1086 // prediction stays in sync, so no floats are used. 1087 // if any part of the game code modifies this struct, it 1088 // will result in a prediction error of some degree. 1089 typedef struct pMoveState_s { 1090 int pmType; 1091 1092 int16 origin[3]; // 12.3 1093 int16 velocity[3]; // 12.3 1094 byte pmFlags; // ducked, jump_held, etc 1095 byte pmTime; // each unit = 8 ms 1096 int16 gravity; 1097 int16 deltaAngles[3]; // add to command angles to get view direction 1098 // changed by spawns, rotating objects, and teleporters 1099 } pMoveState_t; 1100 1101 // 1102 // button bits 1103 // 1104 #define BUTTON_ATTACK 1 1105 #define BUTTON_USE 2 1106 #define BUTTON_ANY 128 // any key whatsoever 1107 1108 // userCmd_t is sent to the server each client frame 1109 typedef struct userCmd_s { 1110 byte msec; 1111 byte buttons; 1112 1113 int16 angles[3]; 1114 1115 int16 forwardMove; 1116 int16 sideMove; 1117 int16 upMove; 1118 1119 byte impulse; // remove? 1120 byte lightLevel; // light level the player is standing on 1121 } userCmd_t; 1122 1123 1124 #define MAXTOUCH 32 1125 typedef struct pMove_s { 1126 // state (in / out) 1127 pMoveState_t state; 1128 1129 // command (in) 1130 userCmd_t cmd; 1131 qBool snapInitial; // if s has been changed outside pmove 1132 1133 // results (out) 1134 int numTouch; 1135 struct edict_s *touchEnts[MAXTOUCH]; 1136 1137 vec3_t viewAngles; // clamped 1138 float viewHeight; 1139 1140 vec3_t mins, maxs; // bounding box size 1141 1142 struct edict_s *groundEntity; 1143 int waterType; 1144 int waterLevel; 1145 1146 // callbacks to test the world 1147 trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); 1148 int (*pointContents) (vec3_t point); 1149 } pMove_t; 1150 1151 typedef struct pMoveNew_s { 1152 // state (in / out) 1153 pMoveState_t state; 1154 1155 // command (in) 1156 userCmd_t cmd; 1157 qBool snapInitial; // if s has been changed outside pmove 1158 1159 // results (out) 1160 int numTouch; 1161 struct edict_s *touchEnts[MAXTOUCH]; 1162 1163 vec3_t viewAngles; // clamped 1164 float viewHeight; 1165 1166 vec3_t mins, maxs; // bounding box size 1167 1168 struct edict_s *groundEntity; 1169 int waterType; 1170 int waterLevel; 1171 1172 // callbacks to test the world 1173 trace_t (*trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); 1174 int (*pointContents) (vec3_t point); 1175 1176 float multiplier; 1177 qBool strafeHack; 1178 qBool step; 1179 } pMoveNew_t; 1180 1181 /* 1182 ============================================================================== 1183 1184 ENTITY FX 1185 1186 ============================================================================== 1187 */ 1188 1189 // entityState_t->effects 1190 // Effects are things handled on the client side (lights, particles, frame 1191 // animations) that happen constantly on the given entity. An entity that has 1192 // effects will be sent to the client even if it has a zero index model. 1193 #define EF_ROTATE 0x00000001 // rotate (bonus items) 1194 #define EF_GIB 0x00000002 // leave a trail 1195 #define EF_BLASTER 0x00000008 // redlight + trail 1196 #define EF_ROCKET 0x00000010 // redlight + trail 1197 #define EF_GRENADE 0x00000020 1198 #define EF_HYPERBLASTER 0x00000040 1199 #define EF_BFG 0x00000080 1200 #define EF_COLOR_SHELL 0x00000100 1201 #define EF_POWERSCREEN 0x00000200 1202 #define EF_ANIM01 0x00000400 // automatically cycle between frames 0 and 1 at 2 hz 1203 #define EF_ANIM23 0x00000800 // automatically cycle between frames 2 and 3 at 2 hz 1204 #define EF_ANIM_ALL 0x00001000 // automatically cycle through all frames at 2hz 1205 #define EF_ANIM_ALLFAST 0x00002000 // automatically cycle through all frames at 10hz 1206 #define EF_FLIES 0x00004000 1207 #define EF_QUAD 0x00008000 1208 #define EF_PENT 0x00010000 1209 #define EF_TELEPORTER 0x00020000 // particle fountain 1210 #define EF_FLAG1 0x00040000 1211 #define EF_FLAG2 0x00080000 1212 1213 // RAFAEL 1214 #define EF_IONRIPPER 0x00100000 1215 #define EF_GREENGIB 0x00200000 1216 #define EF_BLUEHYPERBLASTER 0x00400000 1217 #define EF_SPINNINGLIGHTS 0x00800000 1218 #define EF_PLASMA 0x01000000 1219 #define EF_TRAP 0x02000000 1220 1221 // ROGUE 1222 #define EF_TRACKER 0x04000000 1223 #define EF_DOUBLE 0x08000000 1224 #define EF_SPHERETRANS 0x10000000 1225 #define EF_TAGTRAIL 0x20000000 1226 #define EF_HALF_DAMAGE 0x40000000 1227 #define EF_TRACKERTRAIL 0x80000000 1228 1229 /* 1230 ============================================================================== 1231 1232 RENDERFX 1233 1234 ============================================================================== 1235 */ 1236 1237 // entityState_t->renderfx flags 1238 #define RF_MINLIGHT 1 // allways have some light (viewmodel) 1239 #define RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors 1240 #define RF_WEAPONMODEL 4 // only draw through eyes 1241 #define RF_FULLBRIGHT 8 // allways draw full intensity 1242 #define RF_DEPTHHACK 16 // for view weapon Z crunching 1243 #define RF_TRANSLUCENT 32 1244 #define RF_FRAMELERP 64 1245 #define RF_BEAM 128 1246 #define RF_CUSTOMSKIN 256 // skin is an index in image_precache 1247 #define RF_GLOW 512 // pulse lighting for bonus items 1248 1249 #define RF_SHELL_RED 1024 1250 #define RF_SHELL_GREEN 2048 1251 #define RF_SHELL_BLUE 4096 1252 1253 #define RF_IR_VISIBLE 0x00008000 // 32768 1254 #define RF_SHELL_DOUBLE 0x00010000 // 65536 1255 #define RF_SHELL_HALF_DAM 0x00020000 1256 #define RF_USE_DISGUISE 0x00040000 1257 1258 #define RF_NOSHADOW 0x00080000 1259 #define RF_CULLHACK 0x00100000 1260 #define RF_FORCENOLOD 0x00200000 1261 #define RF_SHELLMASK (RF_SHELL_HALF_DAM|RF_SHELL_DOUBLE|RF_SHELL_RED|RF_SHELL_GREEN|RF_SHELL_BLUE) 1262 1263 /* 1264 ============================================================================== 1265 1266 MUZZLE FLASHES 1267 1268 ============================================================================== 1269 */ 1270 1271 // muzzle flashes / player effects 1272 enum { 1273 MZ_BLASTER, 1274 MZ_MACHINEGUN, 1275 MZ_SHOTGUN, 1276 MZ_CHAINGUN1, 1277 MZ_CHAINGUN2, 1278 MZ_CHAINGUN3, 1279 MZ_RAILGUN, 1280 MZ_ROCKET, 1281 MZ_GRENADE, 1282 MZ_LOGIN, 1283 MZ_LOGOUT, 1284 MZ_RESPAWN, 1285 MZ_BFG, 1286 MZ_SSHOTGUN, 1287 MZ_HYPERBLASTER, 1288 MZ_ITEMRESPAWN, 1289 1290 // RAFAEL 1291 MZ_IONRIPPER, 1292 MZ_BLUEHYPERBLASTER, 1293 MZ_PHALANX, 1294 MZ_SILENCED = 128, // bit flag ORed with one of the above numbers 1295 1296 // ROGUE 1297 MZ_ETF_RIFLE = 30, 1298 MZ_UNUSED, 1299 MZ_SHOTGUN2, 1300 MZ_HEATBEAM, 1301 MZ_BLASTER2, 1302 MZ_TRACKER, 1303 MZ_NUKE1, 1304 MZ_NUKE2, 1305 MZ_NUKE4, 1306 MZ_NUKE8 1307 // ROGUE 1308 }; 1309 1310 // monster muzzle flashes 1311 1312 extern vec3_t dumb_and_hacky_monster_MuzzFlashOffset []; 1313 1314 enum { 1315 MZ2_TANK_BLASTER_1 = 1, 1316 MZ2_TANK_BLASTER_2, 1317 MZ2_TANK_BLASTER_3, 1318 MZ2_TANK_MACHINEGUN_1, 1319 MZ2_TANK_MACHINEGUN_2, 1320 MZ2_TANK_MACHINEGUN_3, 1321 MZ2_TANK_MACHINEGUN_4, 1322 MZ2_TANK_MACHINEGUN_5, 1323 MZ2_TANK_MACHINEGUN_6, 1324 MZ2_TANK_MACHINEGUN_7, 1325 MZ2_TANK_MACHINEGUN_8, 1326 MZ2_TANK_MACHINEGUN_9, 1327 MZ2_TANK_MACHINEGUN_10, 1328 MZ2_TANK_MACHINEGUN_11, 1329 MZ2_TANK_MACHINEGUN_12, 1330 MZ2_TANK_MACHINEGUN_13, 1331 MZ2_TANK_MACHINEGUN_14, 1332 MZ2_TANK_MACHINEGUN_15, 1333 MZ2_TANK_MACHINEGUN_16, 1334 MZ2_TANK_MACHINEGUN_17, 1335 MZ2_TANK_MACHINEGUN_18, 1336 MZ2_TANK_MACHINEGUN_19, 1337 MZ2_TANK_ROCKET_1, 1338 MZ2_TANK_ROCKET_2, 1339 MZ2_TANK_ROCKET_3, 1340 1341 MZ2_INFANTRY_MACHINEGUN_1, 1342 MZ2_INFANTRY_MACHINEGUN_2, 1343 MZ2_INFANTRY_MACHINEGUN_3, 1344 MZ2_INFANTRY_MACHINEGUN_4, 1345 MZ2_INFANTRY_MACHINEGUN_5, 1346 MZ2_INFANTRY_MACHINEGUN_6, 1347 MZ2_INFANTRY_MACHINEGUN_7, 1348 MZ2_INFANTRY_MACHINEGUN_8, 1349 MZ2_INFANTRY_MACHINEGUN_9, 1350 MZ2_INFANTRY_MACHINEGUN_10, 1351 MZ2_INFANTRY_MACHINEGUN_11, 1352 MZ2_INFANTRY_MACHINEGUN_12, 1353 MZ2_INFANTRY_MACHINEGUN_13, 1354 1355 MZ2_SOLDIER_BLASTER_1, 1356 MZ2_SOLDIER_BLASTER_2, 1357 MZ2_SOLDIER_SHOTGUN_1, 1358 MZ2_SOLDIER_SHOTGUN_2, 1359 MZ2_SOLDIER_MACHINEGUN_1, 1360 MZ2_SOLDIER_MACHINEGUN_2, 1361 1362 MZ2_GUNNER_MACHINEGUN_1, 1363 MZ2_GUNNER_MACHINEGUN_2, 1364 MZ2_GUNNER_MACHINEGUN_3, 1365 MZ2_GUNNER_MACHINEGUN_4, 1366 MZ2_GUNNER_MACHINEGUN_5, 1367 MZ2_GUNNER_MACHINEGUN_6, 1368 MZ2_GUNNER_MACHINEGUN_7, 1369 MZ2_GUNNER_MACHINEGUN_8, 1370 MZ2_GUNNER_GRENADE_1, 1371 MZ2_GUNNER_GRENADE_2, 1372 MZ2_GUNNER_GRENADE_3, 1373 MZ2_GUNNER_GRENADE_4, 1374 1375 MZ2_CHICK_ROCKET_1, 1376 1377 MZ2_FLYER_BLASTER_1, 1378 MZ2_FLYER_BLASTER_2, 1379 1380 MZ2_MEDIC_BLASTER_1, 1381 1382 MZ2_GLADIATOR_RAILGUN_1, 1383 1384 MZ2_HOVER_BLASTER_1, 1385 1386 MZ2_ACTOR_MACHINEGUN_1, 1387 1388 MZ2_SUPERTANK_MACHINEGUN_1, 1389 MZ2_SUPERTANK_MACHINEGUN_2, 1390 MZ2_SUPERTANK_MACHINEGUN_3, 1391 MZ2_SUPERTANK_MACHINEGUN_4, 1392 MZ2_SUPERTANK_MACHINEGUN_5, 1393 MZ2_SUPERTANK_MACHINEGUN_6, 1394 MZ2_SUPERTANK_ROCKET_1, 1395 MZ2_SUPERTANK_ROCKET_2, 1396 MZ2_SUPERTANK_ROCKET_3, 1397 1398 MZ2_BOSS2_MACHINEGUN_L1, 1399 MZ2_BOSS2_MACHINEGUN_L2, 1400 MZ2_BOSS2_MACHINEGUN_L3, 1401 MZ2_BOSS2_MACHINEGUN_L4, 1402 MZ2_BOSS2_MACHINEGUN_L5, 1403 MZ2_BOSS2_ROCKET_1, 1404 MZ2_BOSS2_ROCKET_2, 1405 MZ2_BOSS2_ROCKET_3, 1406 MZ2_BOSS2_ROCKET_4, 1407 1408 MZ2_FLOAT_BLASTER_1, 1409 1410 MZ2_SOLDIER_BLASTER_3, 1411 MZ2_SOLDIER_SHOTGUN_3, 1412 MZ2_SOLDIER_MACHINEGUN_3, 1413 MZ2_SOLDIER_BLASTER_4, 1414 MZ2_SOLDIER_SHOTGUN_4, 1415 MZ2_SOLDIER_MACHINEGUN_4, 1416 MZ2_SOLDIER_BLASTER_5, 1417 MZ2_SOLDIER_SHOTGUN_5, 1418 MZ2_SOLDIER_MACHINEGUN_5, 1419 MZ2_SOLDIER_BLASTER_6, 1420 MZ2_SOLDIER_SHOTGUN_6, 1421 MZ2_SOLDIER_MACHINEGUN_6, 1422 MZ2_SOLDIER_BLASTER_7, 1423 MZ2_SOLDIER_SHOTGUN_7, 1424 MZ2_SOLDIER_MACHINEGUN_7, 1425 MZ2_SOLDIER_BLASTER_8, 1426 MZ2_SOLDIER_SHOTGUN_8, 1427 MZ2_SOLDIER_MACHINEGUN_8, 1428 1429 // --- Xian shit below --- 1430 MZ2_MAKRON_BFG, 1431 MZ2_MAKRON_BLASTER_1, 1432 MZ2_MAKRON_BLASTER_2, 1433 MZ2_MAKRON_BLASTER_3, 1434 MZ2_MAKRON_BLASTER_4, 1435 MZ2_MAKRON_BLASTER_5, 1436 MZ2_MAKRON_BLASTER_6, 1437 MZ2_MAKRON_BLASTER_7, 1438 MZ2_MAKRON_BLASTER_8, 1439 MZ2_MAKRON_BLASTER_9, 1440 MZ2_MAKRON_BLASTER_10, 1441 MZ2_MAKRON_BLASTER_11, 1442 MZ2_MAKRON_BLASTER_12, 1443 MZ2_MAKRON_BLASTER_13, 1444 MZ2_MAKRON_BLASTER_14, 1445 MZ2_MAKRON_BLASTER_15, 1446 MZ2_MAKRON_BLASTER_16, 1447 MZ2_MAKRON_BLASTER_17, 1448 MZ2_MAKRON_RAILGUN_1, 1449 MZ2_JORG_MACHINEGUN_L1, 1450 MZ2_JORG_MACHINEGUN_L2, 1451 MZ2_JORG_MACHINEGUN_L3, 1452 MZ2_JORG_MACHINEGUN_L4, 1453 MZ2_JORG_MACHINEGUN_L5, 1454 MZ2_JORG_MACHINEGUN_L6, 1455 MZ2_JORG_MACHINEGUN_R1, 1456 MZ2_JORG_MACHINEGUN_R2, 1457 MZ2_JORG_MACHINEGUN_R3, 1458 MZ2_JORG_MACHINEGUN_R4, 1459 MZ2_JORG_MACHINEGUN_R5, 1460 MZ2_JORG_MACHINEGUN_R6, 1461 MZ2_JORG_BFG_1, 1462 MZ2_BOSS2_MACHINEGUN_R1, 1463 MZ2_BOSS2_MACHINEGUN_R2, 1464 MZ2_BOSS2_MACHINEGUN_R3, 1465 MZ2_BOSS2_MACHINEGUN_R4, 1466 MZ2_BOSS2_MACHINEGUN_R5, 1467 1468 // ROGUE 1469 MZ2_CARRIER_MACHINEGUN_L1, 1470 MZ2_CARRIER_MACHINEGUN_R1, 1471 MZ2_CARRIER_GRENADE, 1472 MZ2_TURRET_MACHINEGUN, 1473 MZ2_TURRET_ROCKET, 1474 MZ2_TURRET_BLASTER, 1475 MZ2_STALKER_BLASTER, 1476 MZ2_DAEDALUS_BLASTER, 1477 MZ2_MEDIC_BLASTER_2, 1478 MZ2_CARRIER_RAILGUN, 1479 MZ2_WIDOW_DISRUPTOR, 1480 MZ2_WIDOW_BLASTER, 1481 MZ2_WIDOW_RAIL, 1482 MZ2_WIDOW_PLASMABEAM, // PMM - not used 1483 MZ2_CARRIER_MACHINEGUN_L2, 1484 MZ2_CARRIER_MACHINEGUN_R2, 1485 MZ2_WIDOW_RAIL_LEFT, 1486 MZ2_WIDOW_RAIL_RIGHT, 1487 MZ2_WIDOW_BLASTER_SWEEP1, 1488 MZ2_WIDOW_BLASTER_SWEEP2, 1489 MZ2_WIDOW_BLASTER_SWEEP3, 1490 MZ2_WIDOW_BLASTER_SWEEP4, 1491 MZ2_WIDOW_BLASTER_SWEEP5, 1492 MZ2_WIDOW_BLASTER_SWEEP6, 1493 MZ2_WIDOW_BLASTER_SWEEP7, 1494 MZ2_WIDOW_BLASTER_SWEEP8, 1495 MZ2_WIDOW_BLASTER_SWEEP9, 1496 MZ2_WIDOW_BLASTER_100, 1497 MZ2_WIDOW_BLASTER_90, 1498 MZ2_WIDOW_BLASTER_80, 1499 MZ2_WIDOW_BLASTER_70, 1500 MZ2_WIDOW_BLASTER_60, 1501 MZ2_WIDOW_BLASTER_50, 1502 MZ2_WIDOW_BLASTER_40, 1503 MZ2_WIDOW_BLASTER_30, 1504 MZ2_WIDOW_BLASTER_20, 1505 MZ2_WIDOW_BLASTER_10, 1506 MZ2_WIDOW_BLASTER_0, 1507 MZ2_WIDOW_BLASTER_10L, 1508 MZ2_WIDOW_BLASTER_20L, 1509 MZ2_WIDOW_BLASTER_30L, 1510 MZ2_WIDOW_BLASTER_40L, 1511 MZ2_WIDOW_BLASTER_50L, 1512 MZ2_WIDOW_BLASTER_60L, 1513 MZ2_WIDOW_BLASTER_70L, 1514 MZ2_WIDOW_RUN_1, 1515 MZ2_WIDOW_RUN_2, 1516 MZ2_WIDOW_RUN_3, 1517 MZ2_WIDOW_RUN_4, 1518 MZ2_WIDOW_RUN_5, 1519 MZ2_WIDOW_RUN_6, 1520 MZ2_WIDOW_RUN_7, 1521 MZ2_WIDOW_RUN_8, 1522 MZ2_CARRIER_ROCKET_1, 1523 MZ2_CARRIER_ROCKET_2, 1524 MZ2_CARRIER_ROCKET_3, 1525 MZ2_CARRIER_ROCKET_4, 1526 MZ2_WIDOW2_BEAMER_1, 1527 MZ2_WIDOW2_BEAMER_2, 1528 MZ2_WIDOW2_BEAMER_3, 1529 MZ2_WIDOW2_BEAMER_4, 1530 MZ2_WIDOW2_BEAMER_5, 1531 MZ2_WIDOW2_BEAM_SWEEP_1, 1532 MZ2_WIDOW2_BEAM_SWEEP_2, 1533 MZ2_WIDOW2_BEAM_SWEEP_3, 1534 MZ2_WIDOW2_BEAM_SWEEP_4, 1535 MZ2_WIDOW2_BEAM_SWEEP_5, 1536 MZ2_WIDOW2_BEAM_SWEEP_6, 1537 MZ2_WIDOW2_BEAM_SWEEP_7, 1538 MZ2_WIDOW2_BEAM_SWEEP_8, 1539 MZ2_WIDOW2_BEAM_SWEEP_9, 1540 MZ2_WIDOW2_BEAM_SWEEP_10, 1541 MZ2_WIDOW2_BEAM_SWEEP_11 1542 // ROGUE 1543 }; 1544 1545 /* 1546 ============================================================================== 1547 1548 TEMP ENTITY EVENTS 1549 1550 ============================================================================== 1551 */ 1552 1553 // Temp entity events are for things that happen at a location seperate from 1554 // any existing entity. Temporary entity messages are explicitly constructed 1555 // and broadcast. 1556 enum { 1557 TE_GUNSHOT, 1558 TE_BLOOD, 1559 TE_BLASTER, 1560 TE_RAILTRAIL, 1561 TE_SHOTGUN, 1562 TE_EXPLOSION1, 1563 TE_EXPLOSION2, 1564 TE_ROCKET_EXPLOSION, 1565 TE_GRENADE_EXPLOSION, 1566 TE_SPARKS, 1567 TE_SPLASH, 1568 TE_BUBBLETRAIL, 1569 TE_SCREEN_SPARKS, 1570 TE_SHIELD_SPARKS, 1571 TE_BULLET_SPARKS, 1572 TE_LASER_SPARKS, 1573 TE_PARASITE_ATTACK, 1574 TE_ROCKET_EXPLOSION_WATER, 1575 TE_GRENADE_EXPLOSION_WATER, 1576 TE_MEDIC_CABLE_ATTACK, 1577 TE_BFG_EXPLOSION, 1578 TE_BFG_BIGEXPLOSION, 1579 TE_BOSSTPORT, 1580 TE_BFG_LASER, 1581 TE_GRAPPLE_CABLE, 1582 TE_WELDING_SPARKS, 1583 TE_GREENBLOOD, 1584 TE_BLUEHYPERBLASTER, 1585 TE_PLASMA_EXPLOSION, 1586 TE_TUNNEL_SPARKS, 1587 1588 //ROGUE 1589 TE_BLASTER2, 1590 TE_RAILTRAIL2, 1591 TE_FLAME, 1592 TE_LIGHTNING, 1593 TE_DEBUGTRAIL, 1594 TE_PLAIN_EXPLOSION, 1595 TE_FLASHLIGHT, 1596 TE_FORCEWALL, 1597 TE_HEATBEAM, 1598 TE_MONSTER_HEATBEAM, 1599 TE_STEAM, 1600 TE_BUBBLETRAIL2, 1601 TE_MOREBLOOD, 1602 TE_HEATBEAM_SPARKS, 1603 TE_HEATBEAM_STEAM, 1604 TE_CHAINFIST_SMOKE, 1605 TE_ELECTRIC_SPARKS, 1606 TE_TRACKER_EXPLOSION, 1607 TE_TELEPORT_EFFECT, 1608 TE_DBALL_GOAL, 1609 TE_WIDOWBEAMOUT, 1610 TE_NUKEBLAST, 1611 TE_WIDOWSPLASH, 1612 TE_EXPLOSION1_BIG, 1613 TE_EXPLOSION1_NP, 1614 TE_FLECHETTE 1615 //ROGUE 1616 }; 1617 1618 // TE_SPLASH effects 1619 enum { 1620 SPLASH_UNKNOWN, 1621 SPLASH_SPARKS, 1622 SPLASH_BLUE_WATER, 1623 SPLASH_BROWN_WATER, 1624 SPLASH_SLIME, 1625 SPLASH_LAVA, 1626 SPLASH_BLOOD 1627 }; 1628 1629 /* 1630 ============================================================================== 1631 1632 SOUND 1633 1634 ============================================================================== 1635 */ 1636 1637 // 1638 // sound channels 1639 // channel 0 never willingly overrides other channels (1-7) allways override 1640 // a playing sound on that channel 1641 // 1642 typedef enum entChannel_s { 1643 CHAN_AUTO, 1644 CHAN_WEAPON, 1645 CHAN_VOICE, 1646 CHAN_ITEM, 1647 CHAN_BODY, 1648 1649 // modifier flags 1650 CHAN_NO_PHS_ADD = 8, // send to all clients, not just ones in PHS (ATTN 0 will also do this) 1651 CHAN_RELIABLE = 16 // send by reliable message, not datagram 1652 } entChannel_t; 1653 1654 // 1655 // sound attenuation values 1656 // 1657 enum { 1658 ATTN_NONE, // full volume the entire level 1659 ATTN_NORM, 1660 ATTN_IDLE, 1661 ATTN_STATIC // diminish very rapidly with distance 1662 }; 1663 1664 /* 1665 ============================================================================== 1666 1667 DEATHMATCH FLAGS 1668 1669 ============================================================================== 1670 */ 1671 1672 // dmflags->floatVal flags 1673 #define DF_NO_HEALTH 0x00000001 // 1 1674 #define DF_NO_ITEMS 0x00000002 // 2 1675 #define DF_WEAPONS_STAY 0x00000004 // 4 1676 #define DF_NO_FALLING 0x00000008 // 8 1677 #define DF_INSTANT_ITEMS 0x00000010 // 16 1678 #define DF_SAME_LEVEL 0x00000020 // 32 1679 #define DF_SKINTEAMS 0x00000040 // 64 1680 #define DF_MODELTEAMS 0x00000080 // 128 1681 #define DF_NO_FRIENDLY_FIRE 0x00000100 // 256 1682 #define DF_SPAWN_FARTHEST 0x00000200 // 512 1683 #define DF_FORCE_RESPAWN 0x00000400 // 1024 1684 #define DF_NO_ARMOR 0x00000800 // 2048 1685 #define DF_ALLOW_EXIT 0x00001000 // 4096 1686 #define DF_INFINITE_AMMO 0x00002000 // 8192 1687 #define DF_QUAD_DROP 0x00004000 // 16384 1688 #define DF_FIXED_FOV 0x00008000 // 32768 1689 1690 #define DF_QUADFIRE_DROP 0x00010000 // 65536 1691 1692 #define DF_NO_MINES 0x00020000 1693 #define DF_NO_STACK_DOUBLE 0x00040000 1694 #define DF_NO_NUKES 0x00080000 1695 #define DF_NO_SPHERES 0x00100000 1696 1697 /* 1698 ============================================================================== 1699 1700 CONFIG STRINGS 1701 1702 ============================================================================== 1703 */ 1704 1705 // per-level limits 1706 #define MAX_CS_CLIENTS 256 // absolute limit 1707 #define MAX_CS_EDICTS 1024 // must change protocol to increase more 1708 #define MAX_CS_LIGHTSTYLES 256 1709 #define MAX_CS_MODELS 256 // these are sent over the net as bytes 1710 #define MAX_CS_SOUNDS 256 // so they cannot be blindly increased 1711 #define MAX_CS_IMAGES 256 1712 #define MAX_CS_ITEMS 256 1713 #define MAX_CS_GENERAL (MAX_CS_CLIENTS*2) // general config strings 1714 1715 #define Q2BSP_MAX_AREAS 256 1716 #define MAX_AREA_BITS (Q2BSP_MAX_AREAS/8) 1717 1718 // config strings are a general means of communication from the server to all 1719 // connected clients. Each config string can be at most MAX_CFGSTRLEN characters. 1720 #define CS_NAME 0 1721 #define CS_CDTRACK 1 1722 #define CS_SKY 2 1723 #define CS_SKYAXIS 3 // %f %f %f format 1724 #define CS_SKYROTATE 4 1725 #define CS_STATUSBAR 5 // display program string 1726 1727 #define CS_AIRACCEL 29 // air acceleration control 1728 #define CS_MAXCLIENTS 30 1729 #define CS_MAPCHECKSUM 31 // for catching cheater maps 1730 1731 #define CS_MODELS 32 1732 #define CS_SOUNDS (CS_MODELS+MAX_CS_MODELS) 1733 #define CS_IMAGES (CS_SOUNDS+MAX_CS_SOUNDS) 1734 #define CS_LIGHTS (CS_IMAGES+MAX_CS_IMAGES) 1735 #define CS_ITEMS (CS_LIGHTS+MAX_CS_LIGHTSTYLES) 1736 #define CS_PLAYERSKINS (CS_ITEMS+MAX_CS_ITEMS) 1737 #define CS_GENERAL (CS_PLAYERSKINS+MAX_CS_CLIENTS) 1738 1739 #define MAX_CFGSTRINGS (CS_GENERAL+MAX_CS_GENERAL) 1740 #define MAX_CFGSTRLEN 64 1741 1742 /* 1743 ============================================================================== 1744 1745 ENTITY STATE 1746 1747 ============================================================================== 1748 */ 1749 1750 // entityState_t->event values 1751 // ertity events are for effects that take place reletive to an existing 1752 // entities origin. Very network efficient. All muzzle flashes really should 1753 // be converted to events... 1754 enum { 1755 EV_NONE = 0, 1756 EV_ITEM_RESPAWN, 1757 EV_FOOTSTEP, 1758 EV_FALLSHORT, 1759 EV_FALL, 1760 EV_FALLFAR, 1761 EV_PLAYER_TELEPORT, 1762 EV_OTHER_TELEPORT 1763 }; 1764 1765 // entityState_t is the information conveyed from the server in an update 1766 // message about entities that the client will need to render in some way 1767 typedef struct entityState_s { 1768 int number; // edict index 1769 1770 vec3_t origin; // entity origin or RF_BEAM start origin 1771 vec3_t angles; 1772 vec3_t oldOrigin; // for interpolation or RF_BEAM end origin 1773 1774 // weapons, CTF flags, etc 1775 int modelIndex; 1776 int modelIndex2; 1777 int modelIndex3; 1778 int modelIndex4; 1779 1780 int frame; // also RF_BEAM's size 1781 int skinNum; // also RF_BEAM color index 1782 1783 uint32 effects; // PGM - we're filling it, so it needs to be uint32 1784 int renderFx; 1785 int solid; // for client side prediction, 8*(bits 0-4) is x/y radius 1786 // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up 1787 // gi.linkentity sets this properly 1788 int sound; // for looping sounds, to guarantee shutoff 1789 int event; // impulse events -- muzzle flashes, footsteps, etc 1790 // events only go out for a single frame, they 1791 // are automatically cleared each frame 1792 vec3_t velocity; // for new ENHANCED_PROTOCOL_VERSION 1793 } entityState_t; 1794 1795 typedef struct entityStateOld_s { 1796 int number; // edict index 1797 1798 vec3_t origin; // entity origin or RF_BEAM start origin 1799 vec3_t angles; 1800 vec3_t oldOrigin; // for interpolation or RF_BEAM end origin 1801 1802 // weapons, CTF flags, etc 1803 int modelIndex; 1804 int modelIndex2; 1805 int modelIndex3; 1806 int modelIndex4; 1807 1808 int frame; // also RF_BEAM's size 1809 int skinNum; // also RF_BEAM color index 1810 1811 uint32 effects; // PGM - we're filling it, so it needs to be uint32 1812 int renderFx; 1813 int solid; // for client side prediction, 8*(bits 0-4) is x/y radius 1814 // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up 1815 // gi.linkentity sets this properly 1816 int sound; // for looping sounds, to guarantee shutoff 1817 int event; // impulse events -- muzzle flashes, footsteps, etc 1818 // events only go out for a single frame, they 1819 // are automatically cleared each frame 1820 } entityStateOld_t; 1821 1822 /* 1823 ============================================================================== 1824 1825 PLAYER STATE 1826 1827 ============================================================================== 1828 */ 1829 1830 // playerState->stats[] indexes 1831 enum { 1832 STAT_HEALTH_ICON = 0, 1833 STAT_HEALTH, 1834 STAT_AMMO_ICON, 1835 STAT_AMMO, 1836 STAT_ARMOR_ICON, 1837 STAT_ARMOR, 1838 STAT_SELECTED_ICON, 1839 STAT_PICKUP_ICON, 1840 STAT_PICKUP_STRING, 1841 STAT_TIMER_ICON, 1842 STAT_TIMER, 1843 STAT_HELPICON, 1844 STAT_SELECTED_ITEM, 1845 STAT_LAYOUTS, 1846 STAT_FRAGS, 1847 STAT_FLASHES, // cleared each frame, 1 = health, 2 = armor 1848 STAT_CHASE, 1849 STAT_SPECTATOR, 1850 1851 MAX_STATS = 32 1852 }; 1853 1854 // playerState_t->rdFlags 1855 enum { 1856 RDF_UNDERWATER = 1 << 0, // warp the screen as apropriate 1857 RDF_NOWORLDMODEL = 1 << 1, // used for player configuration screen 1858 RDF_IRGOGGLES = 1 << 2, 1859 RDF_UVGOGGLES = 1 << 3, 1860 }; 1861 1862 // playerState_t is the information needed in addition to pMoveState_t to 1863 // rendered a view. There will only be 10 playerState_t sent each second, but 1864 // the number of pMoveState_t changes will be reletive to client frame rates 1865 typedef struct playerStateNew_s { 1866 pMoveState_t pMove; // for prediction 1867 1868 // these fields do not need to be communicated bit-precise 1869 vec3_t viewAngles; // for fixed views 1870 vec3_t viewOffset; // add to pmovestate->origin 1871 vec3_t kickAngles; // add to view direction to get render angles 1872 // set by weapon kicks, pain effects, etc 1873 vec3_t gunAngles; 1874 vec3_t gunOffset; 1875 int gunIndex; 1876 int gunFrame; 1877 1878 float viewBlend[4]; // rgba full screen effect 1879 1880 float fov; // horizontal field of view 1881 1882 int rdFlags; // refdef flags 1883 1884 int16 stats[MAX_STATS]; // fast status bar updates 1885 1886 vec3_t mins; 1887 vec3_t maxs; 1888 } playerStateNew_t; 1889 1890 typedef struct playerState_s { 1891 pMoveState_t pMove; // for prediction 1892 1893 // these fields do not need to be communicated bit-precise 1894 vec3_t viewAngles; // for fixed views 1895 vec3_t viewOffset; // add to pmovestate->origin 1896 vec3_t kickAngles; // add to view direction to get render angles 1897 // set by weapon kicks, pain effects, etc 1898 vec3_t gunAngles; 1899 vec3_t gunOffset; 1900 int gunIndex; 1901 int gunFrame; 1902 1903 float viewBlend[4]; // rgba full screen effect 1904 1905 float fov; // horizontal field of view 1906 1907 int rdFlags; // refdef flags 1908 1909 int16 stats[MAX_STATS]; // fast status bar updates 1910 } playerState_t; 1911 1912 #endif // __SHARED_H__ 1913