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 FITNESS FOR A PARTICULAR PURPOSE. 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 #ifndef _QSHARED_H 22 23 #include <math.h> 24 #include <stdio.h> 25 #include <stdarg.h> 26 #include <string.h> 27 #include <stdlib.h> 28 #include <stddef.h> 29 #include <string.h> 30 #include <time.h> 31 #include <ctype.h> 32 #ifndef NO_ZLIB 33 #ifdef _WIN32 34 #define ZEXPORT __cdecl 35 #endif 36 #include <zlib.h> 37 #ifdef _WIN32 38 #undef ZEXPORT 39 #endif 40 #endif 41 42 //for broken Makefiles? 43 #ifdef __linux__ 44 #ifndef LINUX 45 #define LINUX 1 46 #endif 47 #endif 48 49 // q_shared.h -- included first by ALL program modules 50 51 #ifdef _WIN32 52 #ifdef _MSC_VER 53 // unknown pragmas are SUPPOSED to be ignored, but.... 54 //#pragma warning(disable : 4244) // MIPS 55 //#pragma warning(disable : 4136) // X86 56 //#pragma warning(disable : 4051) // ALPHA 57 58 //#pragma warning(disable : 4244) // truncation 59 #pragma warning(disable : 4018) // signed/unsigned mismatch 60 //#pragma warning(disable : 4305) // truncation from const double to float 61 62 #pragma warning(disable : 4096) // __cdecl must be used with '...'*/ 63 #pragma warning(disable : 4142) //benign redefinition 64 65 #pragma warning(2 : 4189 4210 4389) // useful warnings 66 67 //"off by default" warnings 68 #pragma warning(3 : 4056) 69 #pragma warning(3 : 4191) 70 #pragma warning(3 : 4254) 71 #pragma warning(3 : 4287) 72 #pragma warning(3 : 4296) 73 #pragma warning(3 : 4514) 74 #pragma warning(3 : 4545) 75 #pragma warning(3 : 4546) 76 #pragma warning(3 : 4547) 77 #pragma warning(3 : 4548) 78 #pragma warning(3 : 4549) 79 #pragma warning(3 : 4555) 80 #pragma warning(3 : 4905) 81 #pragma warning(3 : 4906) 82 #pragma warning(3 : 4245) 83 #endif 84 //#pragma warning(disable: 4996) // deprecated functions 85 86 #pragma intrinsic(memcmp) 87 //#pragma intrinsic(memset) 88 89 #if _MSC_VER >= 1400 90 #define NORETURN __declspec(noreturn) 91 #define RESTRICT __declspec(restrict) 92 #define NOALIAS __declspec(noalias) 93 #else 94 #define RESTRICT 95 #define NORETURN 96 #define NOALIAS 97 #define sqrtf (float)sqrt 98 #define ceilf (float)ceil 99 #endif 100 101 #define alloca _alloca 102 #define snprintf _snprintf 103 #define vsnprintf _vsnprintf 104 #define Q_strlwr _strlwr 105 //#define Q_snprintf _snprintf 106 #define Q_vsnprintf _vsnprintf 107 #ifndef _M_AMD64 108 #define Q_stricmp _strcmpi //odd, amd64 libc is missing this... 109 #define Q_strncasecmp _strnicmp 110 #endif 111 #define strdup _strdup 112 #ifndef fileno 113 #define fileno _fileno 114 #endif 115 #define strlwr _strlwr 116 #define filelength _filelength 117 #define stricmp _stricmp 118 #define putenv _putenv 119 #define EXPORT __cdecl 120 #define IMPORT __cdecl 121 //#if !defined _M_AMD64 122 //#define DEBUGBREAKPOINT __asm int 3 123 //#else 124 //#define DEBUGBREAKPOINT DebugBreak 125 //#endif 126 #define __attribute__(x) 127 #define PACKED_STRUCT 128 typedef __int32 int32; 129 typedef __int16 int16; 130 typedef __int64 int64; 131 typedef unsigned __int32 uint32; 132 typedef unsigned __int16 uint16; 133 typedef unsigned __int64 uint64; 134 #else /* NON-WIN32 */ 135 #include <stdint.h> 136 #define WINAPI 137 #define RESTRICT 138 #define NORETURN 139 #define NOALIAS 140 typedef int32_t int32; 141 typedef int16_t int16; 142 typedef int64_t int64; 143 typedef uint32_t uint32; 144 typedef uint16_t uint16; 145 typedef uint64_t uint64; 146 #define PACKED_STRUCT __attribute__((packed)) 147 //XXX: are these portable enough on non-win32? 148 #define Q_stricmp strcasecmp 149 #define Q_strncasecmp strncasecmp 150 #define EXPORT 151 #define IMPORT 152 void Q_strlwr (char *str); 153 int Q_vsnprintf (char *buff, size_t len, const char *fmt, va_list va); 154 //int Q_snprintf (char *buff, size_t len, const char *fmt, ...); 155 156 #endif 157 158 #if (defined _M_IX86 || defined __i386__) && !defined C_ONLY && !defined __sun__ 159 #define id386 1 160 #else 161 #define id386 0 162 #endif 163 164 #if defined _M_ALPHA && !defined C_ONLY 165 #define idaxp 1 166 #else 167 #define idaxp 0 168 #endif 169 170 #ifdef NDEBUG 171 #define Q_assert(exp) ((void)0) 172 #else 173 void _Q_assert (char *expression, char *function, uint32 line); 174 #define Q_assert(exp) (void)( (exp) || (_Q_assert(#exp, __FILE__, __LINE__), 0) ) 175 #endif 176 177 typedef unsigned char byte; 178 typedef enum {false, true} qboolean; 179 180 //r1: set this to 1 if you have a stupid endian thingy 181 #define Q_BIGENDIAN 0 182 183 //#define random() (randomMT() / ((float)0xFFFFFFFFU)) 184 185 //32 bit float precision caps this to 0.00000000023283064f which gives max result of .99999998407391880 186 #define random() ((randomMT() * 0.00000000023283064f)) 187 188 189 #define frand() (random()) 190 #define crand() (((int)randomMT() - 0x7FFFFFFF) * 0.000000000465661287307739257812f) 191 192 #ifndef NULL 193 #define NULL ((void *)0) 194 #endif 195 196 #ifdef _WIN32 197 #define FLOAT2INTCAST(f)(*((int32 *)(&f))) 198 #define FLOAT2UINTCAST(f)(*((uint32 *)(&f))) 199 #define FLOAT_LT_ZERO(f) (FLOAT2UINTCAST(f) > 0x80000000U) 200 #define FLOAT_LE_ZERO(f) (FLOAT2INTCAST(f) <= 0) 201 #define FLOAT_GT_ZERO(f) (FLOAT2INTCAST(f) > 0) 202 #define FLOAT_GE_ZERO(f) (FLOAT2UINTCAST(f) <= 0x80000000U) 203 #define FLOAT_EQ_ZERO(f) (FLOAT2INTCAST(f) == 0) 204 #define FLOAT_NE_ZERO(f) (FLOAT2INTCAST(f) != 0) 205 #else 206 //gcc breaks ieee compatibility with -ffast-math? i guess since these break horribly on linux 207 #define FLOAT_LT_ZERO(f) ((f) < 0) 208 #define FLOAT_LE_ZERO(f) ((f) <= 0) 209 #define FLOAT_GT_ZERO(f) ((f) > 0) 210 #define FLOAT_GE_ZERO(f) ((f) >= 0) 211 #define FLOAT_EQ_ZERO(f) ((f) == 0) 212 #define FLOAT_NE_ZERO(f) ((f) != 0) 213 #endif 214 215 //terminating strncpy 216 #define Q_strncpy(dst, src, len) \ 217 do { \ 218 strncpy ((dst), (src), (len)); \ 219 (dst)[(len)] = 0; \ 220 } while (0) 221 222 // angle indexes 223 #define PITCH 0 // up / down 224 #define YAW 1 // left / right 225 #define ROLL 2 // fall over 226 227 #define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString 228 #define MAX_STRING_TOKENS 80 // max tokens resulting from Cmd_TokenizeString 229 #define MAX_TOKEN_CHARS 512 // max length of an individual token 230 231 #define MAX_QPATH 64 // max length of a quake game pathname 232 #define MAX_OSPATH 128 // max length of a filesystem pathname 233 234 // 235 // per-level limits 236 // 237 #define MAX_CLIENTS 256 // absolute limit 238 #define MAX_EDICTS 1024 // must change protocol to increase more 239 #define MAX_LIGHTSTYLES 256 240 #define MAX_MODELS 256 // these are sent over the net as bytes 241 #define MAX_SOUNDS 256 // so they cannot be blindly increased 242 #define MAX_IMAGES 256 243 #define MAX_ITEMS 256 244 #define MAX_GENERAL (MAX_CLIENTS*2) // general config strings 245 246 247 // game print flags 248 #define PRINT_LOW 0 // pickup messages 249 #define PRINT_MEDIUM 1 // death messages 250 #define PRINT_HIGH 2 // critical messages 251 #define PRINT_CHAT 3 // chat messages 252 253 #define ERR_FATAL 0 // exit the entire game with a popup window 254 #define ERR_DROP 1 // print to console and disconnect from game 255 #define ERR_DISCONNECT 2 // not an error, just a normal exit 256 #define ERR_GAME 3 // r1ch: game dll error, allow special handling 257 #define ERR_NET 4 // r1ch: network error, don't use net functions after seeing 258 #define ERR_DIE 5 // r1ch: die ASAP. memory corrupt or other super-fatal 259 #define ERR_HARD 6 // r1ch: don't try to auto restart from this error 260 261 #define PRINT_ALL 0 262 #define PRINT_DEVELOPER 1 // only print when "developer 1" 263 #define PRINT_ALERT 2 264 265 266 // destination class for gi.multicast() 267 typedef enum 268 { 269 MULTICAST_ALL, 270 MULTICAST_PHS, 271 MULTICAST_PVS, 272 MULTICAST_ALL_R, 273 MULTICAST_PHS_R, 274 MULTICAST_PVS_R 275 } multicast_t; 276 277 int16 ShortSwap (int16 l); 278 int32 LongSwap (int32 l); 279 280 #if !Q_BIGENDIAN 281 #define LittleShort(l) (l) 282 #define LittleLong(l) (l) 283 #define LittleFloat(l) (l) 284 #endif 285 286 /* 287 ============================================================== 288 289 MATHLIB 290 291 ============================================================== 292 */ 293 294 typedef float vec_t; 295 typedef vec_t vec3_t[3]; 296 typedef vec_t vec5_t[5]; 297 298 typedef int fixed4_t; 299 typedef int fixed8_t; 300 typedef int fixed16_t; 301 302 #ifndef M_PI 303 #define M_PI 3.14159265358979323846F // matches value in gcc v2 math.h 304 #endif 305 306 #define M_PI_DIV_2 1.570796326794896619230F 307 #define M_PI2_DIV_360 0.01745329251994329576922F 308 309 struct cplane_s; 310 311 extern vec3_t vec3_origin; 312 313 #define nanmask (255<<23) 314 315 #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) 316 317 // microsoft's fabs seems to be ungodly slow... 318 //float Q_fabs (float f); 319 //#define fabs(f) Q_fabs(f) 320 //extern int sse2_enabled; 321 #if !defined C_ONLY && !defined __linux__ && !defined __sgi && !defined SSE2 && !defined __FreeBSD__ 322 //extern void __cdecl Q_sseinit (void); 323 void __cdecl Q_ftol2( float f, int *out ); 324 int __cdecl Q_ftol( float f ); 325 extern void __cdecl Q_fastfloats (float *f, int *out); 326 //extern void __cdecl Q_ftolsse( float f, int *out ); 327 //the overhead of using function pointer offsets any savings of using sse2 :/ 328 #else 329 int Q_ftol( float f); 330 void Q_fastfloats(float *f, int *out); 331 void Q_ftol2( float f, int *out ); 332 #endif 333 334 //this is a function instead of a macro for the asm since some compilers are scared by inline asm 335 //and disable some optimizations. 336 void _Q_DEBUGBREAKPOINT (void); 337 338 typedef union 339 { 340 int i[3]; 341 float f[3]; 342 } vectorhack_t; 343 344 #define DotProduct(x,y) (x[0]*y[0]+x[1]*y[1]+x[2]*y[2]) 345 #define VectorSubtract(a,b,c) (c[0]=a[0]-b[0],c[1]=a[1]-b[1],c[2]=a[2]-b[2]) 346 #define VectorAdd(a,b,c) (c[0]=a[0]+b[0],c[1]=a[1]+b[1],c[2]=a[2]+b[2]) 347 #define VectorCopy(src,dst) (dst[0]=src[0],dst[1]=src[1],dst[2]=src[2]) 348 #define FastVectorCopy(src,dst) *(vectorhack_t *)&(dst) = *(vectorhack_t *)&(src) 349 //#define VectorClear(a) (a[0]=a[1]=a[2]=0) 350 //#define VectorClear(a) (memset ((&a), 0, sizeof((a)))) 351 #define VectorClear(a) *(int *)&(a)[0] = 0, *(int *)&(a)[1] = 0, *(int *)&(a)[2] = 0 352 #define VectorNegate(a,b) (b[0]=-a[0],b[1]=-a[1],b[2]=-a[2]) 353 #define VectorSet(v, x, y, z) (v[0]=(x), v[1]=(y), v[2]=(z)) 354 #define VectorAverage(a,b,o) ((o)[0]=((a)[0]+(b)[0])*0.5f,(o)[1]=((a)[1]+(b)[1])*0.5f,(o)[2]=((a)[2]+(b)[2])*0.5f) 355 356 //r1: macorize 357 #define VectorCompare(v1,v2) (v1[0]==v2[0] && v1[1]==v2[1] && v1[2]== v2[2]) 358 #define CrossProduct(v1,v2,c) (c[0]=v1[1]*v2[2]-v1[2]*v2[1],c[1]=v1[2]*v2[0]-v1[0]*v2[2],c[2]=v1[0]*v2[1]-v1[1]*v2[0]) 359 #define VectorInverse(v) (v[0]=-v[0],v[1]=-v[1],v[2]=-v[2]) 360 #define VectorScale(in,s,out) (out[0]=in[0]*(float)(s),out[1]=in[1]*(float)(s),out[2]=in[2]*(float)(s)) 361 #define VectorMA(a,s,b,c) (c[0]=a[0]+(float)(s)*b[0],c[1]=a[1]+(float)(s)*b[1],c[2]=a[2]+(float)(s)*b[2]) 362 #define ClearBounds(mins,maxs) (mins[0]=mins[1]=mins[2]=99999,maxs[0]=maxs[1]=maxs[2]=-99999) 363 364 //performs comparison on encoded byte differences - pointless sending 0.00 -> 0.01 if both end up as 0 on net. 365 #define Vec_ByteCompare(v1,v2) \ 366 ((int)(v1[0]*4)==(int)(v2[0]*4) && \ 367 (int)(v1[1]*4)==(int)(v2[1]*4) && \ 368 (int)(v1[2]*4) == (int)(v2[2]*4)) 369 370 #define Vec_RoughCompare(v1,v2) \ 371 (*(int *)&(v1[0])== *(int *)&(v2[0]) && \ 372 *(int *)&(v1[1]) == *(int *)&(v2[1]) && \ 373 *(int *)&(v1[2]) == *(int *)&(v2[2])) 374 375 #define Float_ByteCompare(v1,v2) \ 376 ((int)((v1)*8)==((int)((v2)*8))) 377 378 #define Float_RoughCompare(v1,v2) \ 379 (*(int *)&(v1) == *(int *)&(v2)) 380 381 #define Float_AngleCompare(v1,v2) \ 382 (((int)((v1)*256/360) & 255) == ((int)((v2)*256/360) & 255)) 383 384 //to keep ms vc auto complete happy 385 #ifdef UNDEFINED 386 void CrossProduct (vec3_t v1, vec3_t v2, vec3_t cross); 387 int VectorCompare (vec3_t v1, vec3_t v2); 388 void VectorInverse (vec3_t v); 389 void VectorScale (vec3_t in, vec_t scale, vec3_t /*@out@*/out); 390 void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t /*@out@*/vecc); 391 void ClearBounds (vec3_t mins, vec3_t maxs); 392 #endif 393 394 //void VectorMA (vec3_t veca, float scale, vec3_t vecb, vec3_t vecc); 395 396 // just in case you do't want to use the macros 397 vec_t _DotProduct (vec3_t v1, vec3_t v2); 398 void _VectorSubtract (vec3_t veca, vec3_t vecb, vec3_t out); 399 void _VectorAdd (vec3_t veca, vec3_t vecb, vec3_t out); 400 void _VectorCopy (vec3_t in, vec3_t out); 401 402 void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs); 403 404 405 vec_t VectorLength (vec3_t v); 406 vec_t VectorNormalize (vec3_t v); // returns vector length 407 vec_t VectorNormalize2 (vec3_t v, vec3_t /*@out@*/out); 408 409 int Q_log2(int val); 410 411 void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]); 412 void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]); 413 414 void AngleVectors (vec3_t angles, vec3_t /*@out@*//*@null@*/forward, vec3_t /*@out@*//*@null@*/right, vec3_t /*@out@*//*@null@*/up); 415 int EXPORT BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane); 416 float anglemod(float a); 417 float LerpAngle (float a1, float a2, float frac); 418 419 #define BOX_ON_PLANE_SIDE(emins, emaxs, p) \ 420 (((p)->type < 3)? \ 421 ( \ 422 ((p)->dist <= (emins)[(p)->type])? \ 423 1 \ 424 : \ 425 ( \ 426 ((p)->dist >= (emaxs)[(p)->type])?\ 427 2 \ 428 : \ 429 3 \ 430 ) \ 431 ) \ 432 : \ 433 BoxOnPlaneSide( (emins), (emaxs), (p))) 434 435 void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); 436 void PerpendicularVector( vec3_t dst, const vec3_t src ); 437 void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); 438 439 440 //============================================= 441 442 char *COM_SkipPath (char *pathname); 443 void COM_StripExtension (const char *in, char *out); 444 void COM_FileBase (char *in, char *out); 445 void COM_FilePath (const char *in, char *out); 446 void COM_DefaultExtension (char *path, const char *extension); 447 448 const char *COM_Parse (char **data_p); 449 // data is an in/out parm, returns a parsed out token 450 451 int Com_sprintf (char /*@out@*/*dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); 452 453 void Com_PageInMemory (byte *buffer, int size); 454 455 int wildcardfit (char *wildcard, char *test); 456 /* this function implements the UN*X wildcards and returns */ 457 /* 0 if *wildcard does not match *test */ 458 /* 1 if *wildcard matches *test */ 459 460 #ifdef ANTICHEAT 461 int Sys_GetAntiCheatAPI (void); 462 #endif 463 464 //============================================= 465 466 // portable case insensitive compare 467 #ifndef Q_stricmp 468 int Q_stricmp (const char *s1, const char *s2); 469 #endif 470 471 #ifndef Q_strncasecmp 472 int Q_strncasecmp (const char *s1, const char *s2, size_t n); 473 #endif 474 475 //============================================= 476 477 #if Q_BIGENDIAN 478 int16 LittleShort(int16 l); 479 int32 LittleLong (int32 l); 480 float LittleFloat (float l); 481 #endif 482 483 void Swap_Init (void); 484 char *va(const char *format, ...) __attribute__ ((format (printf, 1, 2))); 485 486 //============================================= 487 488 // 489 // key / value info strings 490 // 491 #define MAX_INFO_KEY 64 492 #define MAX_INFO_VALUE 64 493 #define MAX_INFO_STRING 512 494 495 qboolean Info_KeyExists (const char *s, const char *key); 496 char *Info_ValueForKey (const char *s, const char *key); 497 void Info_RemoveKey (char *s, const char *key); 498 void Info_SetValueForKey (char *s, const char *key, const char *value); 499 qboolean Info_Validate (const char *s); 500 qboolean Info_CheckBytes (const char *s); 501 502 void seedMT (uint32 seed); 503 uint32 randomMT (void); 504 505 /* 506 ============================================================== 507 508 SYSTEM SPECIFIC 509 510 ============================================================== 511 */ 512 513 extern unsigned int curtime; // time returned by last Sys_Milliseconds 514 515 unsigned int Sys_Milliseconds (void); 516 void Sys_Mkdir (char *path); 517 void Sys_DebugBreak (void); 518 519 // large block stack allocation routines 520 void *Hunk_Begin (int maxsize, int precommit); 521 void *Hunk_Alloc (int size); 522 void Hunk_Free (void *buf); 523 int Hunk_End (void); 524 525 // directory searching 526 #define SFF_ARCH 0x01 527 #define SFF_HIDDEN 0x02 528 #define SFF_RDONLY 0x04 529 #define SFF_SUBDIR 0x08 530 #define SFF_SYSTEM 0x10 531 532 /* 533 ** pass in an attribute mask of things you wish to REJECT 534 */ 535 char *Sys_FindFirst (char *path, uint32 musthave, uint32 canthave ); 536 char *Sys_FindNext ( uint32 musthave, uint32 canthave ); 537 void Sys_FindClose (void); 538 539 540 void Sys_Sleep (int msec); 541 542 #define LOG_GENERAL 0x0 543 #define LOG_CLIENT 0x1 544 #define LOG_SERVER 0x2 545 #define LOG_DEBUG 0x4 546 #define LOG_WARNING 0x8 547 #define LOG_ERROR 0x10 548 #define LOG_GAME 0x20 549 #define LOG_CONNECT 0x40 550 #define LOG_NAME 0x80 551 #define LOG_DROP 0x100 552 #define LOG_KICK 0x200 553 #define LOG_EXPLOIT 0x400 554 #define LOG_DOWNLOAD 0x800 555 #define LOG_NOTICE 0x1000 556 #define LOG_CHAT 0x2000 557 #define LOG_NET 0x4000 558 #define LOG_GAMEDEBUG 0x8000 559 #define LOG_ANTICHEAT 0x10000 560 561 // this is only here so the functions in q_shared.c and q_shwin.c can link 562 NORETURN void Sys_Error (const char *error, ...) __attribute__ ((format (printf, 1, 2))); 563 void Com_Printf (const char *fmt, int level, ...) __attribute__ ((format (printf, 1, 3))); 564 565 566 /* 567 ========================================================== 568 569 CVARS (console variables) 570 571 ========================================================== 572 */ 573 574 #ifndef CVAR 575 #define CVAR 576 577 #define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc 578 #define CVAR_USERINFO 2 // added to userinfo when changed 579 #define CVAR_SERVERINFO 4 // added to serverinfo when changed 580 #define CVAR_NOSET 8 // don't allow change from console at all, 581 // but can be set from the command line 582 #define CVAR_LATCH 16 // save changes until server restart 583 584 // nothing outside the Cvar_*() functions should modify these fields! 585 typedef struct cvar_s 586 { 587 char *name; //0x00 588 char *string; //0x04 589 char *latched_string; // for CVAR_LATCH vars //0x08 590 int flags; //0x0c 591 qboolean modified; // set each time the cvar is changed //0x10 592 float value; //0x14 593 struct cvar_s *next; //0x18 594 595 //r1ch: added this to avoid all the if (x->modified) bloat 596 void (*changed) (struct cvar_s *self, char *oldValue, char *newValue); 597 int intvalue; 598 const char *help; 599 } cvar_t; 600 601 #define MAX_ALIAS_NAME 32 602 603 typedef struct cmdalias_s 604 { 605 char name[MAX_ALIAS_NAME]; 606 struct cmdalias_s *next; 607 char *value; 608 } cmdalias_t; 609 610 typedef void (*xcommand_t) (void); 611 612 typedef struct cmd_function_s 613 { 614 const char *name; 615 struct cmd_function_s *next; 616 xcommand_t function; 617 } cmd_function_t; 618 619 #endif // CVAR 620 621 /* 622 ============================================================== 623 624 COLLISION DETECTION 625 626 ============================================================== 627 */ 628 629 // lower bits are stronger, and will eat weaker brushes completely 630 #define CONTENTS_SOLID 1 // an eye is never valid in a solid 631 #define CONTENTS_WINDOW 2 // translucent, but not watery 632 #define CONTENTS_AUX 4 633 #define CONTENTS_LAVA 8 634 #define CONTENTS_SLIME 16 635 #define CONTENTS_WATER 32 636 #define CONTENTS_MIST 64 637 #define LAST_VISIBLE_CONTENTS 64 638 639 // remaining contents are non-visible, and don't eat brushes 640 641 #define CONTENTS_AREAPORTAL 0x8000 642 643 #define CONTENTS_PLAYERCLIP 0x10000 644 #define CONTENTS_MONSTERCLIP 0x20000 645 646 // currents can be added to any other contents, and may be mixed 647 #define CONTENTS_CURRENT_0 0x40000 648 #define CONTENTS_CURRENT_90 0x80000 649 #define CONTENTS_CURRENT_180 0x100000 650 #define CONTENTS_CURRENT_270 0x200000 651 #define CONTENTS_CURRENT_UP 0x400000 652 #define CONTENTS_CURRENT_DOWN 0x800000 653 654 #define CONTENTS_ORIGIN 0x1000000 // removed before bsping an entity 655 656 #define CONTENTS_MONSTER 0x2000000 // should never be on a brush, only in game 657 #define CONTENTS_DEADMONSTER 0x4000000 658 #define CONTENTS_DETAIL 0x8000000 // brushes to be added after vis leafs 659 #define CONTENTS_TRANSLUCENT 0x10000000 // auto set if any surface has trans 660 #define CONTENTS_LADDER 0x20000000 661 662 #define CONTENTS_ENT_NOCLIP 0x40000000 // r1q2 hack for non-velocity-changing clipping to solids 663 664 665 #define SURF_LIGHT 0x1 // value will hold the light strength 666 667 #define SURF_SLICK 0x2 // effects game physics 668 669 #define SURF_SKY 0x4 // don't draw, but add to skybox 670 #define SURF_WARP 0x8 // turbulent water warp 671 #define SURF_TRANS33 0x10 672 #define SURF_TRANS66 0x20 673 #define SURF_FLOWING 0x40 // scroll towards angle 674 #define SURF_NODRAW 0x80 // don't bother referencing the texture 675 676 677 678 // content masks 679 #define MASK_ALL (-1) 680 #define MASK_SOLID (CONTENTS_SOLID|CONTENTS_WINDOW) 681 #define MASK_PLAYERSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER) 682 #define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP|CONTENTS_WINDOW) 683 #define MASK_MONSTERSOLID (CONTENTS_SOLID|CONTENTS_MONSTERCLIP|CONTENTS_WINDOW|CONTENTS_MONSTER) 684 #define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME) 685 #define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA) 686 #define MASK_SHOT (CONTENTS_SOLID|CONTENTS_MONSTER|CONTENTS_WINDOW|CONTENTS_DEADMONSTER) 687 #define MASK_CURRENT (CONTENTS_CURRENT_0|CONTENTS_CURRENT_90|CONTENTS_CURRENT_180|CONTENTS_CURRENT_270|CONTENTS_CURRENT_UP|CONTENTS_CURRENT_DOWN) 688 689 690 // gi.BoxEdicts() can return a list of either solid or trigger entities 691 // FIXME: eliminate AREA_ distinction? 692 #define AREA_SOLID 1 693 #define AREA_TRIGGERS 2 694 695 696 // plane_t structure 697 // !!! if this is changed, it must be changed in asm code too !!! 698 typedef struct cplane_s 699 { 700 vec3_t normal; 701 float dist; 702 byte type; // for fast side tests 703 byte signbits; // signx + (signy<<1) + (signz<<1) 704 byte pad[2]; 705 } cplane_t; 706 707 //r1: "fast" plane for server calcs 708 typedef struct fplane_s 709 { 710 int type; // for fast side tests 711 float dist; 712 vec3_t normal; 713 int signbits; // signx + (signy<<1) + (signz<<1) 714 } fplane_t; 715 716 // structure offset for asm code 717 #define CPLANE_NORMAL_X 0 718 #define CPLANE_NORMAL_Y 4 719 #define CPLANE_NORMAL_Z 8 720 #define CPLANE_DIST 12 721 #define CPLANE_TYPE 16 722 #define CPLANE_SIGNBITS 17 723 #define CPLANE_PAD0 18 724 #define CPLANE_PAD1 19 725 726 typedef struct cmodel_s 727 { 728 vec3_t mins, maxs; 729 vec3_t origin; // for sounds or lights 730 int headnode; 731 } cmodel_t; 732 733 typedef struct csurface_s 734 { 735 char name[16]; 736 int flags; 737 int value; 738 } csurface_t; 739 740 typedef struct mapsurface_s // used internally due to name len probs //ZOID 741 { 742 csurface_t c; 743 char rname[32]; 744 } mapsurface_t; 745 746 // a trace is returned when a box is swept through the world 747 typedef struct 748 { 749 qboolean allsolid; // if true, plane is not valid 750 qboolean startsolid; // if true, the initial point was in a solid area 751 float fraction; // time completed, 1.0 = didn't hit anything 752 vec3_t endpos; // final position 753 cplane_t plane; // surface normal at impact 754 csurface_t *surface; // surface hit 755 int contents; // contents on other side of surface hit 756 struct edict_s *ent; // not set by CM_*() functions 757 } trace_t; 758 759 760 761 // pmove_state_t is the information necessary for client side movement 762 // prediction 763 typedef enum 764 { 765 // can accelerate and turn 766 PM_NORMAL, 767 PM_SPECTATOR, 768 // no acceleration or turning 769 PM_DEAD, 770 PM_GIB, // different bounding box 771 PM_FREEZE 772 } pmtype_t; 773 774 // pmove->pm_flags 775 #define PMF_DUCKED 1 776 #define PMF_JUMP_HELD 2 777 #define PMF_ON_GROUND 4 778 #define PMF_TIME_WATERJUMP 8 // pm_time is waterjump 779 #define PMF_TIME_LAND 16 // pm_time is time before rejump 780 #define PMF_TIME_TELEPORT 32 // pm_time is non-moving time 781 #define PMF_NO_PREDICTION 64 // temporarily disables prediction (used for grappling hook) 782 783 // this structure needs to be communicated bit-accurate 784 // from the server to the client to guarantee that 785 // prediction stays in sync, so no floats are used. 786 // if any part of the game code modifies this struct, it 787 // will result in a prediction error of some degree. 788 typedef struct 789 { 790 pmtype_t pm_type; 791 792 int16 origin[3]; // 12.3 793 int16 velocity[3]; // 12.3 794 byte pm_flags; // ducked, jump_held, etc 795 byte pm_time; // each unit = 8 ms 796 int16 gravity; 797 int16 delta_angles[3]; // add to command angles to get view direction 798 // changed by spawns, rotating objects, and teleporters 799 } pmove_state_t; 800 801 802 // 803 // button bits 804 // 805 #define BUTTON_ATTACK 1 806 #define BUTTON_USE 2 807 808 //stolen for r1q2 in the name of bandwidth 809 #define BUTTON_UCMD_DBLFORWARD 4 810 #define BUTTON_UCMD_DBLSIDE 8 811 #define BUTTON_UCMD_DBLUP 16 812 813 #define BUTTON_UCMD_DBL_ANGLE1 32 814 #define BUTTON_UCMD_DBL_ANGLE2 64 815 816 #define BUTTON_ANY 128 // any key whatsoever 817 818 819 // usercmd_t is sent to the server each client frame 820 typedef struct usercmd_s 821 { 822 byte msec; 823 byte buttons; 824 int16 angles[3]; 825 int16 forwardmove, sidemove, upmove; 826 byte impulse; // remove? 827 byte lightlevel; // light level the player is standing on 828 } usercmd_t; 829 830 831 #define MAXTOUCH 32 832 typedef struct 833 { 834 // state (in / out) 835 pmove_state_t s; 836 837 // command (in) 838 usercmd_t cmd; 839 qboolean snapinitial; // if s has been changed outside pmove 840 841 // results (out) 842 int numtouch; 843 struct edict_s *touchents[MAXTOUCH]; 844 845 vec3_t viewangles; // clamped 846 float viewheight; 847 848 vec3_t mins, maxs; // bounding box size 849 850 struct edict_s *groundentity; 851 int watertype; 852 int waterlevel; 853 854 // callbacks to test the world 855 trace_t (IMPORT *trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); 856 int (IMPORT *pointcontents) (vec3_t point); 857 } pmove_t; 858 859 typedef struct 860 { 861 // state (in / out) 862 pmove_state_t s; 863 864 // command (in) 865 usercmd_t cmd; 866 qboolean snapinitial; // if s has been changed outside pmove 867 868 // results (out) 869 int numtouch; 870 struct edict_s *touchents[MAXTOUCH]; 871 872 vec3_t viewangles; // clamped 873 float viewheight; 874 875 vec3_t mins, maxs; // bounding box size 876 877 struct edict_s *groundentity; 878 int watertype; 879 int waterlevel; 880 881 // callbacks to test the world 882 trace_t (IMPORT *trace) (vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end); 883 int (IMPORT *pointcontents) (vec3_t point); 884 885 float multiplier; 886 qboolean strafehack; 887 qboolean enhanced; 888 } pmove_new_t; 889 890 // entity_state_t->effects 891 // Effects are things handled on the client side (lights, particles, frame animations) 892 // that happen constantly on the given entity. 893 // An entity that has effects will be sent to the client 894 // even if it has a zero index model. 895 #define EF_ROTATE 0x00000001 // rotate (bonus items) 896 #define EF_GIB 0x00000002 // leave a trail 897 #define EF_BLASTER 0x00000008 // redlight + trail 898 #define EF_ROCKET 0x00000010 // redlight + trail 899 #define EF_GRENADE 0x00000020 900 #define EF_HYPERBLASTER 0x00000040 901 #define EF_BFG 0x00000080 902 #define EF_COLOR_SHELL 0x00000100 903 #define EF_POWERSCREEN 0x00000200 904 #define EF_ANIM01 0x00000400 // automatically cycle between frames 0 and 1 at 2 hz 905 #define EF_ANIM23 0x00000800 // automatically cycle between frames 2 and 3 at 2 hz 906 #define EF_ANIM_ALL 0x00001000 // automatically cycle through all frames at 2hz 907 #define EF_ANIM_ALLFAST 0x00002000 // automatically cycle through all frames at 10hz 908 #define EF_FLIES 0x00004000 909 #define EF_QUAD 0x00008000 910 #define EF_PENT 0x00010000 911 #define EF_TELEPORTER 0x00020000 // particle fountain 912 #define EF_FLAG1 0x00040000 913 #define EF_FLAG2 0x00080000 914 // RAFAEL 915 #define EF_IONRIPPER 0x00100000 916 #define EF_GREENGIB 0x00200000 917 #define EF_BLUEHYPERBLASTER 0x00400000 918 #define EF_SPINNINGLIGHTS 0x00800000 919 #define EF_PLASMA 0x01000000 920 #define EF_TRAP 0x02000000 921 922 //ROGUE 923 #define EF_TRACKER 0x04000000 924 #define EF_DOUBLE 0x08000000 925 #define EF_SPHERETRANS 0x10000000 926 #define EF_TAGTRAIL 0x20000000 927 #define EF_HALF_DAMAGE 0x40000000 928 #define EF_TRACKERTRAIL 0x80000000 929 //ROGUE 930 931 // entity_state_t->renderfx flags 932 #define RF_MINLIGHT 1 // allways have some light (viewmodel) 933 #define RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors 934 #define RF_WEAPONMODEL 4 // only draw through eyes 935 #define RF_FULLBRIGHT 8 // allways draw full intensity 936 #define RF_DEPTHHACK 16 // for view weapon Z crunching 937 #define RF_TRANSLUCENT 32 938 #define RF_FRAMELERP 64 939 #define RF_BEAM 128 940 #define RF_CUSTOMSKIN 256 // skin is an index in image_precache 941 #define RF_GLOW 512 // pulse lighting for bonus items 942 #define RF_SHELL_RED 1024 943 #define RF_SHELL_GREEN 2048 944 #define RF_SHELL_BLUE 4096 945 946 //ROGUE 947 #define RF_IR_VISIBLE 0x00008000 // 32768 948 #define RF_SHELL_DOUBLE 0x00010000 // 65536 949 #define RF_SHELL_HALF_DAM 0x00020000 950 #define RF_USE_DISGUISE 0x00040000 951 //ROGUE 952 953 // player_state_t->refdef flags 954 #define RDF_UNDERWATER 1 // warp the screen as apropriate 955 #define RDF_NOWORLDMODEL 2 // used for player configuration screen 956 957 //ROGUE 958 #define RDF_IRGOGGLES 4 959 #define RDF_UVGOGGLES 8 960 //ROGUE 961 962 // 963 // muzzle flashes / player effects 964 // 965 #define MZ_BLASTER 0 966 #define MZ_MACHINEGUN 1 967 #define MZ_SHOTGUN 2 968 #define MZ_CHAINGUN1 3 969 #define MZ_CHAINGUN2 4 970 #define MZ_CHAINGUN3 5 971 #define MZ_RAILGUN 6 972 #define MZ_ROCKET 7 973 #define MZ_GRENADE 8 974 #define MZ_LOGIN 9 975 #define MZ_LOGOUT 10 976 #define MZ_RESPAWN 11 977 #define MZ_BFG 12 978 #define MZ_SSHOTGUN 13 979 #define MZ_HYPERBLASTER 14 980 #define MZ_ITEMRESPAWN 15 981 // RAFAEL 982 #define MZ_IONRIPPER 16 983 #define MZ_BLUEHYPERBLASTER 17 984 #define MZ_PHALANX 18 985 #define MZ_SILENCED 128 // bit flag ORed with one of the above numbers 986 987 //ROGUE 988 #define MZ_ETF_RIFLE 30 989 #define MZ_UNUSED 31 990 #define MZ_SHOTGUN2 32 991 #define MZ_HEATBEAM 33 992 #define MZ_BLASTER2 34 993 #define MZ_TRACKER 35 994 #define MZ_NUKE1 36 995 #define MZ_NUKE2 37 996 #define MZ_NUKE4 38 997 #define MZ_NUKE8 39 998 //ROGUE 999 1000 // 1001 // monster muzzle flashes 1002 // 1003 #define MZ2_TANK_BLASTER_1 1 1004 #define MZ2_TANK_BLASTER_2 2 1005 #define MZ2_TANK_BLASTER_3 3 1006 #define MZ2_TANK_MACHINEGUN_1 4 1007 #define MZ2_TANK_MACHINEGUN_2 5 1008 #define MZ2_TANK_MACHINEGUN_3 6 1009 #define MZ2_TANK_MACHINEGUN_4 7 1010 #define MZ2_TANK_MACHINEGUN_5 8 1011 #define MZ2_TANK_MACHINEGUN_6 9 1012 #define MZ2_TANK_MACHINEGUN_7 10 1013 #define MZ2_TANK_MACHINEGUN_8 11 1014 #define MZ2_TANK_MACHINEGUN_9 12 1015 #define MZ2_TANK_MACHINEGUN_10 13 1016 #define MZ2_TANK_MACHINEGUN_11 14 1017 #define MZ2_TANK_MACHINEGUN_12 15 1018 #define MZ2_TANK_MACHINEGUN_13 16 1019 #define MZ2_TANK_MACHINEGUN_14 17 1020 #define MZ2_TANK_MACHINEGUN_15 18 1021 #define MZ2_TANK_MACHINEGUN_16 19 1022 #define MZ2_TANK_MACHINEGUN_17 20 1023 #define MZ2_TANK_MACHINEGUN_18 21 1024 #define MZ2_TANK_MACHINEGUN_19 22 1025 #define MZ2_TANK_ROCKET_1 23 1026 #define MZ2_TANK_ROCKET_2 24 1027 #define MZ2_TANK_ROCKET_3 25 1028 1029 #define MZ2_INFANTRY_MACHINEGUN_1 26 1030 #define MZ2_INFANTRY_MACHINEGUN_2 27 1031 #define MZ2_INFANTRY_MACHINEGUN_3 28 1032 #define MZ2_INFANTRY_MACHINEGUN_4 29 1033 #define MZ2_INFANTRY_MACHINEGUN_5 30 1034 #define MZ2_INFANTRY_MACHINEGUN_6 31 1035 #define MZ2_INFANTRY_MACHINEGUN_7 32 1036 #define MZ2_INFANTRY_MACHINEGUN_8 33 1037 #define MZ2_INFANTRY_MACHINEGUN_9 34 1038 #define MZ2_INFANTRY_MACHINEGUN_10 35 1039 #define MZ2_INFANTRY_MACHINEGUN_11 36 1040 #define MZ2_INFANTRY_MACHINEGUN_12 37 1041 #define MZ2_INFANTRY_MACHINEGUN_13 38 1042 1043 #define MZ2_SOLDIER_BLASTER_1 39 1044 #define MZ2_SOLDIER_BLASTER_2 40 1045 #define MZ2_SOLDIER_SHOTGUN_1 41 1046 #define MZ2_SOLDIER_SHOTGUN_2 42 1047 #define MZ2_SOLDIER_MACHINEGUN_1 43 1048 #define MZ2_SOLDIER_MACHINEGUN_2 44 1049 1050 #define MZ2_GUNNER_MACHINEGUN_1 45 1051 #define MZ2_GUNNER_MACHINEGUN_2 46 1052 #define MZ2_GUNNER_MACHINEGUN_3 47 1053 #define MZ2_GUNNER_MACHINEGUN_4 48 1054 #define MZ2_GUNNER_MACHINEGUN_5 49 1055 #define MZ2_GUNNER_MACHINEGUN_6 50 1056 #define MZ2_GUNNER_MACHINEGUN_7 51 1057 #define MZ2_GUNNER_MACHINEGUN_8 52 1058 #define MZ2_GUNNER_GRENADE_1 53 1059 #define MZ2_GUNNER_GRENADE_2 54 1060 #define MZ2_GUNNER_GRENADE_3 55 1061 #define MZ2_GUNNER_GRENADE_4 56 1062 1063 #define MZ2_CHICK_ROCKET_1 57 1064 1065 #define MZ2_FLYER_BLASTER_1 58 1066 #define MZ2_FLYER_BLASTER_2 59 1067 1068 #define MZ2_MEDIC_BLASTER_1 60 1069 1070 #define MZ2_GLADIATOR_RAILGUN_1 61 1071 1072 #define MZ2_HOVER_BLASTER_1 62 1073 1074 #define MZ2_ACTOR_MACHINEGUN_1 63 1075 1076 #define MZ2_SUPERTANK_MACHINEGUN_1 64 1077 #define MZ2_SUPERTANK_MACHINEGUN_2 65 1078 #define MZ2_SUPERTANK_MACHINEGUN_3 66 1079 #define MZ2_SUPERTANK_MACHINEGUN_4 67 1080 #define MZ2_SUPERTANK_MACHINEGUN_5 68 1081 #define MZ2_SUPERTANK_MACHINEGUN_6 69 1082 #define MZ2_SUPERTANK_ROCKET_1 70 1083 #define MZ2_SUPERTANK_ROCKET_2 71 1084 #define MZ2_SUPERTANK_ROCKET_3 72 1085 1086 #define MZ2_BOSS2_MACHINEGUN_L1 73 1087 #define MZ2_BOSS2_MACHINEGUN_L2 74 1088 #define MZ2_BOSS2_MACHINEGUN_L3 75 1089 #define MZ2_BOSS2_MACHINEGUN_L4 76 1090 #define MZ2_BOSS2_MACHINEGUN_L5 77 1091 #define MZ2_BOSS2_ROCKET_1 78 1092 #define MZ2_BOSS2_ROCKET_2 79 1093 #define MZ2_BOSS2_ROCKET_3 80 1094 #define MZ2_BOSS2_ROCKET_4 81 1095 1096 #define MZ2_FLOAT_BLASTER_1 82 1097 1098 #define MZ2_SOLDIER_BLASTER_3 83 1099 #define MZ2_SOLDIER_SHOTGUN_3 84 1100 #define MZ2_SOLDIER_MACHINEGUN_3 85 1101 #define MZ2_SOLDIER_BLASTER_4 86 1102 #define MZ2_SOLDIER_SHOTGUN_4 87 1103 #define MZ2_SOLDIER_MACHINEGUN_4 88 1104 #define MZ2_SOLDIER_BLASTER_5 89 1105 #define MZ2_SOLDIER_SHOTGUN_5 90 1106 #define MZ2_SOLDIER_MACHINEGUN_5 91 1107 #define MZ2_SOLDIER_BLASTER_6 92 1108 #define MZ2_SOLDIER_SHOTGUN_6 93 1109 #define MZ2_SOLDIER_MACHINEGUN_6 94 1110 #define MZ2_SOLDIER_BLASTER_7 95 1111 #define MZ2_SOLDIER_SHOTGUN_7 96 1112 #define MZ2_SOLDIER_MACHINEGUN_7 97 1113 #define MZ2_SOLDIER_BLASTER_8 98 1114 #define MZ2_SOLDIER_SHOTGUN_8 99 1115 #define MZ2_SOLDIER_MACHINEGUN_8 100 1116 1117 // --- Xian shit below --- 1118 #define MZ2_MAKRON_BFG 101 1119 #define MZ2_MAKRON_BLASTER_1 102 1120 #define MZ2_MAKRON_BLASTER_2 103 1121 #define MZ2_MAKRON_BLASTER_3 104 1122 #define MZ2_MAKRON_BLASTER_4 105 1123 #define MZ2_MAKRON_BLASTER_5 106 1124 #define MZ2_MAKRON_BLASTER_6 107 1125 #define MZ2_MAKRON_BLASTER_7 108 1126 #define MZ2_MAKRON_BLASTER_8 109 1127 #define MZ2_MAKRON_BLASTER_9 110 1128 #define MZ2_MAKRON_BLASTER_10 111 1129 #define MZ2_MAKRON_BLASTER_11 112 1130 #define MZ2_MAKRON_BLASTER_12 113 1131 #define MZ2_MAKRON_BLASTER_13 114 1132 #define MZ2_MAKRON_BLASTER_14 115 1133 #define MZ2_MAKRON_BLASTER_15 116 1134 #define MZ2_MAKRON_BLASTER_16 117 1135 #define MZ2_MAKRON_BLASTER_17 118 1136 #define MZ2_MAKRON_RAILGUN_1 119 1137 #define MZ2_JORG_MACHINEGUN_L1 120 1138 #define MZ2_JORG_MACHINEGUN_L2 121 1139 #define MZ2_JORG_MACHINEGUN_L3 122 1140 #define MZ2_JORG_MACHINEGUN_L4 123 1141 #define MZ2_JORG_MACHINEGUN_L5 124 1142 #define MZ2_JORG_MACHINEGUN_L6 125 1143 #define MZ2_JORG_MACHINEGUN_R1 126 1144 #define MZ2_JORG_MACHINEGUN_R2 127 1145 #define MZ2_JORG_MACHINEGUN_R3 128 1146 #define MZ2_JORG_MACHINEGUN_R4 129 1147 #define MZ2_JORG_MACHINEGUN_R5 130 1148 #define MZ2_JORG_MACHINEGUN_R6 131 1149 #define MZ2_JORG_BFG_1 132 1150 #define MZ2_BOSS2_MACHINEGUN_R1 133 1151 #define MZ2_BOSS2_MACHINEGUN_R2 134 1152 #define MZ2_BOSS2_MACHINEGUN_R3 135 1153 #define MZ2_BOSS2_MACHINEGUN_R4 136 1154 #define MZ2_BOSS2_MACHINEGUN_R5 137 1155 1156 //ROGUE 1157 #define MZ2_CARRIER_MACHINEGUN_L1 138 1158 #define MZ2_CARRIER_MACHINEGUN_R1 139 1159 #define MZ2_CARRIER_GRENADE 140 1160 #define MZ2_TURRET_MACHINEGUN 141 1161 #define MZ2_TURRET_ROCKET 142 1162 #define MZ2_TURRET_BLASTER 143 1163 #define MZ2_STALKER_BLASTER 144 1164 #define MZ2_DAEDALUS_BLASTER 145 1165 #define MZ2_MEDIC_BLASTER_2 146 1166 #define MZ2_CARRIER_RAILGUN 147 1167 #define MZ2_WIDOW_DISRUPTOR 148 1168 #define MZ2_WIDOW_BLASTER 149 1169 #define MZ2_WIDOW_RAIL 150 1170 #define MZ2_WIDOW_PLASMABEAM 151 // PMM - not used 1171 #define MZ2_CARRIER_MACHINEGUN_L2 152 1172 #define MZ2_CARRIER_MACHINEGUN_R2 153 1173 #define MZ2_WIDOW_RAIL_LEFT 154 1174 #define MZ2_WIDOW_RAIL_RIGHT 155 1175 #define MZ2_WIDOW_BLASTER_SWEEP1 156 1176 #define MZ2_WIDOW_BLASTER_SWEEP2 157 1177 #define MZ2_WIDOW_BLASTER_SWEEP3 158 1178 #define MZ2_WIDOW_BLASTER_SWEEP4 159 1179 #define MZ2_WIDOW_BLASTER_SWEEP5 160 1180 #define MZ2_WIDOW_BLASTER_SWEEP6 161 1181 #define MZ2_WIDOW_BLASTER_SWEEP7 162 1182 #define MZ2_WIDOW_BLASTER_SWEEP8 163 1183 #define MZ2_WIDOW_BLASTER_SWEEP9 164 1184 #define MZ2_WIDOW_BLASTER_100 165 1185 #define MZ2_WIDOW_BLASTER_90 166 1186 #define MZ2_WIDOW_BLASTER_80 167 1187 #define MZ2_WIDOW_BLASTER_70 168 1188 #define MZ2_WIDOW_BLASTER_60 169 1189 #define MZ2_WIDOW_BLASTER_50 170 1190 #define MZ2_WIDOW_BLASTER_40 171 1191 #define MZ2_WIDOW_BLASTER_30 172 1192 #define MZ2_WIDOW_BLASTER_20 173 1193 #define MZ2_WIDOW_BLASTER_10 174 1194 #define MZ2_WIDOW_BLASTER_0 175 1195 #define MZ2_WIDOW_BLASTER_10L 176 1196 #define MZ2_WIDOW_BLASTER_20L 177 1197 #define MZ2_WIDOW_BLASTER_30L 178 1198 #define MZ2_WIDOW_BLASTER_40L 179 1199 #define MZ2_WIDOW_BLASTER_50L 180 1200 #define MZ2_WIDOW_BLASTER_60L 181 1201 #define MZ2_WIDOW_BLASTER_70L 182 1202 #define MZ2_WIDOW_RUN_1 183 1203 #define MZ2_WIDOW_RUN_2 184 1204 #define MZ2_WIDOW_RUN_3 185 1205 #define MZ2_WIDOW_RUN_4 186 1206 #define MZ2_WIDOW_RUN_5 187 1207 #define MZ2_WIDOW_RUN_6 188 1208 #define MZ2_WIDOW_RUN_7 189 1209 #define MZ2_WIDOW_RUN_8 190 1210 #define MZ2_CARRIER_ROCKET_1 191 1211 #define MZ2_CARRIER_ROCKET_2 192 1212 #define MZ2_CARRIER_ROCKET_3 193 1213 #define MZ2_CARRIER_ROCKET_4 194 1214 #define MZ2_WIDOW2_BEAMER_1 195 1215 #define MZ2_WIDOW2_BEAMER_2 196 1216 #define MZ2_WIDOW2_BEAMER_3 197 1217 #define MZ2_WIDOW2_BEAMER_4 198 1218 #define MZ2_WIDOW2_BEAMER_5 199 1219 #define MZ2_WIDOW2_BEAM_SWEEP_1 200 1220 #define MZ2_WIDOW2_BEAM_SWEEP_2 201 1221 #define MZ2_WIDOW2_BEAM_SWEEP_3 202 1222 #define MZ2_WIDOW2_BEAM_SWEEP_4 203 1223 #define MZ2_WIDOW2_BEAM_SWEEP_5 204 1224 #define MZ2_WIDOW2_BEAM_SWEEP_6 205 1225 #define MZ2_WIDOW2_BEAM_SWEEP_7 206 1226 #define MZ2_WIDOW2_BEAM_SWEEP_8 207 1227 #define MZ2_WIDOW2_BEAM_SWEEP_9 208 1228 #define MZ2_WIDOW2_BEAM_SWEEP_10 209 1229 #define MZ2_WIDOW2_BEAM_SWEEP_11 210 1230 1231 // ROGUE 1232 1233 extern const vec3_t monster_flash_offset []; 1234 1235 1236 // temp entity events 1237 // 1238 // Temp entity events are for things that happen 1239 // at a location seperate from any existing entity. 1240 // Temporary entity messages are explicitly constructed 1241 // and broadcast. 1242 typedef enum 1243 { 1244 TE_GUNSHOT, 1245 TE_BLOOD, 1246 TE_BLASTER, 1247 TE_RAILTRAIL, 1248 TE_SHOTGUN, 1249 TE_EXPLOSION1, 1250 TE_EXPLOSION2, 1251 TE_ROCKET_EXPLOSION, 1252 TE_GRENADE_EXPLOSION, 1253 TE_SPARKS, 1254 TE_SPLASH, 1255 TE_BUBBLETRAIL, 1256 TE_SCREEN_SPARKS, 1257 TE_SHIELD_SPARKS, 1258 TE_BULLET_SPARKS, 1259 TE_LASER_SPARKS, 1260 TE_PARASITE_ATTACK, 1261 TE_ROCKET_EXPLOSION_WATER, 1262 TE_GRENADE_EXPLOSION_WATER, 1263 TE_MEDIC_CABLE_ATTACK, 1264 TE_BFG_EXPLOSION, 1265 TE_BFG_BIGEXPLOSION, 1266 TE_BOSSTPORT, // used as '22' in a map, so DON'T RENUMBER!!! 1267 TE_BFG_LASER, 1268 TE_GRAPPLE_CABLE, 1269 TE_WELDING_SPARKS, 1270 TE_GREENBLOOD, 1271 TE_BLUEHYPERBLASTER, 1272 TE_PLASMA_EXPLOSION, 1273 TE_TUNNEL_SPARKS, 1274 //ROGUE 1275 TE_BLASTER2, 1276 TE_RAILTRAIL2, 1277 TE_FLAME, 1278 TE_LIGHTNING, 1279 TE_DEBUGTRAIL, 1280 TE_PLAIN_EXPLOSION, 1281 TE_FLASHLIGHT, 1282 TE_FORCEWALL, 1283 TE_HEATBEAM, 1284 TE_MONSTER_HEATBEAM, 1285 TE_STEAM, 1286 TE_BUBBLETRAIL2, 1287 TE_MOREBLOOD, 1288 TE_HEATBEAM_SPARKS, 1289 TE_HEATBEAM_STEAM, 1290 TE_CHAINFIST_SMOKE, 1291 TE_ELECTRIC_SPARKS, 1292 TE_TRACKER_EXPLOSION, 1293 TE_TELEPORT_EFFECT, 1294 TE_DBALL_GOAL, 1295 TE_WIDOWBEAMOUT, 1296 TE_NUKEBLAST, 1297 TE_WIDOWSPLASH, 1298 TE_EXPLOSION1_BIG, 1299 TE_EXPLOSION1_NP, 1300 TE_FLECHETTE 1301 //ROGUE 1302 } temp_event_t; 1303 1304 #define SPLASH_UNKNOWN 0 1305 #define SPLASH_SPARKS 1 1306 #define SPLASH_BLUE_WATER 2 1307 #define SPLASH_BROWN_WATER 3 1308 #define SPLASH_SLIME 4 1309 #define SPLASH_LAVA 5 1310 #define SPLASH_BLOOD 6 1311 1312 1313 // sound channels 1314 // channel 0 never willingly overrides 1315 // other channels (1-7) allways override a playing sound on that channel 1316 #define CHAN_AUTO 0 1317 #define CHAN_WEAPON 1 1318 #define CHAN_VOICE 2 1319 #define CHAN_ITEM 3 1320 #define CHAN_BODY 4 1321 1322 // modifier flags 1323 #define CHAN_NO_PHS_ADD 8 // send to all clients, not just ones in PHS (ATTN 0 will also do this) 1324 #define CHAN_RELIABLE 16 // send by reliable message, not datagram 1325 //R1Q2 SPECIFIC XXX 1326 #define CHAN_SERVER_ATTN_CALC 32 1327 1328 // sound attenuation values 1329 #define ATTN_NONE 0 // full volume the entire level 1330 #define ATTN_NORM 1 1331 #define ATTN_IDLE 2 1332 #define ATTN_STATIC 3 // diminish very rapidly with distance 1333 1334 1335 // player_state->stats[] indexes 1336 #define STAT_HEALTH_ICON 0 1337 #define STAT_HEALTH 1 1338 #define STAT_AMMO_ICON 2 1339 #define STAT_AMMO 3 1340 #define STAT_ARMOR_ICON 4 1341 #define STAT_ARMOR 5 1342 #define STAT_SELECTED_ICON 6 1343 #define STAT_PICKUP_ICON 7 1344 #define STAT_PICKUP_STRING 8 1345 #define STAT_TIMER_ICON 9 1346 #define STAT_TIMER 10 1347 #define STAT_HELPICON 11 1348 #define STAT_SELECTED_ITEM 12 1349 #define STAT_LAYOUTS 13 1350 #define STAT_FRAGS 14 1351 #define STAT_FLASHES 15 // cleared each frame, 1 = health, 2 = armor 1352 #define STAT_CHASE 16 1353 #define STAT_SPECTATOR 17 1354 1355 #define MAX_STATS 32 1356 1357 1358 // dmflags->value flags 1359 #define DF_NO_HEALTH 0x00000001 // 1 1360 #define DF_NO_ITEMS 0x00000002 // 2 1361 #define DF_WEAPONS_STAY 0x00000004 // 4 1362 #define DF_NO_FALLING 0x00000008 // 8 1363 #define DF_INSTANT_ITEMS 0x00000010 // 16 1364 #define DF_SAME_LEVEL 0x00000020 // 32 1365 #define DF_SKINTEAMS 0x00000040 // 64 1366 #define DF_MODELTEAMS 0x00000080 // 128 1367 #define DF_NO_FRIENDLY_FIRE 0x00000100 // 256 1368 #define DF_SPAWN_FARTHEST 0x00000200 // 512 1369 #define DF_FORCE_RESPAWN 0x00000400 // 1024 1370 #define DF_NO_ARMOR 0x00000800 // 2048 1371 #define DF_ALLOW_EXIT 0x00001000 // 4096 1372 #define DF_INFINITE_AMMO 0x00002000 // 8192 1373 #define DF_QUAD_DROP 0x00004000 // 16384 1374 #define DF_FIXED_FOV 0x00008000 // 32768 1375 1376 // RAFAEL 1377 #define DF_QUADFIRE_DROP 0x00010000 // 65536 1378 1379 //ROGUE 1380 #define DF_NO_MINES 0x00020000 1381 #define DF_NO_STACK_DOUBLE 0x00040000 1382 #define DF_NO_NUKES 0x00080000 1383 #define DF_NO_SPHERES 0x00100000 1384 //ROGUE 1385 1386 /* 1387 ROGUE - VERSIONS 1388 1234 08/13/1998 Activision 1389 1235 08/14/1998 Id Software 1390 1236 08/15/1998 Steve Tietze 1391 1237 08/15/1998 Phil Dobranski 1392 1238 08/15/1998 John Sheley 1393 1239 08/17/1998 Barrett Alexander 1394 1230 08/17/1998 Brandon Fish 1395 1245 08/17/1998 Don MacAskill 1396 1246 08/17/1998 David "Zoid" Kirsch 1397 1247 08/17/1998 Manu Smith 1398 1248 08/17/1998 Geoff Scully 1399 1249 08/17/1998 Andy Van Fossen 1400 1240 08/20/1998 Activision Build 2 1401 1256 08/20/1998 Ranger Clan 1402 1257 08/20/1998 Ensemble Studios 1403 1258 08/21/1998 Robert Duffy 1404 1259 08/21/1998 Stephen Seachord 1405 1250 08/21/1998 Stephen Heaslip 1406 1267 08/21/1998 Samir Sandesara 1407 1268 08/21/1998 Oliver Wyman 1408 1269 08/21/1998 Steven Marchegiano 1409 1260 08/21/1998 Build #2 for Nihilistic 1410 1278 08/21/1998 Build #2 for Ensemble 1411 1412 9999 08/20/1998 Internal Use 1413 */ 1414 #define ROGUE_VERSION_ID 1278 1415 1416 #define ROGUE_VERSION_STRING "08/21/1998 Beta 2 for Ensemble" 1417 1418 // ROGUE 1419 /* 1420 ========================================================== 1421 1422 ELEMENTS COMMUNICATED ACROSS THE NET 1423 1424 ========================================================== 1425 */ 1426 1427 #define ANGLE2SHORT(x) ((int)((x)*182.04444444444444444444444444444f) & 65535) 1428 #define SHORT2ANGLE(x) ((x)*(0.0054931640625f)) 1429 1430 1431 // 1432 // config strings are a general means of communication from 1433 // the server to all connected clients. 1434 // Each config string can be at most MAX_QPATH characters. 1435 // 1436 #define CS_NAME 0 1437 #define CS_CDTRACK 1 1438 #define CS_SKY 2 1439 #define CS_SKYAXIS 3 // %f %f %f format 1440 #define CS_SKYROTATE 4 1441 #define CS_STATUSBAR 5 // display program string 1442 1443 #define CS_AIRACCEL 29 // air acceleration control 1444 #define CS_MAXCLIENTS 30 1445 #define CS_MAPCHECKSUM 31 // for catching cheater maps 1446 1447 #define CS_MODELS 32 1448 #define CS_SOUNDS (CS_MODELS+MAX_MODELS) //288 1449 #define CS_IMAGES (CS_SOUNDS+MAX_SOUNDS) //544 1450 #define CS_LIGHTS (CS_IMAGES+MAX_IMAGES) //800 1451 #define CS_ITEMS (CS_LIGHTS+MAX_LIGHTSTYLES) //1056 1452 #define CS_PLAYERSKINS (CS_ITEMS+MAX_ITEMS) //1312 1453 #define CS_GENERAL (CS_PLAYERSKINS+MAX_CLIENTS) //1568 1454 #define MAX_CONFIGSTRINGS (CS_GENERAL+MAX_GENERAL) //2080 1455 1456 1457 //============================================== 1458 1459 1460 // entity_state_t->event values 1461 // ertity events are for effects that take place reletive 1462 // to an existing entities origin. Very network efficient. 1463 // All muzzle flashes really should be converted to events... 1464 typedef enum 1465 { 1466 EVENT_NONE, 1467 EV_ITEM_RESPAWN, 1468 EV_FOOTSTEP, 1469 EV_FALLSHORT, 1470 EV_FALL, 1471 EV_FALLFAR, 1472 EV_PLAYER_TELEPORT, 1473 EV_OTHER_TELEPORT 1474 } entity_event_t; 1475 1476 1477 // entity_state_t is the information conveyed from the server 1478 // in an update message about entities that the client will 1479 // need to render in some way 1480 typedef struct entity_state_s 1481 { 1482 int number; // edict index 1483 1484 vec3_t origin; 1485 vec3_t angles; 1486 vec3_t old_origin; // for lerping 1487 int32 modelindex; 1488 int32 modelindex2, modelindex3, modelindex4; // weapons, CTF flags, etc 1489 int32 frame; 1490 int32 skinnum; 1491 uint32 effects; // PGM - we're filling it, so it needs to be unsigned 1492 int32 renderfx; 1493 int32 solid; // for client side prediction, 8*(bits 0-4) is x/y radius 1494 // 8*(bits 5-9) is z down distance, 8(bits10-15) is z up 1495 // gi.linkentity sets this properly 1496 int32 sound; // for looping sounds, to guarantee shutoff 1497 int32 event; // impulse events -- muzzle flashes, footsteps, etc 1498 // events only go out for a single frame, they 1499 // are automatically cleared each frame 1500 } entity_state_t; 1501 1502 //============================================== 1503 1504 1505 // player_state_t is the information needed in addition to pmove_state_t 1506 // to rendered a view. There will only be 10 player_state_t sent each second, 1507 // but the number of pmove_state_t changes will be reletive to client 1508 // frame rates 1509 1510 typedef struct 1511 { 1512 pmove_state_t pmove; // for prediction 1513 1514 // these fields do not need to be communicated bit-precise 1515 1516 vec3_t viewangles; // for fixed views 1517 vec3_t viewoffset; // add to pmovestate->origin 1518 vec3_t kick_angles; // add to view direction to get render angles 1519 // set by weapon kicks, pain effects, etc 1520 1521 vec3_t gunangles; 1522 vec3_t gunoffset; 1523 1524 int gunindex; 1525 int gunframe; 1526 1527 float blend[4]; // rgba full screen effect 1528 1529 float fov; // horizontal field of view 1530 1531 int rdflags; // refdef flags 1532 1533 int16 stats[MAX_STATS]; // fast status bar updates 1534 } player_state_t; 1535 1536 // ================== 1537 // PGM 1538 #define VIDREF_GL 1 1539 #define VIDREF_SOFT 2 1540 #define VIDREF_OTHER 3 1541 1542 extern int vidref_val; 1543 // PGM 1544 // ================== 1545 1546 #define _QSHARED_H 1547 1548 #endif 1549