| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#ifndef __Q_SHARED_H |
| 24 |
#define __Q_SHARED_H |
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
#ifdef STANDALONE |
| 30 |
#define PRODUCT_NAME "iofoo3" |
| 31 |
#define BASEGAME "foobar" |
| 32 |
#define CLIENT_WINDOW_TITLE "changeme" |
| 33 |
#define CLIENT_WINDOW_MIN_TITLE "changeme2" |
| 34 |
#define HOMEPATH_NAME_UNIX_LEGACY ".foo" |
| 35 |
#define HOMEPATH_NAME "FooBar" |
| 36 |
#define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace |
| 37 |
#define CINEMATICS_LOGO "foologo.roq" |
| 38 |
#define CINEMATICS_INTRO "intro.roq" |
| 39 |
|
| 40 |
|
| 41 |
#define CONFIG_PREFIX "fooconfig" |
| 42 |
#else |
| 43 |
#define PRODUCT_NAME "ioq3" |
| 44 |
#define BASEGAME "baseq3" |
| 45 |
#define CLIENT_WINDOW_TITLE "ioquake3" |
| 46 |
#define CLIENT_WINDOW_MIN_TITLE "ioq3" |
| 47 |
#define HOMEPATH_NAME_UNIX_LEGACY ".q3a" |
| 48 |
#define HOMEPATH_NAME "Quake3" |
| 49 |
#define GAMENAME_FOR_MASTER "Quake3Arena" |
| 50 |
#define CINEMATICS_LOGO "idlogo.RoQ" |
| 51 |
#define CINEMATICS_INTRO "intro.RoQ" |
| 52 |
#define LEGACY_PROTOCOL |
| 53 |
#define PROTOCOL_HANDLER "quake3" |
| 54 |
#define CONFIG_PREFIX "q3config" |
| 55 |
#endif |
| 56 |
|
| 57 |
|
| 58 |
#define HEARTBEAT_FOR_MASTER "DarkPlaces" |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
#define LEGACY_MASTER_GAMENAME "Quake3Arena" |
| 63 |
#define LEGACY_HEARTBEAT_FOR_MASTER "QuakeArena-1" |
| 64 |
|
| 65 |
#define BASETA "missionpack" |
| 66 |
|
| 67 |
#ifndef PRODUCT_VERSION |
| 68 |
#define PRODUCT_VERSION "1.36" |
| 69 |
#endif |
| 70 |
|
| 71 |
#ifndef PRODUCT_DATE |
| 72 |
# define PRODUCT_DATE __DATE__ |
| 73 |
#endif |
| 74 |
|
| 75 |
#define Q3_VERSION PRODUCT_NAME " " PRODUCT_VERSION |
| 76 |
|
| 77 |
#define MAX_TEAMNAME 32 |
| 78 |
#define MAX_MASTER_SERVERS 5 // number of supported master servers |
| 79 |
|
| 80 |
#define DEMOEXT "dm_" // standard demo extension |
| 81 |
|
| 82 |
#ifdef _MSC_VER |
| 83 |
|
| 84 |
#pragma warning(disable : 4018) // signed/unsigned mismatch |
| 85 |
#pragma warning(disable : 4032) |
| 86 |
#pragma warning(disable : 4051) |
| 87 |
#pragma warning(disable : 4057) // slightly different base types |
| 88 |
#pragma warning(disable : 4100) // unreferenced formal parameter |
| 89 |
#pragma warning(disable : 4115) |
| 90 |
#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence |
| 91 |
#pragma warning(disable : 4127) // conditional expression is constant |
| 92 |
#pragma warning(disable : 4136) |
| 93 |
#pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression |
| 94 |
|
| 95 |
|
| 96 |
#pragma warning(disable : 4244) |
| 97 |
#pragma warning(disable : 4142) // benign redefinition |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
#pragma warning(disable : 4514) |
| 102 |
#pragma warning(disable : 4702) // unreachable code |
| 103 |
#pragma warning(disable : 4711) // selected for automatic inline expansion |
| 104 |
#pragma warning(disable : 4220) // varargs matches remaining parameters |
| 105 |
|
| 106 |
#endif |
| 107 |
|
| 108 |
#ifdef __GNUC__ |
| 109 |
#define Q_UNUSED_VAR __attribute__((unused)) |
| 110 |
#define Q_NO_RETURN __attribute__((noreturn)) |
| 111 |
|
| 112 |
#ifdef __MINGW32__ |
| 113 |
|
| 114 |
#define Q_PRINTF_FUNC(fmt, va) \ |
| 115 |
__attribute__((format(gnu_printf, fmt, va))) \ |
| 116 |
__attribute__((format(ms_printf, fmt, va))) |
| 117 |
#else |
| 118 |
#define Q_PRINTF_FUNC(fmt, va) __attribute__((format(printf, fmt, va))) |
| 119 |
#endif |
| 120 |
|
| 121 |
#define Q_SCANF_FUNC(fmt, va) __attribute__((format(scanf, fmt, va))) |
| 122 |
#define Q_ALIGN(x) __attribute__((aligned(x))) |
| 123 |
#else |
| 124 |
#define Q_UNUSED_VAR |
| 125 |
#define Q_NO_RETURN |
| 126 |
#define Q_PRINTF_FUNC(fmt, va) |
| 127 |
#define Q_SCANF_FUNC(fmt, va) |
| 128 |
#define Q_ALIGN(x) |
| 129 |
#endif |
| 130 |
|
| 131 |
#if (defined _MSC_VER) |
| 132 |
#define Q_EXPORT __declspec(dllexport) |
| 133 |
#elif (defined __SUNPRO_C) |
| 134 |
#define Q_EXPORT __global |
| 135 |
#elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun)) |
| 136 |
#define Q_EXPORT __attribute__((visibility("default"))) |
| 137 |
#else |
| 138 |
#define Q_EXPORT |
| 139 |
#endif |
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
#ifdef Q3_VM |
| 158 |
|
| 159 |
#include "../game/bg_lib.h" |
| 160 |
|
| 161 |
typedef int intptr_t; |
| 162 |
|
| 163 |
#else |
| 164 |
|
| 165 |
#include <assert.h> |
| 166 |
#include <math.h> |
| 167 |
#include <stdio.h> |
| 168 |
#include <stdarg.h> |
| 169 |
#include <string.h> |
| 170 |
#include <stddef.h> |
| 171 |
#include <stdlib.h> |
| 172 |
#include <time.h> |
| 173 |
#include <ctype.h> |
| 174 |
#include <limits.h> |
| 175 |
#include <stdint.h> |
| 176 |
|
| 177 |
#ifdef _WIN32 |
| 178 |
|
| 179 |
|
| 180 |
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap) Q_PRINTF_FUNC(3, 0); |
| 181 |
#else |
| 182 |
#define Q_vsnprintf vsnprintf |
| 183 |
#endif |
| 184 |
|
| 185 |
#endif |
| 186 |
|
| 187 |
|
| 188 |
#include "q_platform.h" |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
typedef unsigned char byte; |
| 193 |
|
| 194 |
typedef enum {qfalse, qtrue} qboolean; |
| 195 |
|
| 196 |
typedef union { |
| 197 |
float f; |
| 198 |
int i; |
| 199 |
unsigned int ui; |
| 200 |
} floatint_t; |
| 201 |
|
| 202 |
typedef int qhandle_t; |
| 203 |
typedef int sfxHandle_t; |
| 204 |
typedef int fileHandle_t; |
| 205 |
typedef int clipHandle_t; |
| 206 |
|
| 207 |
#define PAD(base, alignment) (((base)+(alignment)-1) & ~((alignment)-1)) |
| 208 |
#define PADLEN(base, alignment) (PAD((base), (alignment)) - (base)) |
| 209 |
|
| 210 |
#define PADP(base, alignment) ((void *) PAD((intptr_t) (base), (alignment))) |
| 211 |
|
| 212 |
#ifndef NULL |
| 213 |
#define NULL ((void *)0) |
| 214 |
#endif |
| 215 |
|
| 216 |
#define STRING(s) #s |
| 217 |
|
| 218 |
#define XSTRING(s) STRING(s) |
| 219 |
|
| 220 |
#define MAX_QINT 0x7fffffff |
| 221 |
#define MIN_QINT (-MAX_QINT-1) |
| 222 |
|
| 223 |
#define ARRAY_LEN(x) (sizeof(x) / sizeof(*(x))) |
| 224 |
#define STRARRAY_LEN(x) (ARRAY_LEN(x) - 1) |
| 225 |
|
| 226 |
|
| 227 |
#define PITCH 0 // up / down |
| 228 |
#define YAW 1 // left / right |
| 229 |
#define ROLL 2 // fall over |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString |
| 234 |
#define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString |
| 235 |
#define MAX_TOKEN_CHARS 1024 // max length of an individual token |
| 236 |
|
| 237 |
#define MAX_INFO_STRING 1024 |
| 238 |
#define MAX_INFO_KEY 1024 |
| 239 |
#define MAX_INFO_VALUE 1024 |
| 240 |
|
| 241 |
#define BIG_INFO_STRING 8192 // used for system info key only |
| 242 |
#define BIG_INFO_KEY 8192 |
| 243 |
#define BIG_INFO_VALUE 8192 |
| 244 |
|
| 245 |
|
| 246 |
#define MAX_QPATH 64 // max length of a quake game pathname |
| 247 |
#ifdef PATH_MAX |
| 248 |
#define MAX_OSPATH PATH_MAX |
| 249 |
#else |
| 250 |
#define MAX_OSPATH 256 // max length of a filesystem pathname |
| 251 |
#endif |
| 252 |
|
| 253 |
#define MAX_NAME_LENGTH 32 // max length of a client name |
| 254 |
#define MAX_HOSTNAME_LENGTH 80 // max length of a host name |
| 255 |
|
| 256 |
#define MAX_SAY_TEXT 150 |
| 257 |
|
| 258 |
|
| 259 |
typedef enum { |
| 260 |
EXEC_NOW, |
| 261 |
|
| 262 |
EXEC_INSERT, |
| 263 |
EXEC_APPEND |
| 264 |
} cbufExec_t; |
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility |
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
typedef enum { |
| 275 |
PRINT_ALL, |
| 276 |
PRINT_DEVELOPER, |
| 277 |
PRINT_WARNING, |
| 278 |
PRINT_ERROR |
| 279 |
} printParm_t; |
| 280 |
|
| 281 |
|
| 282 |
#ifdef ERR_FATAL |
| 283 |
#undef ERR_FATAL // this is be defined in malloc.h |
| 284 |
#endif |
| 285 |
|
| 286 |
|
| 287 |
typedef enum { |
| 288 |
ERR_FATAL, |
| 289 |
ERR_DROP, |
| 290 |
ERR_SERVERDISCONNECT, |
| 291 |
ERR_DISCONNECT, |
| 292 |
ERR_NEED_CD |
| 293 |
} errorParm_t; |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
#define PROP_GAP_WIDTH 3 |
| 299 |
#define PROP_SPACE_WIDTH 8 |
| 300 |
#define PROP_HEIGHT 27 |
| 301 |
#define PROP_SMALL_SIZE_SCALE 0.75 |
| 302 |
|
| 303 |
#define BLINK_DIVISOR 200 |
| 304 |
#define PULSE_DIVISOR 75 |
| 305 |
|
| 306 |
#define UI_LEFT 0x00000000 // default |
| 307 |
#define UI_CENTER 0x00000001 |
| 308 |
#define UI_RIGHT 0x00000002 |
| 309 |
#define UI_FORMATMASK 0x00000007 |
| 310 |
#define UI_SMALLFONT 0x00000010 |
| 311 |
#define UI_BIGFONT 0x00000020 // default |
| 312 |
#define UI_GIANTFONT 0x00000040 |
| 313 |
#define UI_DROPSHADOW 0x00000800 |
| 314 |
#define UI_BLINK 0x00001000 |
| 315 |
#define UI_INVERSE 0x00002000 |
| 316 |
#define UI_PULSE 0x00004000 |
| 317 |
|
| 318 |
#if !defined(NDEBUG) && !defined(BSPC) |
| 319 |
#define HUNK_DEBUG |
| 320 |
#endif |
| 321 |
|
| 322 |
typedef enum { |
| 323 |
h_high, |
| 324 |
h_low, |
| 325 |
h_dontcare |
| 326 |
} ha_pref; |
| 327 |
|
| 328 |
#ifdef HUNK_DEBUG |
| 329 |
#define Hunk_Alloc( size, preference ) Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__) |
| 330 |
void *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line ); |
| 331 |
#else |
| 332 |
void *Hunk_Alloc( int size, ha_pref preference ); |
| 333 |
#endif |
| 334 |
|
| 335 |
#define Com_Memset memset |
| 336 |
#define Com_Memcpy memcpy |
| 337 |
|
| 338 |
#define CIN_system 1 |
| 339 |
#define CIN_loop 2 |
| 340 |
#define CIN_hold 4 |
| 341 |
#define CIN_silent 8 |
| 342 |
#define CIN_shader 16 |
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
typedef float vec_t; |
| 354 |
typedef vec_t vec2_t[2]; |
| 355 |
typedef vec_t vec3_t[3]; |
| 356 |
typedef vec_t vec4_t[4]; |
| 357 |
typedef vec_t vec5_t[5]; |
| 358 |
|
| 359 |
typedef vec_t quat_t[4]; |
| 360 |
|
| 361 |
typedef int fixed4_t; |
| 362 |
typedef int fixed8_t; |
| 363 |
typedef int fixed16_t; |
| 364 |
|
| 365 |
#ifndef M_PI |
| 366 |
#define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h |
| 367 |
#endif |
| 368 |
|
| 369 |
#define NUMVERTEXNORMALS 162 |
| 370 |
extern vec3_t bytedirs[NUMVERTEXNORMALS]; |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
#define SCREEN_WIDTH 640 |
| 375 |
#define SCREEN_HEIGHT 480 |
| 376 |
|
| 377 |
#define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) |
| 378 |
#define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) |
| 379 |
|
| 380 |
#define SMALLCHAR_WIDTH 8 |
| 381 |
#define SMALLCHAR_HEIGHT 16 |
| 382 |
|
| 383 |
#define BIGCHAR_WIDTH 16 |
| 384 |
#define BIGCHAR_HEIGHT 16 |
| 385 |
|
| 386 |
#define GIANTCHAR_WIDTH 32 |
| 387 |
#define GIANTCHAR_HEIGHT 48 |
| 388 |
|
| 389 |
extern vec4_t colorBlack; |
| 390 |
extern vec4_t colorRed; |
| 391 |
extern vec4_t colorGreen; |
| 392 |
extern vec4_t colorBlue; |
| 393 |
extern vec4_t colorYellow; |
| 394 |
extern vec4_t colorMagenta; |
| 395 |
extern vec4_t colorCyan; |
| 396 |
extern vec4_t colorWhite; |
| 397 |
extern vec4_t colorLtGrey; |
| 398 |
extern vec4_t colorMdGrey; |
| 399 |
extern vec4_t colorDkGrey; |
| 400 |
|
| 401 |
#define Q_COLOR_ESCAPE '^' |
| 402 |
qboolean Q_IsColorString(const char *p); |
| 403 |
|
| 404 |
#define COLOR_BLACK '0' |
| 405 |
#define COLOR_RED '1' |
| 406 |
#define COLOR_GREEN '2' |
| 407 |
#define COLOR_YELLOW '3' |
| 408 |
#define COLOR_BLUE '4' |
| 409 |
#define COLOR_CYAN '5' |
| 410 |
#define COLOR_MAGENTA '6' |
| 411 |
#define COLOR_WHITE '7' |
| 412 |
#define ColorIndexForNumber(c) ((c) & 0x07) |
| 413 |
#define ColorIndex(c) (ColorIndexForNumber((c) - '0')) |
| 414 |
|
| 415 |
#define S_COLOR_BLACK "^0" |
| 416 |
#define S_COLOR_RED "^1" |
| 417 |
#define S_COLOR_GREEN "^2" |
| 418 |
#define S_COLOR_YELLOW "^3" |
| 419 |
#define S_COLOR_BLUE "^4" |
| 420 |
#define S_COLOR_CYAN "^5" |
| 421 |
#define S_COLOR_MAGENTA "^6" |
| 422 |
#define S_COLOR_WHITE "^7" |
| 423 |
|
| 424 |
extern vec4_t g_color_table[8]; |
| 425 |
|
| 426 |
#define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b |
| 427 |
#define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a |
| 428 |
|
| 429 |
#define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F ) |
| 430 |
#define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI ) |
| 431 |
|
| 432 |
struct cplane_s; |
| 433 |
|
| 434 |
extern vec3_t vec3_origin; |
| 435 |
extern vec3_t axisDefault[3]; |
| 436 |
|
| 437 |
#define nanmask (255<<23) |
| 438 |
|
| 439 |
#define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) |
| 440 |
|
| 441 |
int Q_isnan(float x); |
| 442 |
|
| 443 |
#if idx64 |
| 444 |
extern long qftolsse(float f); |
| 445 |
extern int qvmftolsse(void); |
| 446 |
extern void qsnapvectorsse(vec3_t vec); |
| 447 |
|
| 448 |
#define Q_ftol qftolsse |
| 449 |
#define Q_SnapVector qsnapvectorsse |
| 450 |
|
| 451 |
extern int (*Q_VMftol)(void); |
| 452 |
#elif id386 |
| 453 |
extern long QDECL qftolx87(float f); |
| 454 |
extern long QDECL qftolsse(float f); |
| 455 |
extern int QDECL qvmftolx87(void); |
| 456 |
extern int QDECL qvmftolsse(void); |
| 457 |
extern void QDECL qsnapvectorx87(vec3_t vec); |
| 458 |
extern void QDECL qsnapvectorsse(vec3_t vec); |
| 459 |
|
| 460 |
extern long (QDECL *Q_ftol)(float f); |
| 461 |
extern int (QDECL *Q_VMftol)(void); |
| 462 |
extern void (QDECL *Q_SnapVector)(vec3_t vec); |
| 463 |
#else |
| 464 |
|
| 465 |
|
| 466 |
#define Q_ftol lrintf |
| 467 |
#define Q_SnapVector(vec)\ |
| 468 |
do\ |
| 469 |
{\ |
| 470 |
vec3_t *temp = (vec);\ |
| 471 |
\ |
| 472 |
(*temp)[0] = round((*temp)[0]);\ |
| 473 |
(*temp)[1] = round((*temp)[1]);\ |
| 474 |
(*temp)[2] = round((*temp)[2]);\ |
| 475 |
} while(0) |
| 476 |
#endif |
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
#if idppc |
| 496 |
|
| 497 |
static ID_INLINE float Q_rsqrt( float number ) { |
| 498 |
float x = 0.5f * number; |
| 499 |
float y; |
| 500 |
#ifdef __GNUC__ |
| 501 |
asm("frsqrte %0,%1" : "=f" (y) : "f" (number)); |
| 502 |
#else |
| 503 |
y = __frsqrte( number ); |
| 504 |
#endif |
| 505 |
return y * (1.5f - (x * y * y)); |
| 506 |
} |
| 507 |
|
| 508 |
#ifdef __GNUC__ |
| 509 |
static ID_INLINE float Q_fabs(float x) { |
| 510 |
float abs_x; |
| 511 |
|
| 512 |
asm("fabs %0,%1" : "=f" (abs_x) : "f" (x)); |
| 513 |
return abs_x; |
| 514 |
} |
| 515 |
#else |
| 516 |
#define Q_fabs __fabsf |
| 517 |
#endif |
| 518 |
|
| 519 |
#else |
| 520 |
float Q_fabs( float f ); |
| 521 |
float Q_rsqrt( float f ); |
| 522 |
#endif |
| 523 |
|
| 524 |
#define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) ) |
| 525 |
|
| 526 |
signed char ClampChar( int i ); |
| 527 |
signed short ClampShort( int i ); |
| 528 |
|
| 529 |
|
| 530 |
int DirToByte( vec3_t dir ); |
| 531 |
void ByteToDir( int b, vec3_t dir ); |
| 532 |
|
| 533 |
#if 1 |
| 534 |
|
| 535 |
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) |
| 536 |
#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) |
| 537 |
#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) |
| 538 |
#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) |
| 539 |
#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) |
| 540 |
#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s)) |
| 541 |
|
| 542 |
#else |
| 543 |
|
| 544 |
#define DotProduct(x,y) _DotProduct(x,y) |
| 545 |
#define VectorSubtract(a,b,c) _VectorSubtract(a,b,c) |
| 546 |
#define VectorAdd(a,b,c) _VectorAdd(a,b,c) |
| 547 |
#define VectorCopy(a,b) _VectorCopy(a,b) |
| 548 |
#define VectorScale(v, s, o) _VectorScale(v,s,o) |
| 549 |
#define VectorMA(v, s, b, o) _VectorMA(v,s,b,o) |
| 550 |
|
| 551 |
#endif |
| 552 |
|
| 553 |
#ifdef Q3_VM |
| 554 |
#ifdef VectorCopy |
| 555 |
#undef VectorCopy |
| 556 |
|
| 557 |
typedef struct { |
| 558 |
float v[3]; |
| 559 |
} vec3struct_t; |
| 560 |
#define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a) |
| 561 |
#endif |
| 562 |
#endif |
| 563 |
|
| 564 |
#define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) |
| 565 |
#define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) |
| 566 |
#define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) |
| 567 |
#define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) |
| 568 |
|
| 569 |
#define Byte4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) |
| 570 |
|
| 571 |
#define QuatCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) |
| 572 |
|
| 573 |
#define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} |
| 574 |
|
| 575 |
vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); |
| 576 |
void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); |
| 577 |
void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ); |
| 578 |
void _VectorCopy( const vec3_t in, vec3_t out ); |
| 579 |
void _VectorScale( const vec3_t in, float scale, vec3_t out ); |
| 580 |
void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ); |
| 581 |
|
| 582 |
unsigned ColorBytes3 (float r, float g, float b); |
| 583 |
unsigned ColorBytes4 (float r, float g, float b, float a); |
| 584 |
|
| 585 |
float NormalizeColor( const vec3_t in, vec3_t out ); |
| 586 |
|
| 587 |
float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); |
| 588 |
void ClearBounds( vec3_t mins, vec3_t maxs ); |
| 589 |
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); |
| 590 |
|
| 591 |
#if !defined( Q3_VM ) || ( defined( Q3_VM ) && defined( __Q3_VM_MATH ) ) |
| 592 |
static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) { |
| 593 |
if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { |
| 594 |
return 0; |
| 595 |
} |
| 596 |
return 1; |
| 597 |
} |
| 598 |
|
| 599 |
static ID_INLINE vec_t VectorLength( const vec3_t v ) { |
| 600 |
return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
| 601 |
} |
| 602 |
|
| 603 |
static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) { |
| 604 |
return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
| 605 |
} |
| 606 |
|
| 607 |
static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) { |
| 608 |
vec3_t v; |
| 609 |
|
| 610 |
VectorSubtract (p2, p1, v); |
| 611 |
return VectorLength( v ); |
| 612 |
} |
| 613 |
|
| 614 |
static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { |
| 615 |
vec3_t v; |
| 616 |
|
| 617 |
VectorSubtract (p2, p1, v); |
| 618 |
return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
static ID_INLINE void VectorNormalizeFast( vec3_t v ) |
| 624 |
{ |
| 625 |
float ilength; |
| 626 |
|
| 627 |
ilength = Q_rsqrt( DotProduct( v, v ) ); |
| 628 |
|
| 629 |
v[0] *= ilength; |
| 630 |
v[1] *= ilength; |
| 631 |
v[2] *= ilength; |
| 632 |
} |
| 633 |
|
| 634 |
static ID_INLINE void VectorInverse( vec3_t v ){ |
| 635 |
v[0] = -v[0]; |
| 636 |
v[1] = -v[1]; |
| 637 |
v[2] = -v[2]; |
| 638 |
} |
| 639 |
|
| 640 |
static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { |
| 641 |
cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; |
| 642 |
cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; |
| 643 |
cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; |
| 644 |
} |
| 645 |
|
| 646 |
#else |
| 647 |
int VectorCompare( const vec3_t v1, const vec3_t v2 ); |
| 648 |
|
| 649 |
vec_t VectorLength( const vec3_t v ); |
| 650 |
|
| 651 |
vec_t VectorLengthSquared( const vec3_t v ); |
| 652 |
|
| 653 |
vec_t Distance( const vec3_t p1, const vec3_t p2 ); |
| 654 |
|
| 655 |
vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ); |
| 656 |
|
| 657 |
void VectorNormalizeFast( vec3_t v ); |
| 658 |
|
| 659 |
void VectorInverse( vec3_t v ); |
| 660 |
|
| 661 |
void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ); |
| 662 |
|
| 663 |
#endif |
| 664 |
|
| 665 |
vec_t VectorNormalize (vec3_t v); |
| 666 |
vec_t VectorNormalize2( const vec3_t v, vec3_t out ); |
| 667 |
void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ); |
| 668 |
void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ); |
| 669 |
int Q_log2(int val); |
| 670 |
|
| 671 |
float Q_acos(float c); |
| 672 |
|
| 673 |
int Q_rand( int *seed ); |
| 674 |
float Q_random( int *seed ); |
| 675 |
float Q_crandom( int *seed ); |
| 676 |
|
| 677 |
#define random() ((rand () & 0x7fff) / ((float)0x7fff)) |
| 678 |
#define crandom() (2.0 * (random() - 0.5)) |
| 679 |
|
| 680 |
void vectoangles( const vec3_t value1, vec3_t angles); |
| 681 |
void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ); |
| 682 |
|
| 683 |
void AxisClear( vec3_t axis[3] ); |
| 684 |
void AxisCopy( vec3_t in[3], vec3_t out[3] ); |
| 685 |
|
| 686 |
void SetPlaneSignbits( struct cplane_s *out ); |
| 687 |
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane); |
| 688 |
|
| 689 |
qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs, |
| 690 |
const vec3_t mins2, const vec3_t maxs2); |
| 691 |
qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs, |
| 692 |
const vec3_t origin, vec_t radius); |
| 693 |
qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs, |
| 694 |
const vec3_t origin); |
| 695 |
|
| 696 |
float AngleMod(float a); |
| 697 |
float LerpAngle (float from, float to, float frac); |
| 698 |
float AngleSubtract( float a1, float a2 ); |
| 699 |
void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ); |
| 700 |
|
| 701 |
float AngleNormalize360 ( float angle ); |
| 702 |
float AngleNormalize180 ( float angle ); |
| 703 |
float AngleDelta ( float angle1, float angle2 ); |
| 704 |
|
| 705 |
qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ); |
| 706 |
void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); |
| 707 |
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); |
| 708 |
void RotateAroundDirection( vec3_t axis[3], float yaw ); |
| 709 |
void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up ); |
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]); |
| 715 |
void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); |
| 716 |
void PerpendicularVector( vec3_t dst, const vec3_t src ); |
| 717 |
|
| 718 |
#ifndef MAX |
| 719 |
#define MAX(x,y) ((x)>(y)?(x):(y)) |
| 720 |
#endif |
| 721 |
|
| 722 |
#ifndef MIN |
| 723 |
#define MIN(x,y) ((x)<(y)?(x):(y)) |
| 724 |
#endif |
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
float Com_Clamp( float min, float max, float value ); |
| 729 |
|
| 730 |
char *COM_SkipPath( char *pathname ); |
| 731 |
const char *COM_GetExtension( const char *name ); |
| 732 |
void COM_StripExtension(const char *in, char *out, int destsize); |
| 733 |
qboolean COM_CompareExtension(const char *in, const char *ext); |
| 734 |
void COM_DefaultExtension( char *path, int maxSize, const char *extension ); |
| 735 |
|
| 736 |
void COM_BeginParseSession( const char *name ); |
| 737 |
int COM_GetCurrentParseLine( void ); |
| 738 |
char *COM_Parse( char **data_p ); |
| 739 |
char *COM_ParseExt( char **data_p, qboolean allowLineBreak ); |
| 740 |
int COM_Compress( char *data_p ); |
| 741 |
void COM_ParseError( char *format, ... ) Q_PRINTF_FUNC(1, 2); |
| 742 |
void COM_ParseWarning( char *format, ... ) Q_PRINTF_FUNC(1, 2); |
| 743 |
|
| 744 |
|
| 745 |
#define MAX_TOKENLENGTH 1024 |
| 746 |
|
| 747 |
#ifndef TT_STRING |
| 748 |
|
| 749 |
#define TT_STRING 1 // string |
| 750 |
#define TT_LITERAL 2 // literal |
| 751 |
#define TT_NUMBER 3 // number |
| 752 |
#define TT_NAME 4 // name |
| 753 |
#define TT_PUNCTUATION 5 // punctuation |
| 754 |
#endif |
| 755 |
|
| 756 |
typedef struct pc_token_s |
| 757 |
{ |
| 758 |
int type; |
| 759 |
int subtype; |
| 760 |
int intvalue; |
| 761 |
float floatvalue; |
| 762 |
char string[MAX_TOKENLENGTH]; |
| 763 |
} pc_token_t; |
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
void COM_MatchToken( char**buf_p, char *match ); |
| 768 |
|
| 769 |
qboolean SkipBracedSection (char **program, int depth); |
| 770 |
void SkipRestOfLine ( char **data ); |
| 771 |
|
| 772 |
void Parse1DMatrix (char **buf_p, int x, float *m); |
| 773 |
void Parse2DMatrix (char **buf_p, int y, int x, float *m); |
| 774 |
void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m); |
| 775 |
int Com_HexStrToInt( const char *str ); |
| 776 |
|
| 777 |
int QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) Q_PRINTF_FUNC(3, 4); |
| 778 |
|
| 779 |
char *Com_SkipTokens( char *s, int numTokens, char *sep ); |
| 780 |
char *Com_SkipCharset( char *s, char *sep ); |
| 781 |
|
| 782 |
void Com_RandomBytes( byte *string, int len ); |
| 783 |
|
| 784 |
|
| 785 |
typedef enum { |
| 786 |
FS_READ, |
| 787 |
FS_WRITE, |
| 788 |
FS_APPEND, |
| 789 |
FS_APPEND_SYNC |
| 790 |
} fsMode_t; |
| 791 |
|
| 792 |
typedef enum { |
| 793 |
FS_SEEK_CUR, |
| 794 |
FS_SEEK_END, |
| 795 |
FS_SEEK_SET |
| 796 |
} fsOrigin_t; |
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
int Q_isprint( int c ); |
| 801 |
int Q_islower( int c ); |
| 802 |
int Q_isupper( int c ); |
| 803 |
int Q_isalpha( int c ); |
| 804 |
qboolean Q_isanumber( const char *s ); |
| 805 |
qboolean Q_isintegral( float f ); |
| 806 |
|
| 807 |
|
| 808 |
int Q_stricmp (const char *s1, const char *s2); |
| 809 |
int Q_strncmp (const char *s1, const char *s2, int n); |
| 810 |
int Q_stricmpn (const char *s1, const char *s2, int n); |
| 811 |
char *Q_strlwr( char *s1 ); |
| 812 |
char *Q_strupr( char *s1 ); |
| 813 |
const char *Q_stristr( const char *s, const char *find); |
| 814 |
|
| 815 |
|
| 816 |
void Q_strncpyz( char *dest, const char *src, int destsize ); |
| 817 |
void Q_strcat( char *dest, int size, const char *src ); |
| 818 |
|
| 819 |
|
| 820 |
int Q_PrintStrlen( const char *string ); |
| 821 |
|
| 822 |
char *Q_CleanStr( char *string ); |
| 823 |
|
| 824 |
int Q_CountChar(const char *string, char tocount); |
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
typedef struct |
| 831 |
{ |
| 832 |
byte b0; |
| 833 |
byte b1; |
| 834 |
byte b2; |
| 835 |
byte b3; |
| 836 |
byte b4; |
| 837 |
byte b5; |
| 838 |
byte b6; |
| 839 |
byte b7; |
| 840 |
} qint64; |
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
|
| 845 |
|
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
|
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
char * QDECL va(char *format, ...) Q_PRINTF_FUNC(1, 2); |
| 856 |
|
| 857 |
#define TRUNCATE_LENGTH 64 |
| 858 |
void Com_TruncateLongString( char *buffer, const char *s ); |
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
char *Info_ValueForKey( const char *s, const char *key ); |
| 866 |
void Info_RemoveKey( char *s, const char *key ); |
| 867 |
void Info_RemoveKey_Big( char *s, const char *key ); |
| 868 |
void Info_SetValueForKey( char *s, const char *key, const char *value ); |
| 869 |
void Info_SetValueForKey_Big( char *s, const char *key, const char *value ); |
| 870 |
qboolean Info_Validate( const char *s ); |
| 871 |
void Info_NextPair( const char **s, char *key, char *value ); |
| 872 |
|
| 873 |
|
| 874 |
void QDECL Com_Error( int level, const char *error, ... ) Q_NO_RETURN Q_PRINTF_FUNC(2, 3); |
| 875 |
void QDECL Com_Printf( const char *msg, ... ) Q_PRINTF_FUNC(1, 2); |
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
#define CVAR_ARCHIVE 0x0001 // set to cause it to be saved to vars.rc |
| 890 |
|
| 891 |
|
| 892 |
#define CVAR_USERINFO 0x0002 // sent to server on connect or change |
| 893 |
#define CVAR_SERVERINFO 0x0004 // sent in response to front end requests |
| 894 |
#define CVAR_SYSTEMINFO 0x0008 // these cvars will be duplicated on all clients |
| 895 |
#define CVAR_INIT 0x0010 // don't allow change from console at all, |
| 896 |
|
| 897 |
#define CVAR_LATCH 0x0020 // will only change when C code next does |
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
#define CVAR_ROM 0x0040 // display only, cannot be set by user at all |
| 903 |
#define CVAR_USER_CREATED 0x0080 // created by a set command |
| 904 |
#define CVAR_TEMP 0x0100 // can be set even when cheats are disabled, but is not archived |
| 905 |
#define CVAR_CHEAT 0x0200 // can not be changed if cheats are disabled |
| 906 |
#define CVAR_NORESTART 0x0400 // do not clear when a cvar_restart is issued |
| 907 |
|
| 908 |
#define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to. |
| 909 |
#define CVAR_VM_CREATED 0x1000 // cvar was created exclusively in one of the VMs. |
| 910 |
#define CVAR_PROTECTED 0x2000 // prevent modifying this var from VMs or the server |
| 911 |
|
| 912 |
#define CVAR_MODIFIED 0x40000000 // Cvar was modified |
| 913 |
#define CVAR_NONEXISTENT 0x80000000 // Cvar doesn't exist. |
| 914 |
|
| 915 |
|
| 916 |
typedef struct cvar_s cvar_t; |
| 917 |
|
| 918 |
struct cvar_s { |
| 919 |
char *name; |
| 920 |
char *string; |
| 921 |
char *resetString; |
| 922 |
char *latchedString; |
| 923 |
int flags; |
| 924 |
qboolean modified; |
| 925 |
int modificationCount; |
| 926 |
float value; |
| 927 |
int integer; |
| 928 |
qboolean validate; |
| 929 |
qboolean integral; |
| 930 |
float min; |
| 931 |
float max; |
| 932 |
char *description; |
| 933 |
|
| 934 |
cvar_t *next; |
| 935 |
cvar_t *prev; |
| 936 |
cvar_t *hashNext; |
| 937 |
cvar_t *hashPrev; |
| 938 |
int hashIndex; |
| 939 |
}; |
| 940 |
|
| 941 |
#define MAX_CVAR_VALUE_STRING 256 |
| 942 |
|
| 943 |
typedef int cvarHandle_t; |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
typedef struct { |
| 948 |
cvarHandle_t handle; |
| 949 |
int modificationCount; |
| 950 |
float value; |
| 951 |
int integer; |
| 952 |
char string[MAX_CVAR_VALUE_STRING]; |
| 953 |
} vmCvar_t; |
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
#define VOIP_SPATIAL 0x01 // spatialized voip message |
| 966 |
#define VOIP_DIRECT 0x02 // non-spatialized voip message |
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
#define VOIP_FLAGCNT 2 |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
#include "surfaceflags.h" |
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
#define PLANE_X 0 |
| 985 |
#define PLANE_Y 1 |
| 986 |
#define PLANE_Z 2 |
| 987 |
#define PLANE_NON_AXIAL 3 |
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
#define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) ) |
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
typedef struct cplane_s { |
| 1001 |
vec3_t normal; |
| 1002 |
float dist; |
| 1003 |
byte type; |
| 1004 |
byte signbits; |
| 1005 |
byte pad[2]; |
| 1006 |
} cplane_t; |
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
typedef struct { |
| 1011 |
qboolean allsolid; |
| 1012 |
qboolean startsolid; |
| 1013 |
float fraction; |
| 1014 |
vec3_t endpos; |
| 1015 |
cplane_t plane; |
| 1016 |
int surfaceFlags; |
| 1017 |
int contents; |
| 1018 |
int entityNum; |
| 1019 |
} trace_t; |
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
typedef struct { |
| 1027 |
int firstPoint; |
| 1028 |
int numPoints; |
| 1029 |
} markFragment_t; |
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
typedef struct { |
| 1034 |
vec3_t origin; |
| 1035 |
vec3_t axis[3]; |
| 1036 |
} orientation_t; |
| 1037 |
|
| 1038 |
|
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
#define KEYCATCH_CONSOLE 0x0001 |
| 1044 |
#define KEYCATCH_UI 0x0002 |
| 1045 |
#define KEYCATCH_MESSAGE 0x0004 |
| 1046 |
#define KEYCATCH_CGAME 0x0008 |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
typedef enum { |
| 1053 |
CHAN_AUTO, |
| 1054 |
CHAN_LOCAL, |
| 1055 |
CHAN_WEAPON, |
| 1056 |
CHAN_VOICE, |
| 1057 |
CHAN_ITEM, |
| 1058 |
CHAN_BODY, |
| 1059 |
CHAN_LOCAL_SOUND, |
| 1060 |
CHAN_ANNOUNCER |
| 1061 |
} soundChannel_t; |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
#define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) |
| 1073 |
#define SHORT2ANGLE(x) ((x)*(360.0/65536)) |
| 1074 |
|
| 1075 |
#define SNAPFLAG_RATE_DELAYED 1 |
| 1076 |
#define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies |
| 1077 |
#define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected |
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
#define MAX_CLIENTS 64 // absolute limit |
| 1083 |
#define MAX_LOCATIONS 64 |
| 1084 |
|
| 1085 |
#define GENTITYNUM_BITS 10 // don't need to send any more |
| 1086 |
#define MAX_GENTITIES (1<<GENTITYNUM_BITS) |
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
#define ENTITYNUM_NONE (MAX_GENTITIES-1) |
| 1092 |
#define ENTITYNUM_WORLD (MAX_GENTITIES-2) |
| 1093 |
#define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-2) |
| 1094 |
|
| 1095 |
|
| 1096 |
#define MAX_MODELS 256 // these are sent over the net as 8 bits |
| 1097 |
#define MAX_SOUNDS 256 // so they cannot be blindly increased |
| 1098 |
|
| 1099 |
|
| 1100 |
#define MAX_CONFIGSTRINGS 1024 |
| 1101 |
|
| 1102 |
|
| 1103 |
|
| 1104 |
#define CS_SERVERINFO 0 // an info string with all the serverinfo cvars |
| 1105 |
#define CS_SYSTEMINFO 1 // an info string for server system to client system configuration (timescale, etc) |
| 1106 |
|
| 1107 |
#define RESERVED_CONFIGSTRINGS 2 // game can't modify below this, only the system can |
| 1108 |
|
| 1109 |
#define MAX_GAMESTATE_CHARS 16000 |
| 1110 |
typedef struct { |
| 1111 |
int stringOffsets[MAX_CONFIGSTRINGS]; |
| 1112 |
char stringData[MAX_GAMESTATE_CHARS]; |
| 1113 |
int dataCount; |
| 1114 |
} gameState_t; |
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
#define MAX_STATS 16 |
| 1120 |
#define MAX_PERSISTANT 16 |
| 1121 |
#define MAX_POWERUPS 16 |
| 1122 |
#define MAX_WEAPONS 16 |
| 1123 |
|
| 1124 |
#define MAX_PS_EVENTS 2 |
| 1125 |
|
| 1126 |
#define PS_PMOVEFRAMECOUNTBITS 6 |
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
typedef struct playerState_s { |
| 1139 |
int commandTime; |
| 1140 |
int pm_type; |
| 1141 |
int bobCycle; |
| 1142 |
int pm_flags; |
| 1143 |
int pm_time; |
| 1144 |
|
| 1145 |
vec3_t origin; |
| 1146 |
vec3_t velocity; |
| 1147 |
int weaponTime; |
| 1148 |
int gravity; |
| 1149 |
int speed; |
| 1150 |
int delta_angles[3]; |
| 1151 |
|
| 1152 |
|
| 1153 |
int groundEntityNum; |
| 1154 |
|
| 1155 |
int legsTimer; |
| 1156 |
int legsAnim; |
| 1157 |
|
| 1158 |
int torsoTimer; |
| 1159 |
int torsoAnim; |
| 1160 |
|
| 1161 |
int movementDir; |
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
vec3_t grapplePoint; |
| 1167 |
|
| 1168 |
int eFlags; |
| 1169 |
|
| 1170 |
int eventSequence; |
| 1171 |
int events[MAX_PS_EVENTS]; |
| 1172 |
int eventParms[MAX_PS_EVENTS]; |
| 1173 |
|
| 1174 |
int externalEvent; |
| 1175 |
int externalEventParm; |
| 1176 |
int externalEventTime; |
| 1177 |
|
| 1178 |
int clientNum; |
| 1179 |
int weapon; |
| 1180 |
int weaponstate; |
| 1181 |
|
| 1182 |
vec3_t viewangles; |
| 1183 |
int viewheight; |
| 1184 |
|
| 1185 |
|
| 1186 |
int damageEvent; |
| 1187 |
int damageYaw; |
| 1188 |
int damagePitch; |
| 1189 |
int damageCount; |
| 1190 |
|
| 1191 |
int stats[MAX_STATS]; |
| 1192 |
int persistant[MAX_PERSISTANT]; |
| 1193 |
int powerups[MAX_POWERUPS]; |
| 1194 |
int ammo[MAX_WEAPONS]; |
| 1195 |
|
| 1196 |
int generic1; |
| 1197 |
int loopSound; |
| 1198 |
int jumppad_ent; |
| 1199 |
|
| 1200 |
|
| 1201 |
int ping; |
| 1202 |
int pmove_framecount; |
| 1203 |
int jumppad_frame; |
| 1204 |
int entityEventSequence; |
| 1205 |
} playerState_t; |
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
#define BUTTON_ATTACK 1 |
| 1216 |
#define BUTTON_TALK 2 // displays talk balloon and disables actions |
| 1217 |
#define BUTTON_USE_HOLDABLE 4 |
| 1218 |
#define BUTTON_GESTURE 8 |
| 1219 |
#define BUTTON_WALKING 16 // walking can't just be inferred from MOVE_RUN |
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
#define BUTTON_AFFIRMATIVE 32 |
| 1225 |
#define BUTTON_NEGATIVE 64 |
| 1226 |
|
| 1227 |
#define BUTTON_GETFLAG 128 |
| 1228 |
#define BUTTON_GUARDBASE 256 |
| 1229 |
#define BUTTON_PATROL 512 |
| 1230 |
#define BUTTON_FOLLOWME 1024 |
| 1231 |
|
| 1232 |
#define BUTTON_ANY 2048 // any key whatsoever |
| 1233 |
|
| 1234 |
#define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN, |
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
typedef struct usercmd_s { |
| 1239 |
int serverTime; |
| 1240 |
int angles[3]; |
| 1241 |
int buttons; |
| 1242 |
byte weapon; |
| 1243 |
signed char forwardmove, rightmove, upmove; |
| 1244 |
} usercmd_t; |
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
#define SOLID_BMODEL 0xffffff |
| 1250 |
|
| 1251 |
typedef enum { |
| 1252 |
TR_STATIONARY, |
| 1253 |
TR_INTERPOLATE, |
| 1254 |
TR_LINEAR, |
| 1255 |
TR_LINEAR_STOP, |
| 1256 |
TR_SINE, |
| 1257 |
TR_GRAVITY |
| 1258 |
} trType_t; |
| 1259 |
|
| 1260 |
typedef struct { |
| 1261 |
trType_t trType; |
| 1262 |
int trTime; |
| 1263 |
int trDuration; |
| 1264 |
vec3_t trBase; |
| 1265 |
vec3_t trDelta; |
| 1266 |
} trajectory_t; |
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
typedef struct entityState_s { |
| 1276 |
int number; |
| 1277 |
int eType; |
| 1278 |
int eFlags; |
| 1279 |
|
| 1280 |
trajectory_t pos; |
| 1281 |
trajectory_t apos; |
| 1282 |
|
| 1283 |
int time; |
| 1284 |
int time2; |
| 1285 |
|
| 1286 |
vec3_t origin; |
| 1287 |
vec3_t origin2; |
| 1288 |
|
| 1289 |
vec3_t angles; |
| 1290 |
vec3_t angles2; |
| 1291 |
|
| 1292 |
int otherEntityNum; |
| 1293 |
int otherEntityNum2; |
| 1294 |
|
| 1295 |
int groundEntityNum; |
| 1296 |
|
| 1297 |
int constantLight; |
| 1298 |
int loopSound; |
| 1299 |
|
| 1300 |
int modelindex; |
| 1301 |
int modelindex2; |
| 1302 |
int clientNum; |
| 1303 |
int frame; |
| 1304 |
|
| 1305 |
int solid; |
| 1306 |
|
| 1307 |
int event; |
| 1308 |
int eventParm; |
| 1309 |
|
| 1310 |
|
| 1311 |
int powerups; |
| 1312 |
int weapon; |
| 1313 |
int legsAnim; |
| 1314 |
int torsoAnim; |
| 1315 |
|
| 1316 |
int generic1; |
| 1317 |
} entityState_t; |
| 1318 |
|
| 1319 |
typedef enum { |
| 1320 |
CA_UNINITIALIZED, |
| 1321 |
CA_DISCONNECTED, |
| 1322 |
CA_AUTHORIZING, |
| 1323 |
CA_CONNECTING, |
| 1324 |
CA_CHALLENGING, |
| 1325 |
CA_CONNECTED, |
| 1326 |
CA_LOADING, |
| 1327 |
CA_PRIMED, |
| 1328 |
CA_ACTIVE, |
| 1329 |
CA_CINEMATIC |
| 1330 |
} connstate_t; |
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
#define GLYPH_START 0 |
| 1335 |
#define GLYPH_END 255 |
| 1336 |
#define GLYPH_CHARSTART 32 |
| 1337 |
#define GLYPH_CHAREND 127 |
| 1338 |
#define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1 |
| 1339 |
typedef struct { |
| 1340 |
int height; |
| 1341 |
int top; |
| 1342 |
int bottom; |
| 1343 |
int pitch; |
| 1344 |
int xSkip; |
| 1345 |
int imageWidth; |
| 1346 |
int imageHeight; |
| 1347 |
float s; |
| 1348 |
float t; |
| 1349 |
float s2; |
| 1350 |
float t2; |
| 1351 |
qhandle_t glyph; |
| 1352 |
char shaderName[32]; |
| 1353 |
} glyphInfo_t; |
| 1354 |
|
| 1355 |
typedef struct { |
| 1356 |
glyphInfo_t glyphs [GLYPHS_PER_FONT]; |
| 1357 |
float glyphScale; |
| 1358 |
char name[MAX_QPATH]; |
| 1359 |
} fontInfo_t; |
| 1360 |
|
| 1361 |
#define Square(x) ((x)*(x)) |
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
typedef struct qtime_s { |
| 1368 |
int tm_sec; |
| 1369 |
int tm_min; |
| 1370 |
int tm_hour; |
| 1371 |
int tm_mday; |
| 1372 |
int tm_mon; |
| 1373 |
int tm_year; |
| 1374 |
int tm_wday; |
| 1375 |
int tm_yday; |
| 1376 |
int tm_isdst; |
| 1377 |
} qtime_t; |
| 1378 |
|
| 1379 |
|
| 1380 |
|
| 1381 |
|
| 1382 |
#define AS_LOCAL 0 |
| 1383 |
#define AS_MPLAYER 1 |
| 1384 |
#define AS_GLOBAL 2 |
| 1385 |
#define AS_FAVORITES 3 |
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
typedef enum { |
| 1390 |
FMV_IDLE, |
| 1391 |
FMV_PLAY, |
| 1392 |
FMV_EOF, |
| 1393 |
FMV_ID_BLT, |
| 1394 |
FMV_ID_IDLE, |
| 1395 |
FMV_LOOPED, |
| 1396 |
FMV_ID_WAIT |
| 1397 |
} e_status; |
| 1398 |
|
| 1399 |
typedef enum _flag_status { |
| 1400 |
FLAG_ATBASE = 0, |
| 1401 |
FLAG_TAKEN, |
| 1402 |
FLAG_TAKEN_RED, |
| 1403 |
FLAG_TAKEN_BLUE, |
| 1404 |
FLAG_DROPPED |
| 1405 |
} flagStatus_t; |
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
#define MAX_GLOBAL_SERVERS 4096 |
| 1410 |
#define MAX_OTHER_SERVERS 128 |
| 1411 |
#define MAX_PINGREQUESTS 32 |
| 1412 |
#define MAX_SERVERSTATUSREQUESTS 16 |
| 1413 |
|
| 1414 |
#define SAY_ALL 0 |
| 1415 |
#define SAY_TEAM 1 |
| 1416 |
#define SAY_TELL 2 |
| 1417 |
|
| 1418 |
#define CDKEY_LEN 16 |
| 1419 |
#define CDCHKSUM_LEN 2 |
| 1420 |
|
| 1421 |
|
| 1422 |
#define LERP( a, b, w ) ( ( a ) * ( 1.0f - ( w ) ) + ( b ) * ( w ) ) |
| 1423 |
#define LUMA( red, green, blue ) ( 0.2126f * ( red ) + 0.7152f * ( green ) + 0.0722f * ( blue ) ) |
| 1424 |
|
| 1425 |
#endif |