| 1 | /* |
|---|
| 2 | =========================================================================== |
|---|
| 3 | Copyright (C) 1999-2005 Id Software, Inc. |
|---|
| 4 | Copyright (C) 2000-2006 Tim Angus |
|---|
| 5 | |
|---|
| 6 | This file is part of Tremulous. |
|---|
| 7 | |
|---|
| 8 | Tremulous is free software; you can redistribute it |
|---|
| 9 | and/or modify it under the terms of the GNU General Public License as |
|---|
| 10 | published by the Free Software Foundation; either version 2 of the License, |
|---|
| 11 | or (at your option) any later version. |
|---|
| 12 | |
|---|
| 13 | Tremulous is distributed in the hope that it will be |
|---|
| 14 | useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 16 | GNU General Public License for more details. |
|---|
| 17 | |
|---|
| 18 | You should have received a copy of the GNU General Public License |
|---|
| 19 | along with Tremulous; if not, write to the Free Software |
|---|
| 20 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 21 | =========================================================================== |
|---|
| 22 | */ |
|---|
| 23 | // |
|---|
| 24 | #ifndef __Q_SHARED_H |
|---|
| 25 | #define __Q_SHARED_H |
|---|
| 26 | |
|---|
| 27 | // q_shared.h -- included first by ALL program modules. |
|---|
| 28 | // A user mod should never modify this file |
|---|
| 29 | |
|---|
| 30 | #define PRODUCT_NAME "tremulous" |
|---|
| 31 | |
|---|
| 32 | #ifndef PRODUCT_VERSION |
|---|
| 33 | #define PRODUCT_VERSION "DnC-Eggy-r2" |
|---|
| 34 | #endif |
|---|
| 35 | |
|---|
| 36 | #ifdef SVN_VERSION |
|---|
| 37 | # define Q3_VERSION PRODUCT_NAME " " SVN_VERSION |
|---|
| 38 | #else |
|---|
| 39 | # define Q3_VERSION PRODUCT_NAME " " PRODUCT_VERSION |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | #define CLIENT_WINDOW_TITLE "Tremulous " PRODUCT_VERSION |
|---|
| 43 | #define CLIENT_WINDOW_MIN_TITLE "Tremulous" |
|---|
| 44 | |
|---|
| 45 | #define FULL_VERSION Q3_VERSION " " PLATFORM_STRING " " __DATE__ |
|---|
| 46 | |
|---|
| 47 | #define MAX_TEAMNAME 32 |
|---|
| 48 | |
|---|
| 49 | #ifdef _MSC_VER |
|---|
| 50 | |
|---|
| 51 | #pragma warning(disable : 4018) // signed/unsigned mismatch |
|---|
| 52 | #pragma warning(disable : 4032) |
|---|
| 53 | #pragma warning(disable : 4051) |
|---|
| 54 | #pragma warning(disable : 4057) // slightly different base types |
|---|
| 55 | #pragma warning(disable : 4100) // unreferenced formal parameter |
|---|
| 56 | #pragma warning(disable : 4115) |
|---|
| 57 | #pragma warning(disable : 4125) // decimal digit terminates octal escape sequence |
|---|
| 58 | #pragma warning(disable : 4127) // conditional expression is constant |
|---|
| 59 | #pragma warning(disable : 4136) |
|---|
| 60 | #pragma warning(disable : 4152) // nonstandard extension, function/data pointer conversion in expression |
|---|
| 61 | //#pragma warning(disable : 4201) |
|---|
| 62 | //#pragma warning(disable : 4214) |
|---|
| 63 | #pragma warning(disable : 4244) |
|---|
| 64 | #pragma warning(disable : 4142) // benign redefinition |
|---|
| 65 | //#pragma warning(disable : 4305) // truncation from const double to float |
|---|
| 66 | //#pragma warning(disable : 4310) // cast truncates constant value |
|---|
| 67 | //#pragma warning(disable: 4505) // unreferenced local function has been removed |
|---|
| 68 | #pragma warning(disable : 4514) |
|---|
| 69 | #pragma warning(disable : 4702) // unreachable code |
|---|
| 70 | #pragma warning(disable : 4711) // selected for automatic inline expansion |
|---|
| 71 | #pragma warning(disable : 4220) // varargs matches remaining parameters |
|---|
| 72 | //#pragma intrinsic( memset, memcpy ) |
|---|
| 73 | #endif |
|---|
| 74 | |
|---|
| 75 | //Ignore __attribute__ on non-gcc platforms |
|---|
| 76 | #ifndef __GNUC__ |
|---|
| 77 | #ifndef __attribute__ |
|---|
| 78 | #define __attribute__(x) |
|---|
| 79 | #endif |
|---|
| 80 | #endif |
|---|
| 81 | |
|---|
| 82 | /********************************************************************** |
|---|
| 83 | VM Considerations |
|---|
| 84 | |
|---|
| 85 | The VM can not use the standard system headers because we aren't really |
|---|
| 86 | using the compiler they were meant for. We use bg_lib.h which contains |
|---|
| 87 | prototypes for the functions we define for our own use in bg_lib.c. |
|---|
| 88 | |
|---|
| 89 | When writing mods, please add needed headers HERE, do not start including |
|---|
| 90 | stuff like <stdio.h> in the various .c files that make up each of the VMs |
|---|
| 91 | since you will be including system headers files can will have issues. |
|---|
| 92 | |
|---|
| 93 | Remember, if you use a C library function that is not defined in bg_lib.c, |
|---|
| 94 | you will have to add your own version for support in the VM. |
|---|
| 95 | |
|---|
| 96 | **********************************************************************/ |
|---|
| 97 | |
|---|
| 98 | #ifdef Q3_VM |
|---|
| 99 | |
|---|
| 100 | #include "../game/bg_lib.h" |
|---|
| 101 | |
|---|
| 102 | #else |
|---|
| 103 | |
|---|
| 104 | #include <assert.h> |
|---|
| 105 | #include <math.h> |
|---|
| 106 | #include <stdio.h> |
|---|
| 107 | #include <stdarg.h> |
|---|
| 108 | #include <string.h> |
|---|
| 109 | #include <stdlib.h> |
|---|
| 110 | #include <time.h> |
|---|
| 111 | #include <ctype.h> |
|---|
| 112 | #include <limits.h> |
|---|
| 113 | |
|---|
| 114 | #endif |
|---|
| 115 | |
|---|
| 116 | #include "q_platform.h" |
|---|
| 117 | |
|---|
| 118 | //============================================================= |
|---|
| 119 | |
|---|
| 120 | #ifdef Q3_VM |
|---|
| 121 | typedef int intptr_t; |
|---|
| 122 | #else |
|---|
| 123 | #ifndef _MSC_VER |
|---|
| 124 | #include <stdint.h> |
|---|
| 125 | #else |
|---|
| 126 | #include <io.h> |
|---|
| 127 | typedef __int64 int64_t; |
|---|
| 128 | typedef __int32 int32_t; |
|---|
| 129 | typedef __int16 int16_t; |
|---|
| 130 | typedef __int8 int8_t; |
|---|
| 131 | typedef unsigned __int64 uint64_t; |
|---|
| 132 | typedef unsigned __int32 uint32_t; |
|---|
| 133 | typedef unsigned __int16 uint16_t; |
|---|
| 134 | typedef unsigned __int8 uint8_t; |
|---|
| 135 | #endif |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | typedef unsigned char byte; |
|---|
| 139 | |
|---|
| 140 | typedef enum {qfalse, qtrue} qboolean; |
|---|
| 141 | |
|---|
| 142 | typedef int qhandle_t; |
|---|
| 143 | typedef int sfxHandle_t; |
|---|
| 144 | typedef int fileHandle_t; |
|---|
| 145 | typedef int clipHandle_t; |
|---|
| 146 | |
|---|
| 147 | #define PAD(x,y) (((x)+(y)-1) & ~((y)-1)) |
|---|
| 148 | |
|---|
| 149 | #ifdef __GNUC__ |
|---|
| 150 | #define ALIGN(x) __attribute__((aligned(x))) |
|---|
| 151 | #else |
|---|
| 152 | #define ALIGN(x) |
|---|
| 153 | #endif |
|---|
| 154 | |
|---|
| 155 | #ifndef NULL |
|---|
| 156 | #define NULL ((void *)0) |
|---|
| 157 | #endif |
|---|
| 158 | |
|---|
| 159 | #define MAX_QINT 0x7fffffff |
|---|
| 160 | #define MIN_QINT (-MAX_QINT-1) |
|---|
| 161 | |
|---|
| 162 | |
|---|
| 163 | // angle indexes |
|---|
| 164 | #define PITCH 0 // up / down |
|---|
| 165 | #define YAW 1 // left / right |
|---|
| 166 | #define ROLL 2 // fall over |
|---|
| 167 | |
|---|
| 168 | // the game guarantees that no string from the network will ever |
|---|
| 169 | // exceed MAX_STRING_CHARS |
|---|
| 170 | #define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString |
|---|
| 171 | #define MAX_STRING_TOKENS 1024 // max tokens resulting from Cmd_TokenizeString |
|---|
| 172 | #define MAX_TOKEN_CHARS 1024 // max length of an individual token |
|---|
| 173 | |
|---|
| 174 | #define MAX_INFO_STRING 1024 |
|---|
| 175 | #define MAX_INFO_KEY 1024 |
|---|
| 176 | #define MAX_INFO_VALUE 1024 |
|---|
| 177 | |
|---|
| 178 | #define BIG_INFO_STRING 8192 // used for system info key only |
|---|
| 179 | #define BIG_INFO_KEY 8192 |
|---|
| 180 | #define BIG_INFO_VALUE 8192 |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | #define MAX_QPATH 64 // max length of a quake game pathname |
|---|
| 184 | #ifdef PATH_MAX |
|---|
| 185 | #define MAX_OSPATH PATH_MAX |
|---|
| 186 | #else |
|---|
| 187 | #define MAX_OSPATH 256 // max length of a filesystem pathname |
|---|
| 188 | #endif |
|---|
| 189 | |
|---|
| 190 | #define MAX_NAME_LENGTH 32 // max length of a client name |
|---|
| 191 | #define MAX_HOSTNAME_LENGTH 80 // max length of a host name |
|---|
| 192 | |
|---|
| 193 | #define MAX_SAY_TEXT 150 |
|---|
| 194 | |
|---|
| 195 | // paramters for command buffer stuffing |
|---|
| 196 | typedef enum { |
|---|
| 197 | EXEC_NOW, // don't return until completed, a VM should NEVER use this, |
|---|
| 198 | // because some commands might cause the VM to be unloaded... |
|---|
| 199 | EXEC_INSERT, // insert at current position, but don't run yet |
|---|
| 200 | EXEC_APPEND // add to end of the command buffer (normal case) |
|---|
| 201 | } cbufExec_t; |
|---|
| 202 | |
|---|
| 203 | |
|---|
| 204 | // |
|---|
| 205 | // these aren't needed by any of the VMs. put in another header? |
|---|
| 206 | // |
|---|
| 207 | #define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility |
|---|
| 208 | |
|---|
| 209 | |
|---|
| 210 | // print levels from renderer (FIXME: set up for game / cgame?) |
|---|
| 211 | typedef enum { |
|---|
| 212 | PRINT_ALL, |
|---|
| 213 | PRINT_DEVELOPER, // only print when "developer 1" |
|---|
| 214 | PRINT_WARNING, |
|---|
| 215 | PRINT_ERROR |
|---|
| 216 | } printParm_t; |
|---|
| 217 | |
|---|
| 218 | |
|---|
| 219 | #ifdef ERR_FATAL |
|---|
| 220 | #undef ERR_FATAL // this is be defined in malloc.h |
|---|
| 221 | #endif |
|---|
| 222 | |
|---|
| 223 | // parameters to the main Error routine |
|---|
| 224 | typedef enum { |
|---|
| 225 | ERR_FATAL, // exit the entire game with a popup window |
|---|
| 226 | ERR_DROP, // print to console and disconnect from game |
|---|
| 227 | ERR_SERVERDISCONNECT, // don't kill server |
|---|
| 228 | ERR_DISCONNECT, // client disconnected from the server |
|---|
| 229 | ERR_NEED_CD // pop up the need-cd dialog |
|---|
| 230 | } errorParm_t; |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | // font rendering values used by ui and cgame |
|---|
| 234 | |
|---|
| 235 | #define PROP_GAP_WIDTH 3 |
|---|
| 236 | #define PROP_SPACE_WIDTH 8 |
|---|
| 237 | #define PROP_HEIGHT 27 |
|---|
| 238 | #define PROP_SMALL_SIZE_SCALE 0.75 |
|---|
| 239 | |
|---|
| 240 | #define BLINK_DIVISOR 200 |
|---|
| 241 | #define PULSE_DIVISOR 75 |
|---|
| 242 | |
|---|
| 243 | #define UI_LEFT 0x00000000 // default |
|---|
| 244 | #define UI_CENTER 0x00000001 |
|---|
| 245 | #define UI_RIGHT 0x00000002 |
|---|
| 246 | #define UI_FORMATMASK 0x00000007 |
|---|
| 247 | #define UI_SMALLFONT 0x00000010 |
|---|
| 248 | #define UI_BIGFONT 0x00000020 // default |
|---|
| 249 | #define UI_GIANTFONT 0x00000040 |
|---|
| 250 | #define UI_DROPSHADOW 0x00000800 |
|---|
| 251 | #define UI_BLINK 0x00001000 |
|---|
| 252 | #define UI_INVERSE 0x00002000 |
|---|
| 253 | #define UI_PULSE 0x00004000 |
|---|
| 254 | |
|---|
| 255 | #if defined(_DEBUG) && !defined(BSPC) |
|---|
| 256 | #define HUNK_DEBUG |
|---|
| 257 | #endif |
|---|
| 258 | |
|---|
| 259 | typedef enum { |
|---|
| 260 | h_high, |
|---|
| 261 | h_low, |
|---|
| 262 | h_dontcare |
|---|
| 263 | } ha_pref; |
|---|
| 264 | |
|---|
| 265 | #ifdef HUNK_DEBUG |
|---|
| 266 | #define Hunk_Alloc( size, preference ) Hunk_AllocDebug(size, preference, #size, __FILE__, __LINE__) |
|---|
| 267 | void *Hunk_AllocDebug( int size, ha_pref preference, char *label, char *file, int line ); |
|---|
| 268 | #else |
|---|
| 269 | void *Hunk_Alloc( int size, ha_pref preference ); |
|---|
| 270 | #endif |
|---|
| 271 | |
|---|
| 272 | #define Com_Memset memset |
|---|
| 273 | #define Com_Memcpy memcpy |
|---|
| 274 | |
|---|
| 275 | #define CIN_system 1 |
|---|
| 276 | #define CIN_loop 2 |
|---|
| 277 | #define CIN_hold 4 |
|---|
| 278 | #define CIN_silent 8 |
|---|
| 279 | #define CIN_shader 16 |
|---|
| 280 | |
|---|
| 281 | /* |
|---|
| 282 | ============================================================== |
|---|
| 283 | |
|---|
| 284 | MATHLIB |
|---|
| 285 | |
|---|
| 286 | ============================================================== |
|---|
| 287 | */ |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | typedef float vec_t; |
|---|
| 291 | typedef vec_t vec2_t[2]; |
|---|
| 292 | typedef vec_t vec3_t[3]; |
|---|
| 293 | typedef vec_t vec4_t[4]; |
|---|
| 294 | typedef vec_t vec5_t[5]; |
|---|
| 295 | |
|---|
| 296 | typedef int fixed4_t; |
|---|
| 297 | typedef int fixed8_t; |
|---|
| 298 | typedef int fixed16_t; |
|---|
| 299 | |
|---|
| 300 | #ifndef M_PI |
|---|
| 301 | #define M_PI 3.14159265358979323846f // matches value in gcc v2 math.h |
|---|
| 302 | #endif |
|---|
| 303 | |
|---|
| 304 | #ifndef M_SQRT2 |
|---|
| 305 | #define M_SQRT2 1.414213562f |
|---|
| 306 | #endif |
|---|
| 307 | |
|---|
| 308 | #ifndef M_ROOT3 |
|---|
| 309 | #define M_ROOT3 1.732050808f |
|---|
| 310 | #endif |
|---|
| 311 | |
|---|
| 312 | #define NUMVERTEXNORMALS 162 |
|---|
| 313 | extern vec3_t bytedirs[NUMVERTEXNORMALS]; |
|---|
| 314 | |
|---|
| 315 | // all drawing is done to a 640*480 virtual screen size |
|---|
| 316 | // and will be automatically scaled to the real resolution |
|---|
| 317 | #define SCREEN_WIDTH 640 |
|---|
| 318 | #define SCREEN_HEIGHT 480 |
|---|
| 319 | |
|---|
| 320 | #define TINYCHAR_WIDTH (SMALLCHAR_WIDTH) |
|---|
| 321 | #define TINYCHAR_HEIGHT (SMALLCHAR_HEIGHT/2) |
|---|
| 322 | |
|---|
| 323 | #define SMALLCHAR_WIDTH 8 |
|---|
| 324 | #define SMALLCHAR_HEIGHT 16 |
|---|
| 325 | |
|---|
| 326 | #define BIGCHAR_WIDTH 16 |
|---|
| 327 | #define BIGCHAR_HEIGHT 16 |
|---|
| 328 | |
|---|
| 329 | #define GIANTCHAR_WIDTH 32 |
|---|
| 330 | #define GIANTCHAR_HEIGHT 48 |
|---|
| 331 | |
|---|
| 332 | extern vec4_t colorBlack; |
|---|
| 333 | extern vec4_t colorRed; |
|---|
| 334 | extern vec4_t colorGreen; |
|---|
| 335 | extern vec4_t colorBlue; |
|---|
| 336 | extern vec4_t colorYellow; |
|---|
| 337 | extern vec4_t colorMagenta; |
|---|
| 338 | extern vec4_t colorCyan; |
|---|
| 339 | extern vec4_t colorWhite; |
|---|
| 340 | extern vec4_t colorLtGrey; |
|---|
| 341 | extern vec4_t colorMdGrey; |
|---|
| 342 | extern vec4_t colorDkGrey; |
|---|
| 343 | |
|---|
| 344 | #define Q_COLOR_ESCAPE '^' |
|---|
| 345 | #define Q_IsColorString(p) ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE ) |
|---|
| 346 | |
|---|
| 347 | #define COLOR_BLACK '0' |
|---|
| 348 | #define COLOR_RED '1' |
|---|
| 349 | #define COLOR_GREEN '2' |
|---|
| 350 | #define COLOR_YELLOW '3' |
|---|
| 351 | #define COLOR_BLUE '4' |
|---|
| 352 | #define COLOR_CYAN '5' |
|---|
| 353 | #define COLOR_MAGENTA '6' |
|---|
| 354 | #define COLOR_WHITE '7' |
|---|
| 355 | #define ColorIndex(c) ( ( (c) - '0' ) & 7 ) |
|---|
| 356 | |
|---|
| 357 | #define S_COLOR_BLACK "^0" |
|---|
| 358 | #define S_COLOR_RED "^1" |
|---|
| 359 | #define S_COLOR_GREEN "^2" |
|---|
| 360 | #define S_COLOR_YELLOW "^3" |
|---|
| 361 | #define S_COLOR_BLUE "^4" |
|---|
| 362 | #define S_COLOR_CYAN "^5" |
|---|
| 363 | #define S_COLOR_MAGENTA "^6" |
|---|
| 364 | #define S_COLOR_WHITE "^7" |
|---|
| 365 | |
|---|
| 366 | extern vec4_t g_color_table[8]; |
|---|
| 367 | |
|---|
| 368 | #define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b |
|---|
| 369 | #define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a |
|---|
| 370 | |
|---|
| 371 | #define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F ) |
|---|
| 372 | #define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI ) |
|---|
| 373 | |
|---|
| 374 | struct cplane_s; |
|---|
| 375 | |
|---|
| 376 | extern vec3_t vec3_origin; |
|---|
| 377 | extern vec3_t axisDefault[3]; |
|---|
| 378 | |
|---|
| 379 | #define nanmask (255<<23) |
|---|
| 380 | |
|---|
| 381 | #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask) |
|---|
| 382 | |
|---|
| 383 | #if idppc |
|---|
| 384 | |
|---|
| 385 | static ID_INLINE float Q_rsqrt( float number ) { |
|---|
| 386 | float x = 0.5f * number; |
|---|
| 387 | float y; |
|---|
| 388 | #ifdef __GNUC__ |
|---|
| 389 | asm("frsqrte %0,%1" : "=f" (y) : "f" (number)); |
|---|
| 390 | #else |
|---|
| 391 | y = __frsqrte( number ); |
|---|
| 392 | #endif |
|---|
| 393 | return y * (1.5f - (x * y * y)); |
|---|
| 394 | } |
|---|
| 395 | |
|---|
| 396 | #ifdef __GNUC__ |
|---|
| 397 | static ID_INLINE float Q_fabs(float x) { |
|---|
| 398 | float abs_x; |
|---|
| 399 | |
|---|
| 400 | asm("fabs %0,%1" : "=f" (abs_x) : "f" (x)); |
|---|
| 401 | return abs_x; |
|---|
| 402 | } |
|---|
| 403 | #else |
|---|
| 404 | #define Q_fabs __fabsf |
|---|
| 405 | #endif |
|---|
| 406 | |
|---|
| 407 | #else |
|---|
| 408 | float Q_fabs( float f ); |
|---|
| 409 | float Q_rsqrt( float f ); // reciprocal square root |
|---|
| 410 | #endif |
|---|
| 411 | |
|---|
| 412 | #define SQRTFAST( x ) ( (x) * Q_rsqrt( x ) ) |
|---|
| 413 | |
|---|
| 414 | signed char ClampChar( int i ); |
|---|
| 415 | signed short ClampShort( int i ); |
|---|
| 416 | |
|---|
| 417 | // this isn't a real cheap function to call! |
|---|
| 418 | int DirToByte( vec3_t dir ); |
|---|
| 419 | void ByteToDir( int b, vec3_t dir ); |
|---|
| 420 | |
|---|
| 421 | #if 1 |
|---|
| 422 | |
|---|
| 423 | #define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]) |
|---|
| 424 | #define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2]) |
|---|
| 425 | #define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2]) |
|---|
| 426 | #define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2]) |
|---|
| 427 | #define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s)) |
|---|
| 428 | #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)) |
|---|
| 429 | #define VectorLerp( f, s, e, r ) ((r)[0]=(s)[0]+(f)*((e)[0]-(s)[0]),\ |
|---|
| 430 | (r)[1]=(s)[1]+(f)*((e)[1]-(s)[1]),\ |
|---|
| 431 | (r)[2]=(s)[2]+(f)*((e)[2]-(s)[2])) |
|---|
| 432 | |
|---|
| 433 | #else |
|---|
| 434 | |
|---|
| 435 | #define DotProduct(x,y) _DotProduct(x,y) |
|---|
| 436 | #define VectorSubtract(a,b,c) _VectorSubtract(a,b,c) |
|---|
| 437 | #define VectorAdd(a,b,c) _VectorAdd(a,b,c) |
|---|
| 438 | #define VectorCopy(a,b) _VectorCopy(a,b) |
|---|
| 439 | #define VectorScale(v, s, o) _VectorScale(v,s,o) |
|---|
| 440 | #define VectorMA(v, s, b, o) _VectorMA(v,s,b,o) |
|---|
| 441 | |
|---|
| 442 | #endif |
|---|
| 443 | |
|---|
| 444 | #ifdef Q3_VM |
|---|
| 445 | #ifdef VectorCopy |
|---|
| 446 | #undef VectorCopy |
|---|
| 447 | // this is a little hack to get more efficient copies in our interpreter |
|---|
| 448 | typedef struct { |
|---|
| 449 | float v[3]; |
|---|
| 450 | } vec3struct_t; |
|---|
| 451 | #define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a) |
|---|
| 452 | #endif |
|---|
| 453 | #endif |
|---|
| 454 | |
|---|
| 455 | #define Vector2Set(v, x, y) ((v)[0]=(x), (v)[1]=(y)) |
|---|
| 456 | #define VectorClear(a) ((a)[0]=(a)[1]=(a)[2]=0) |
|---|
| 457 | #define VectorNegate(a,b) ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2]) |
|---|
| 458 | #define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) |
|---|
| 459 | #define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) |
|---|
| 460 | #define Vector4Add(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]) |
|---|
| 461 | |
|---|
| 462 | #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} |
|---|
| 463 | // just in case you do't want to use the macros |
|---|
| 464 | vec_t _DotProduct( const vec3_t v1, const vec3_t v2 ); |
|---|
| 465 | void _VectorSubtract( const vec3_t veca, const vec3_t vecb, vec3_t out ); |
|---|
| 466 | void _VectorAdd( const vec3_t veca, const vec3_t vecb, vec3_t out ); |
|---|
| 467 | void _VectorCopy( const vec3_t in, vec3_t out ); |
|---|
| 468 | void _VectorScale( const vec3_t in, float scale, vec3_t out ); |
|---|
| 469 | void _VectorMA( const vec3_t veca, float scale, const vec3_t vecb, vec3_t vecc ); |
|---|
| 470 | |
|---|
| 471 | unsigned ColorBytes3 (float r, float g, float b); |
|---|
| 472 | unsigned ColorBytes4 (float r, float g, float b, float a); |
|---|
| 473 | |
|---|
| 474 | float NormalizeColor( const vec3_t in, vec3_t out ); |
|---|
| 475 | |
|---|
| 476 | float RadiusFromBounds( const vec3_t mins, const vec3_t maxs ); |
|---|
| 477 | void ClearBounds( vec3_t mins, vec3_t maxs ); |
|---|
| 478 | void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); |
|---|
| 479 | |
|---|
| 480 | #if !defined( Q3_VM ) || ( defined( Q3_VM ) && defined( __Q3_VM_MATH ) ) |
|---|
| 481 | static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) { |
|---|
| 482 | if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { |
|---|
| 483 | return 0; |
|---|
| 484 | } |
|---|
| 485 | return 1; |
|---|
| 486 | } |
|---|
| 487 | |
|---|
| 488 | static ID_INLINE int VectorCompareEpsilon( |
|---|
| 489 | const vec3_t v1, const vec3_t v2, float epsilon ) |
|---|
| 490 | { |
|---|
| 491 | vec3_t d; |
|---|
| 492 | |
|---|
| 493 | VectorSubtract( v1, v2, d ); |
|---|
| 494 | d[ 0 ] = fabs( d[ 0 ] ); |
|---|
| 495 | d[ 1 ] = fabs( d[ 1 ] ); |
|---|
| 496 | d[ 2 ] = fabs( d[ 2 ] ); |
|---|
| 497 | |
|---|
| 498 | if( d[ 0 ] > epsilon || d[ 1 ] > epsilon || d[ 2 ] > epsilon ) |
|---|
| 499 | return 0; |
|---|
| 500 | |
|---|
| 501 | return 1; |
|---|
| 502 | } |
|---|
| 503 | |
|---|
| 504 | static ID_INLINE vec_t VectorLength( const vec3_t v ) { |
|---|
| 505 | return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | static ID_INLINE vec_t VectorLengthSquared( const vec3_t v ) { |
|---|
| 509 | return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | static ID_INLINE vec_t Distance( const vec3_t p1, const vec3_t p2 ) { |
|---|
| 513 | vec3_t v; |
|---|
| 514 | |
|---|
| 515 | VectorSubtract (p2, p1, v); |
|---|
| 516 | return VectorLength( v ); |
|---|
| 517 | } |
|---|
| 518 | |
|---|
| 519 | static ID_INLINE vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { |
|---|
| 520 | vec3_t v; |
|---|
| 521 | |
|---|
| 522 | VectorSubtract (p2, p1, v); |
|---|
| 523 | return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; |
|---|
| 524 | } |
|---|
| 525 | |
|---|
| 526 | // fast vector normalize routine that does not check to make sure |
|---|
| 527 | // that length != 0, nor does it return length, uses rsqrt approximation |
|---|
| 528 | static ID_INLINE void VectorNormalizeFast( vec3_t v ) |
|---|
| 529 | { |
|---|
| 530 | float ilength; |
|---|
| 531 | |
|---|
| 532 | ilength = Q_rsqrt( DotProduct( v, v ) ); |
|---|
| 533 | |
|---|
| 534 | v[0] *= ilength; |
|---|
| 535 | v[1] *= ilength; |
|---|
| 536 | v[2] *= ilength; |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | static ID_INLINE void VectorInverse( vec3_t v ){ |
|---|
| 540 | v[0] = -v[0]; |
|---|
| 541 | v[1] = -v[1]; |
|---|
| 542 | v[2] = -v[2]; |
|---|
| 543 | } |
|---|
| 544 | |
|---|
| 545 | static ID_INLINE void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { |
|---|
| 546 | cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; |
|---|
| 547 | cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; |
|---|
| 548 | cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; |
|---|
| 549 | } |
|---|
| 550 | |
|---|
| 551 | #else |
|---|
| 552 | int VectorCompare( const vec3_t v1, const vec3_t v2 ); |
|---|
| 553 | |
|---|
| 554 | vec_t VectorLength( const vec3_t v ); |
|---|
| 555 | |
|---|
| 556 | vec_t VectorLengthSquared( const vec3_t v ); |
|---|
| 557 | |
|---|
| 558 | vec_t Distance( const vec3_t p1, const vec3_t p2 ); |
|---|
| 559 | |
|---|
| 560 | vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ); |
|---|
| 561 | |
|---|
| 562 | void VectorNormalizeFast( vec3_t v ); |
|---|
| 563 | |
|---|
| 564 | void VectorInverse( vec3_t v ); |
|---|
| 565 | |
|---|
| 566 | void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ); |
|---|
| 567 | |
|---|
| 568 | #endif |
|---|
| 569 | |
|---|
| 570 | vec_t VectorNormalize (vec3_t v); // returns vector length |
|---|
| 571 | vec_t VectorNormalize2( const vec3_t v, vec3_t out ); |
|---|
| 572 | void Vector4Scale( const vec4_t in, vec_t scale, vec4_t out ); |
|---|
| 573 | void VectorRotate( vec3_t in, vec3_t matrix[3], vec3_t out ); |
|---|
| 574 | int Q_log2(int val); |
|---|
| 575 | |
|---|
| 576 | float Q_acos(float c); |
|---|
| 577 | |
|---|
| 578 | int Q_rand( int *seed ); |
|---|
| 579 | float Q_random( int *seed ); |
|---|
| 580 | float Q_crandom( int *seed ); |
|---|
| 581 | |
|---|
| 582 | #define random() ((rand () & 0x7fff) / ((float)0x7fff)) |
|---|
| 583 | #define crandom() (2.0 * (random() - 0.5)) |
|---|
| 584 | |
|---|
| 585 | void vectoangles( const vec3_t value1, vec3_t angles); |
|---|
| 586 | void AnglesToAxis( const vec3_t angles, vec3_t axis[3] ); |
|---|
| 587 | void AxisToAngles( vec3_t axis[3], vec3_t angles ); |
|---|
| 588 | |
|---|
| 589 | void AxisClear( vec3_t axis[3] ); |
|---|
| 590 | void AxisCopy( vec3_t in[3], vec3_t out[3] ); |
|---|
| 591 | |
|---|
| 592 | void SetPlaneSignbits( struct cplane_s *out ); |
|---|
| 593 | int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *plane); |
|---|
| 594 | |
|---|
| 595 | qboolean BoundsIntersect(const vec3_t mins, const vec3_t maxs, |
|---|
| 596 | const vec3_t mins2, const vec3_t maxs2); |
|---|
| 597 | qboolean BoundsIntersectSphere(const vec3_t mins, const vec3_t maxs, |
|---|
| 598 | const vec3_t origin, vec_t radius); |
|---|
| 599 | qboolean BoundsIntersectPoint(const vec3_t mins, const vec3_t maxs, |
|---|
| 600 | const vec3_t origin); |
|---|
| 601 | |
|---|
| 602 | float AngleMod(float a); |
|---|
| 603 | float LerpAngle (float from, float to, float frac); |
|---|
| 604 | float AngleSubtract( float a1, float a2 ); |
|---|
| 605 | void AnglesSubtract( vec3_t v1, vec3_t v2, vec3_t v3 ); |
|---|
| 606 | |
|---|
| 607 | float AngleNormalize360 ( float angle ); |
|---|
| 608 | float AngleNormalize180 ( float angle ); |
|---|
| 609 | float AngleDelta ( float angle1, float angle2 ); |
|---|
| 610 | |
|---|
| 611 | qboolean PlaneFromPoints( vec4_t plane, const vec3_t a, const vec3_t b, const vec3_t c ); |
|---|
| 612 | void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ); |
|---|
| 613 | void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees ); |
|---|
| 614 | void RotateAroundDirection( vec3_t axis[3], vec_t angle ); |
|---|
| 615 | void MakeNormalVectors( const vec3_t forward, vec3_t right, vec3_t up ); |
|---|
| 616 | // perpendicular vector could be replaced by this |
|---|
| 617 | |
|---|
| 618 | //int PlaneTypeForNormal (vec3_t normal); |
|---|
| 619 | |
|---|
| 620 | void MatrixMultiply(float in1[3][3], float in2[3][3], float out[3][3]); |
|---|
| 621 | void VectorMatrixMultiply( const vec3_t p, vec3_t m[ 3 ], vec3_t out ); |
|---|
| 622 | void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); |
|---|
| 623 | void PerpendicularVector( vec3_t dst, const vec3_t src ); |
|---|
| 624 | int Q_isnan( float x ); |
|---|
| 625 | |
|---|
| 626 | void GetPerpendicularViewVector( const vec3_t point, const vec3_t p1, |
|---|
| 627 | const vec3_t p2, vec3_t up ); |
|---|
| 628 | void ProjectPointOntoVector( vec3_t point, vec3_t vStart, |
|---|
| 629 | vec3_t vEnd, vec3_t vProj ); |
|---|
| 630 | float VectorDistance( vec3_t v1, vec3_t v2 ); |
|---|
| 631 | |
|---|
| 632 | float pointToLineDistance( const vec3_t point, const vec3_t p1, const vec3_t p2 ); |
|---|
| 633 | float VectorMinComponent( vec3_t v ); |
|---|
| 634 | float VectorMaxComponent( vec3_t v ); |
|---|
| 635 | |
|---|
| 636 | vec_t DistanceBetweenLineSegmentsSquared( |
|---|
| 637 | const vec3_t sP0, const vec3_t sP1, |
|---|
| 638 | const vec3_t tP0, const vec3_t tP1, |
|---|
| 639 | float *s, float *t ); |
|---|
| 640 | vec_t DistanceBetweenLineSegments( |
|---|
| 641 | const vec3_t sP0, const vec3_t sP1, |
|---|
| 642 | const vec3_t tP0, const vec3_t tP1, |
|---|
| 643 | float *s, float *t ); |
|---|
| 644 | |
|---|
| 645 | #ifndef MAX |
|---|
| 646 | #define MAX(x,y) (x)>(y)?(x):(y) |
|---|
| 647 | #endif |
|---|
| 648 | |
|---|
| 649 | #ifndef MIN |
|---|
| 650 | #define MIN(x,y) (x)<(y)?(x):(y) |
|---|
| 651 | #endif |
|---|
| 652 | |
|---|
| 653 | //============================================= |
|---|
| 654 | |
|---|
| 655 | float Com_Clamp( float min, float max, float value ); |
|---|
| 656 | |
|---|
| 657 | char *COM_SkipPath( char *pathname ); |
|---|
| 658 | const char *COM_GetExtension( const char *name ); |
|---|
| 659 | void COM_StripExtension(const char *in, char *out, int destsize); |
|---|
| 660 | void COM_DefaultExtension( char *path, int maxSize, const char *extension ); |
|---|
| 661 | |
|---|
| 662 | void COM_BeginParseSession( const char *name ); |
|---|
| 663 | int COM_GetCurrentParseLine( void ); |
|---|
| 664 | char *COM_Parse( char **data_p ); |
|---|
| 665 | char *COM_ParseExt( char **data_p, qboolean allowLineBreak ); |
|---|
| 666 | int COM_Compress( char *data_p ); |
|---|
| 667 | void COM_ParseError( char *format, ... ) __attribute__ ((format (printf, 1, 2))); |
|---|
| 668 | void COM_ParseWarning( char *format, ... ) __attribute__ ((format (printf, 1, 2))); |
|---|
| 669 | //int COM_ParseInfos( char *buf, int max, char infos[][MAX_INFO_STRING] ); |
|---|
| 670 | |
|---|
| 671 | #define MAX_TOKENLENGTH 1024 |
|---|
| 672 | |
|---|
| 673 | #ifndef TT_STRING |
|---|
| 674 | //token types |
|---|
| 675 | #define TT_STRING 1 // string |
|---|
| 676 | #define TT_LITERAL 2 // literal |
|---|
| 677 | #define TT_NUMBER 3 // number |
|---|
| 678 | #define TT_NAME 4 // name |
|---|
| 679 | #define TT_PUNCTUATION 5 // punctuation |
|---|
| 680 | #endif |
|---|
| 681 | |
|---|
| 682 | typedef struct pc_token_s |
|---|
| 683 | { |
|---|
| 684 | int type; |
|---|
| 685 | int subtype; |
|---|
| 686 | int intvalue; |
|---|
| 687 | float floatvalue; |
|---|
| 688 | char string[MAX_TOKENLENGTH]; |
|---|
| 689 | } pc_token_t; |
|---|
| 690 | |
|---|
| 691 | // data is an in/out parm, returns a parsed out token |
|---|
| 692 | |
|---|
| 693 | void COM_MatchToken( char**buf_p, char *match ); |
|---|
| 694 | |
|---|
| 695 | void SkipBracedSection (char **program); |
|---|
| 696 | void SkipRestOfLine ( char **data ); |
|---|
| 697 | |
|---|
| 698 | void Parse1DMatrix (char **buf_p, int x, float *m); |
|---|
| 699 | void Parse2DMatrix (char **buf_p, int y, int x, float *m); |
|---|
| 700 | void Parse3DMatrix (char **buf_p, int z, int y, int x, float *m); |
|---|
| 701 | |
|---|
| 702 | void QDECL Com_sprintf (char *dest, int size, const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); |
|---|
| 703 | |
|---|
| 704 | char *Com_SkipTokens( char *s, int numTokens, char *sep ); |
|---|
| 705 | char *Com_SkipCharset( char *s, char *sep ); |
|---|
| 706 | |
|---|
| 707 | void Com_RandomBytes( byte *string, int len ); |
|---|
| 708 | |
|---|
| 709 | // mode parm for FS_FOpenFile |
|---|
| 710 | typedef enum { |
|---|
| 711 | FS_READ, |
|---|
| 712 | FS_WRITE, |
|---|
| 713 | FS_APPEND, |
|---|
| 714 | FS_APPEND_SYNC |
|---|
| 715 | } fsMode_t; |
|---|
| 716 | |
|---|
| 717 | typedef enum { |
|---|
| 718 | FS_SEEK_CUR, |
|---|
| 719 | FS_SEEK_END, |
|---|
| 720 | FS_SEEK_SET |
|---|
| 721 | } fsOrigin_t; |
|---|
| 722 | |
|---|
| 723 | //============================================= |
|---|
| 724 | |
|---|
| 725 | int Q_isprint( int c ); |
|---|
| 726 | int Q_islower( int c ); |
|---|
| 727 | int Q_isupper( int c ); |
|---|
| 728 | int Q_isalpha( int c ); |
|---|
| 729 | |
|---|
| 730 | // portable case insensitive compare |
|---|
| 731 | int Q_stricmp (const char *s1, const char *s2); |
|---|
| 732 | int Q_strncmp (const char *s1, const char *s2, int n); |
|---|
| 733 | int Q_stricmpn (const char *s1, const char *s2, int n); |
|---|
| 734 | char *Q_strlwr( char *s1 ); |
|---|
| 735 | char *Q_strupr( char *s1 ); |
|---|
| 736 | char *Q_strrchr( const char* string, int c ); |
|---|
| 737 | const char *Q_stristr( const char *s, const char *find); |
|---|
| 738 | |
|---|
| 739 | // buffer size safe library replacements |
|---|
| 740 | void Q_strncpyz( char *dest, const char *src, int destsize ); |
|---|
| 741 | void Q_strcat( char *dest, int size, const char *src ); |
|---|
| 742 | |
|---|
| 743 | // strlen that discounts Quake color sequences |
|---|
| 744 | int Q_PrintStrlen( const char *string ); |
|---|
| 745 | // removes color sequences from string |
|---|
| 746 | char *Q_CleanStr( char *string ); |
|---|
| 747 | |
|---|
| 748 | //============================================= |
|---|
| 749 | |
|---|
| 750 | // 64-bit integers for global rankings interface |
|---|
| 751 | // implemented as a struct for qvm compatibility |
|---|
| 752 | typedef struct |
|---|
| 753 | { |
|---|
| 754 | byte b0; |
|---|
| 755 | byte b1; |
|---|
| 756 | byte b2; |
|---|
| 757 | byte b3; |
|---|
| 758 | byte b4; |
|---|
| 759 | byte b5; |
|---|
| 760 | byte b6; |
|---|
| 761 | byte b7; |
|---|
| 762 | } qint64; |
|---|
| 763 | |
|---|
| 764 | //============================================= |
|---|
| 765 | /* |
|---|
| 766 | short BigShort(short l); |
|---|
| 767 | short LittleShort(short l); |
|---|
| 768 | int BigLong (int l); |
|---|
| 769 | int LittleLong (int l); |
|---|
| 770 | qint64 BigLong64 (qint64 l); |
|---|
| 771 | qint64 LittleLong64 (qint64 l); |
|---|
| 772 | float BigFloat (const float *l); |
|---|
| 773 | float LittleFloat (const float *l); |
|---|
| 774 | |
|---|
| 775 | void Swap_Init (void); |
|---|
| 776 | */ |
|---|
| 777 | char * QDECL va(char *format, ...) __attribute__ ((format (printf, 1, 2))); |
|---|
| 778 | |
|---|
| 779 | #define TRUNCATE_LENGTH 64 |
|---|
| 780 | void Com_TruncateLongString( char *buffer, const char *s ); |
|---|
| 781 | |
|---|
| 782 | //============================================= |
|---|
| 783 | |
|---|
| 784 | // |
|---|
| 785 | // key / value info strings |
|---|
| 786 | // |
|---|
| 787 | char *Info_ValueForKey( const char *s, const char *key ); |
|---|
| 788 | void Info_RemoveKey( char *s, const char *key ); |
|---|
| 789 | void Info_RemoveKey_big( char *s, const char *key ); |
|---|
| 790 | void Info_SetValueForKey( char *s, const char *key, const char *value ); |
|---|
| 791 | void Info_SetValueForKey_Big( char *s, const char *key, const char *value ); |
|---|
| 792 | qboolean Info_Validate( const char *s ); |
|---|
| 793 | void Info_NextPair( const char **s, char *key, char *value ); |
|---|
| 794 | |
|---|
| 795 | // this is only here so the functions in q_shared.c and bg_*.c can link |
|---|
| 796 | void QDECL Com_Error( int level, const char *error, ... ) __attribute__ ((format (printf, 2, 3))); |
|---|
| 797 | void QDECL Com_Printf( const char *msg, ... ) __attribute__ ((format (printf, 1, 2))); |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | /* |
|---|
| 801 | ========================================================== |
|---|
| 802 | |
|---|
| 803 | CVARS (console variables) |
|---|
| 804 | |
|---|
| 805 | Many variables can be used for cheating purposes, so when |
|---|
| 806 | cheats is zero, force all unspecified variables to their |
|---|
| 807 | default values. |
|---|
| 808 | ========================================================== |
|---|
| 809 | */ |
|---|
| 810 | |
|---|
| 811 | #define CVAR_ARCHIVE 1 // set to cause it to be saved to vars.rc |
|---|
| 812 | // used for system variables, not for player |
|---|
| 813 | // specific configurations |
|---|
| 814 | #define CVAR_USERINFO 2 // sent to server on connect or change |
|---|
| 815 | #define CVAR_SERVERINFO 4 // sent in response to front end requests |
|---|
| 816 | #define CVAR_SYSTEMINFO 8 // these cvars will be duplicated on all clients |
|---|
| 817 | #define CVAR_INIT 16 // don't allow change from console at all, |
|---|
| 818 | // but can be set from the command line |
|---|
| 819 | #define CVAR_LATCH 32 // will only change when C code next does |
|---|
| 820 | // a Cvar_Get(), so it can't be changed |
|---|
| 821 | // without proper initialization. modified |
|---|
| 822 | // will be set, even though the value hasn't |
|---|
| 823 | // changed yet |
|---|
| 824 | #define CVAR_ROM 64 // display only, cannot be set by user at all |
|---|
| 825 | #define CVAR_USER_CREATED 128 // created by a set command |
|---|
| 826 | #define CVAR_TEMP 256 // can be set even when cheats are disabled, but is not archived |
|---|
| 827 | #define CVAR_CHEAT 512 // can not be changed if cheats are disabled |
|---|
| 828 | #define CVAR_NORESTART 1024 // do not clear when a cvar_restart is issued |
|---|
| 829 | |
|---|
| 830 | #define CVAR_SERVER_CREATED 2048 // cvar was created by a server the client connected to. |
|---|
| 831 | #define CVAR_NONEXISTENT 0xFFFFFFFF // Cvar doesn't exist. |
|---|
| 832 | |
|---|
| 833 | // nothing outside the Cvar_*() functions should modify these fields! |
|---|
| 834 | typedef struct cvar_s { |
|---|
| 835 | char *name; |
|---|
| 836 | char *string; |
|---|
| 837 | char *resetString; // cvar_restart will reset to this value |
|---|
| 838 | char *latchedString; // for CVAR_LATCH vars |
|---|
| 839 | int flags; |
|---|
| 840 | qboolean modified; // set each time the cvar is changed |
|---|
| 841 | int modificationCount; // incremented each time the cvar is changed |
|---|
| 842 | float value; // atof( string ) |
|---|
| 843 | int integer; // atoi( string ) |
|---|
| 844 | struct cvar_s *next; |
|---|
| 845 | struct cvar_s *hashNext; |
|---|
| 846 | } cvar_t; |
|---|
| 847 | |
|---|
| 848 | #define MAX_CVAR_VALUE_STRING 256 |
|---|
| 849 | |
|---|
| 850 | typedef int cvarHandle_t; |
|---|
| 851 | |
|---|
| 852 | // the modules that run in the virtual machine can't access the cvar_t directly, |
|---|
| 853 | // so they must ask for structured updates |
|---|
| 854 | typedef struct { |
|---|
| 855 | cvarHandle_t handle; |
|---|
| 856 | int modificationCount; |
|---|
| 857 | float value; |
|---|
| 858 | int integer; |
|---|
| 859 | char string[MAX_CVAR_VALUE_STRING]; |
|---|
| 860 | } vmCvar_t; |
|---|
| 861 | |
|---|
| 862 | /* |
|---|
| 863 | ============================================================== |
|---|
| 864 | |
|---|
| 865 | COLLISION DETECTION |
|---|
| 866 | |
|---|
| 867 | ============================================================== |
|---|
| 868 | */ |
|---|
| 869 | |
|---|
| 870 | #include "surfaceflags.h" // shared with the q3map utility |
|---|
| 871 | |
|---|
| 872 | // plane types are used to speed some tests |
|---|
| 873 | // 0-2 are axial planes |
|---|
| 874 | #define PLANE_X 0 |
|---|
| 875 | #define PLANE_Y 1 |
|---|
| 876 | #define PLANE_Z 2 |
|---|
| 877 | #define PLANE_NON_AXIAL 3 |
|---|
| 878 | |
|---|
| 879 | |
|---|
| 880 | /* |
|---|
| 881 | ================= |
|---|
| 882 | PlaneTypeForNormal |
|---|
| 883 | ================= |
|---|
| 884 | */ |
|---|
| 885 | |
|---|
| 886 | #define PlaneTypeForNormal(x) (x[0] == 1.0 ? PLANE_X : (x[1] == 1.0 ? PLANE_Y : (x[2] == 1.0 ? PLANE_Z : PLANE_NON_AXIAL) ) ) |
|---|
| 887 | |
|---|
| 888 | // plane_t structure |
|---|
| 889 | // !!! if this is changed, it must be changed in asm code too !!! |
|---|
| 890 | typedef struct cplane_s { |
|---|
| 891 | vec3_t normal; |
|---|
| 892 | float dist; |
|---|
| 893 | byte type; // for fast side tests: 0,1,2 = axial, 3 = nonaxial |
|---|
| 894 | byte signbits; // signx + (signy<<1) + (signz<<2), used as lookup during collision |
|---|
| 895 | byte pad[2]; |
|---|
| 896 | } cplane_t; |
|---|
| 897 | |
|---|
| 898 | typedef enum { |
|---|
| 899 | TT_NONE, |
|---|
| 900 | |
|---|
| 901 | TT_AABB, |
|---|
| 902 | TT_CAPSULE, |
|---|
| 903 | TT_BISPHERE, |
|---|
| 904 | |
|---|
| 905 | TT_NUM_TRACE_TYPES |
|---|
| 906 | } traceType_t; |
|---|
| 907 | |
|---|
| 908 | // a trace is returned when a box is swept through the world |
|---|
| 909 | typedef struct { |
|---|
| 910 | qboolean allsolid; // if true, plane is not valid |
|---|
| 911 | qboolean startsolid; // if true, the initial point was in a solid area |
|---|
| 912 | float fraction; // time completed, 1.0 = didn't hit anything |
|---|
| 913 | vec3_t endpos; // final position |
|---|
| 914 | cplane_t plane; // surface normal at impact, transformed to world space |
|---|
| 915 | int surfaceFlags; // surface hit |
|---|
| 916 | int contents; // contents on other side of surface hit |
|---|
| 917 | int entityNum; // entity the contacted sirface is a part of |
|---|
| 918 | float lateralFraction; // fraction of collision tangetially to the trace direction |
|---|
| 919 | } trace_t; |
|---|
| 920 | |
|---|
| 921 | // trace->entityNum can also be 0 to (MAX_GENTITIES-1) |
|---|
| 922 | // or ENTITYNUM_NONE, ENTITYNUM_WORLD |
|---|
| 923 | |
|---|
| 924 | |
|---|
| 925 | // markfragments are returned by CM_MarkFragments() |
|---|
| 926 | typedef struct { |
|---|
| 927 | int firstPoint; |
|---|
| 928 | int numPoints; |
|---|
| 929 | } markFragment_t; |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | |
|---|
| 933 | typedef struct { |
|---|
| 934 | vec3_t origin; |
|---|
| 935 | vec3_t axis[3]; |
|---|
| 936 | } orientation_t; |
|---|
| 937 | |
|---|
| 938 | //===================================================================== |
|---|
| 939 | |
|---|
| 940 | |
|---|
| 941 | // in order from highest priority to lowest |
|---|
| 942 | // if none of the catchers are active, bound key strings will be executed |
|---|
| 943 | #define KEYCATCH_CONSOLE 0x0001 |
|---|
| 944 | #define KEYCATCH_UI 0x0002 |
|---|
| 945 | #define KEYCATCH_CGAME 0x0008 |
|---|
| 946 | |
|---|
| 947 | |
|---|
| 948 | // sound channels |
|---|
| 949 | // channel 0 never willingly overrides |
|---|
| 950 | // other channels will allways override a playing sound on that channel |
|---|
| 951 | typedef enum { |
|---|
| 952 | CHAN_AUTO, |
|---|
| 953 | CHAN_LOCAL, // menu sounds, etc |
|---|
| 954 | CHAN_WEAPON, |
|---|
| 955 | CHAN_VOICE, |
|---|
| 956 | CHAN_ITEM, |
|---|
| 957 | CHAN_BODY, |
|---|
| 958 | CHAN_LOCAL_SOUND, // chat messages, etc |
|---|
| 959 | CHAN_ANNOUNCER // announcer voices, etc |
|---|
| 960 | } soundChannel_t; |
|---|
| 961 | |
|---|
| 962 | |
|---|
| 963 | /* |
|---|
| 964 | ======================================================================== |
|---|
| 965 | |
|---|
| 966 | ELEMENTS COMMUNICATED ACROSS THE NET |
|---|
| 967 | |
|---|
| 968 | ======================================================================== |
|---|
| 969 | */ |
|---|
| 970 | |
|---|
| 971 | #define ANGLE2SHORT(x) ((int)((x)*65536/360) & 65535) |
|---|
| 972 | #define SHORT2ANGLE(x) ((x)*(360.0/65536)) |
|---|
| 973 | |
|---|
| 974 | #define SNAPFLAG_RATE_DELAYED 1 |
|---|
| 975 | #define SNAPFLAG_NOT_ACTIVE 2 // snapshot used during connection and for zombies |
|---|
| 976 | #define SNAPFLAG_SERVERCOUNT 4 // toggled every map_restart so transitions can be detected |
|---|
| 977 | |
|---|
| 978 | // |
|---|
| 979 | // per-level limits |
|---|
| 980 | // |
|---|
| 981 | #define MAX_CLIENTS 64 // absolute limit |
|---|
| 982 | #define MAX_LOCATIONS 64 |
|---|
| 983 | |
|---|
| 984 | #define GENTITYNUM_BITS 10 // don't need to send any more |
|---|
| 985 | #define MAX_GENTITIES (1<<GENTITYNUM_BITS) |
|---|
| 986 | |
|---|
| 987 | // entitynums are communicated with GENTITY_BITS, so any reserved |
|---|
| 988 | // values that are going to be communcated over the net need to |
|---|
| 989 | // also be in this range |
|---|
| 990 | #define ENTITYNUM_NONE (MAX_GENTITIES-1) |
|---|
| 991 | #define ENTITYNUM_WORLD (MAX_GENTITIES-2) |
|---|
| 992 | #define ENTITYNUM_MAX_NORMAL (MAX_GENTITIES-2) |
|---|
| 993 | |
|---|
| 994 | |
|---|
| 995 | #define MAX_MODELS 256 // these are sent over the net as 8 bits |
|---|
| 996 | #define MAX_SOUNDS 256 // so they cannot be blindly increased |
|---|
| 997 | #define MAX_GAME_SHADERS 64 |
|---|
| 998 | #define MAX_GAME_PARTICLE_SYSTEMS 64 |
|---|
| 999 | |
|---|
| 1000 | |
|---|
| 1001 | #define MAX_CONFIGSTRINGS 1024 |
|---|
| 1002 | |
|---|
| 1003 | // these are the only configstrings that the system reserves, all the |
|---|
| 1004 | // other ones are strictly for servergame to clientgame communication |
|---|
| 1005 | #define CS_SERVERINFO 0 // an info string with all the serverinfo cvars |
|---|
| 1006 | #define CS_SYSTEMINFO 1 // an info string for server system to client system configuration (timescale, etc) |
|---|
| 1007 | |
|---|
| 1008 | #define RESERVED_CONFIGSTRINGS 2 // game can't modify below this, only the system can |
|---|
| 1009 | |
|---|
| 1010 | #define MAX_GAMESTATE_CHARS 16000 |
|---|
| 1011 | typedef struct { |
|---|
| 1012 | int stringOffsets[MAX_CONFIGSTRINGS]; |
|---|
| 1013 | char stringData[MAX_GAMESTATE_CHARS]; |
|---|
| 1014 | int dataCount; |
|---|
| 1015 | } gameState_t; |
|---|
| 1016 | |
|---|
| 1017 | //========================================================= |
|---|
| 1018 | |
|---|
| 1019 | // bit field limits |
|---|
| 1020 | #define MAX_STATS 16 |
|---|
| 1021 | #define MAX_PERSISTANT 16 |
|---|
| 1022 | #define MAX_POWERUPS 16 |
|---|
| 1023 | #define MAX_WEAPONS 16 |
|---|
| 1024 | |
|---|
| 1025 | #define MAX_PS_EVENTS 2 |
|---|
| 1026 | |
|---|
| 1027 | #define PS_PMOVEFRAMECOUNTBITS 6 |
|---|
| 1028 | |
|---|
| 1029 | // playerState_t is the information needed by both the client and server |
|---|
| 1030 | // to predict player motion and actions |
|---|
| 1031 | // nothing outside of pmove should modify these, or some degree of prediction error |
|---|
| 1032 | // will occur |
|---|
| 1033 | |
|---|
| 1034 | // you can't add anything to this without modifying the code in msg.c |
|---|
| 1035 | |
|---|
| 1036 | // playerState_t is a full superset of entityState_t as it is used by players, |
|---|
| 1037 | // so if a playerState_t is transmitted, the entityState_t can be fully derived |
|---|
| 1038 | // from it. |
|---|
| 1039 | typedef struct playerState_s { |
|---|
| 1040 | int commandTime; // cmd->serverTime of last executed command |
|---|
| 1041 | int pm_type; |
|---|
| 1042 | int bobCycle; // for view bobbing and footstep generation |
|---|
| 1043 | int pm_flags; // ducked, jump_held, etc |
|---|
| 1044 | int pm_time; |
|---|
| 1045 | |
|---|
| 1046 | vec3_t origin; |
|---|
| 1047 | vec3_t velocity; |
|---|
| 1048 | int weaponTime; |
|---|
| 1049 | int gravity; |
|---|
| 1050 | int speed; |
|---|
| 1051 | int delta_angles[3]; // add to command angles to get view direction |
|---|
| 1052 | // changed by spawns, rotating objects, and teleporters |
|---|
| 1053 | |
|---|
| 1054 | int groundEntityNum;// ENTITYNUM_NONE = in air |
|---|
| 1055 | |
|---|
| 1056 | int legsTimer; // don't change low priority animations until this runs out |
|---|
| 1057 | int legsAnim; // mask off ANIM_TOGGLEBIT |
|---|
| 1058 | |
|---|
| 1059 | int torsoTimer; // don't change low priority animations until this runs out |
|---|
| 1060 | int torsoAnim; // mask off ANIM_TOGGLEBIT |
|---|
| 1061 | |
|---|
| 1062 | int movementDir; // a number 0 to 7 that represents the reletive angle |
|---|
| 1063 | // of movement to the view angle (axial and diagonals) |
|---|
| 1064 | // when at rest, the value will remain unchanged |
|---|
| 1065 | // used to twist the legs during strafing |
|---|
| 1066 | |
|---|
| 1067 | vec3_t grapplePoint; // location of grapple to pull towards if PMF_GRAPPLE_PULL |
|---|
| 1068 | |
|---|
| 1069 | int eFlags; // copied to entityState_t->eFlags |
|---|
| 1070 | |
|---|
| 1071 | int eventSequence; // pmove generated events |
|---|
| 1072 | int events[MAX_PS_EVENTS]; |
|---|
| 1073 | int eventParms[MAX_PS_EVENTS]; |
|---|
| 1074 | |
|---|
| 1075 | int externalEvent; // events set on player from another source |
|---|
| 1076 | int externalEventParm; |
|---|
| 1077 | int externalEventTime; |
|---|
| 1078 | |
|---|
| 1079 | int clientNum; // ranges from 0 to MAX_CLIENTS-1 |
|---|
| 1080 | int weapon; // copied to entityState_t->weapon |
|---|
| 1081 | int weaponstate; |
|---|
| 1082 | |
|---|
| 1083 | vec3_t viewangles; // for fixed views |
|---|
| 1084 | int viewheight; |
|---|
| 1085 | |
|---|
| 1086 | // damage feedback |
|---|
| 1087 | int damageEvent; // when it changes, latch the other parms |
|---|
| 1088 | int damageYaw; |
|---|
| 1089 | int damagePitch; |
|---|
| 1090 | int damageCount; |
|---|
| 1091 | |
|---|
| 1092 | int stats[MAX_STATS]; |
|---|
| 1093 | int persistant[MAX_PERSISTANT]; // stats that aren't cleared on death |
|---|
| 1094 | int powerups[MAX_POWERUPS]; // level.time that the powerup runs out |
|---|
| 1095 | int ammo[MAX_WEAPONS]; |
|---|
| 1096 | |
|---|
| 1097 | int generic1; |
|---|
| 1098 | int loopSound; |
|---|
| 1099 | int otherEntityNum; |
|---|
| 1100 | |
|---|
| 1101 | // not communicated over the net at all |
|---|
| 1102 | int ping; // server to game info for scoreboard |
|---|
| 1103 | int pmove_framecount; // FIXME: don't transmit over the network |
|---|
| 1104 | int jumppad_frame; |
|---|
| 1105 | int entityEventSequence; |
|---|
| 1106 | } playerState_t; |
|---|
| 1107 | |
|---|
| 1108 | |
|---|
| 1109 | //==================================================================== |
|---|
| 1110 | |
|---|
| 1111 | |
|---|
| 1112 | // |
|---|
| 1113 | // usercmd_t->button bits, many of which are generated by the client system, |
|---|
| 1114 | // so they aren't game/cgame only definitions |
|---|
| 1115 | // |
|---|
| 1116 | #define BUTTON_ATTACK 1 |
|---|
| 1117 | #define BUTTON_TALK 2 // displays talk balloon and disables actions |
|---|
| 1118 | #define BUTTON_USE_HOLDABLE 4 |
|---|
| 1119 | #define BUTTON_GESTURE 8 |
|---|
| 1120 | #define BUTTON_WALKING 16 // walking can't just be infered from MOVE_RUN |
|---|
| 1121 | // because a key pressed late in the frame will |
|---|
| 1122 | // only generate a small move value for that frame |
|---|
| 1123 | // walking will use different animations and |
|---|
| 1124 | // won't generate footsteps |
|---|
| 1125 | #define BUTTON_ATTACK2 32 |
|---|
| 1126 | #define BUTTON_NEGATIVE 64 |
|---|
| 1127 | |
|---|
| 1128 | #define BUTTON_GETFLAG 128 |
|---|
| 1129 | #define BUTTON_GUARDBASE 256 |
|---|
| 1130 | #define BUTTON_PATROL 512 |
|---|
| 1131 | #define BUTTON_FOLLOWME 1024 |
|---|
| 1132 | |
|---|
| 1133 | #define BUTTON_ANY 2048 // any key whatsoever |
|---|
| 1134 | |
|---|
| 1135 | #define MOVE_RUN 120 // if forwardmove or rightmove are >= MOVE_RUN, |
|---|
| 1136 | // then BUTTON_WALKING should be set |
|---|
| 1137 | |
|---|
| 1138 | // usercmd_t is sent to the server each client frame |
|---|
| 1139 | typedef struct usercmd_s { |
|---|
| 1140 | int serverTime; |
|---|
| 1141 | int angles[3]; |
|---|
| 1142 | int buttons; |
|---|
| 1143 | byte weapon; // weapon |
|---|
| 1144 | signed char forwardmove, rightmove, upmove; |
|---|
| 1145 | } usercmd_t; |
|---|
| 1146 | |
|---|
| 1147 | //=================================================================== |
|---|
| 1148 | |
|---|
| 1149 | // if entityState->solid == SOLID_BMODEL, modelindex is an inline model number |
|---|
| 1150 | #define SOLID_BMODEL 0xffffff |
|---|
| 1151 | |
|---|
| 1152 | typedef enum { |
|---|
| 1153 | TR_STATIONARY, |
|---|
| 1154 | TR_INTERPOLATE, // non-parametric, but interpolate between snapshots |
|---|
| 1155 | TR_LINEAR, |
|---|
| 1156 | TR_LINEAR_STOP, |
|---|
| 1157 | TR_SINE, // value = base + sin( time / duration ) * delta |
|---|
| 1158 | TR_GRAVITY, |
|---|
| 1159 | TR_BUOYANCY //TA: what the hell is this doing in here anyway? |
|---|
| 1160 | } trType_t; |
|---|
| 1161 | |
|---|
| 1162 | typedef struct { |
|---|
| 1163 | trType_t trType; |
|---|
| 1164 | int trTime; |
|---|
| 1165 | int trDuration; // if non 0, trTime + trDuration = stop time |
|---|
| 1166 | vec3_t trBase; |
|---|
| 1167 | vec3_t trDelta; // velocity, etc |
|---|
| 1168 | } trajectory_t; |
|---|
| 1169 | |
|---|
| 1170 | // entityState_t is the information conveyed from the server |
|---|
| 1171 | // in an update message about entities that the client will |
|---|
| 1172 | // need to render in some way |
|---|
| 1173 | // Different eTypes may use the information in different ways |
|---|
| 1174 | // The messages are delta compressed, so it doesn't really matter if |
|---|
| 1175 | // the structure size is fairly large |
|---|
| 1176 | |
|---|
| 1177 | typedef struct entityState_s { |
|---|
| 1178 | int number; // entity index |
|---|
| 1179 | int eType; // entityType_t |
|---|
| 1180 | int eFlags; |
|---|
| 1181 | |
|---|
| 1182 | trajectory_t pos; // for calculating position |
|---|
| 1183 | trajectory_t apos; // for calculating angles |
|---|
| 1184 | |
|---|
| 1185 | int time; |
|---|
| 1186 | int time2; |
|---|
| 1187 | |
|---|
| 1188 | vec3_t origin; |
|---|
| 1189 | vec3_t origin2; |
|---|
| 1190 | |
|---|
| 1191 | vec3_t angles; |
|---|
| 1192 | vec3_t angles2; |
|---|
| 1193 | |
|---|
| 1194 | int otherEntityNum; // shotgun sources, etc |
|---|
| 1195 | int otherEntityNum2; |
|---|
| 1196 | |
|---|
| 1197 | int groundEntityNum; // -1 = in air |
|---|
| 1198 | |
|---|
| 1199 | int constantLight; // r + (g<<8) + (b<<16) + (intensity<<24) |
|---|
| 1200 | int loopSound; // constantly loop this sound |
|---|
| 1201 | |
|---|
| 1202 | int modelindex; |
|---|
| 1203 | int modelindex2; |
|---|
| 1204 | int clientNum; // 0 to (MAX_CLIENTS - 1), for players and corpses |
|---|
| 1205 | int frame; |
|---|
| 1206 | |
|---|
| 1207 | int solid; // for client side prediction, trap_linkentity sets this properly |
|---|
| 1208 | |
|---|
| 1209 | int event; // impulse events -- muzzle flashes, footsteps, etc |
|---|
| 1210 | int eventParm; |
|---|
| 1211 | |
|---|
| 1212 | // for players |
|---|
| 1213 | int powerups; // bit flags |
|---|
| 1214 | int weapon; // determines weapon and flash model, etc |
|---|
| 1215 | int legsAnim; // mask off ANIM_TOGGLEBIT |
|---|
| 1216 | int torsoAnim; // mask off ANIM_TOGGLEBIT |
|---|
| 1217 | |
|---|
| 1218 | int generic1; |
|---|
| 1219 | } entityState_t; |
|---|
| 1220 | |
|---|
| 1221 | typedef enum { |
|---|
| 1222 | CA_UNINITIALIZED, |
|---|
| 1223 | CA_DISCONNECTED, // not talking to a server |
|---|
| 1224 | CA_AUTHORIZING, // not used any more, was checking cd key |
|---|
| 1225 | CA_CONNECTING, // sending request packets to the server |
|---|
| 1226 | CA_CHALLENGING, // sending challenge packets to the server |
|---|
| 1227 | CA_CONNECTED, // netchan_t established, getting gamestate |
|---|
| 1228 | CA_LOADING, // only during cgame initialization, never during main loop |
|---|
| 1229 | CA_PRIMED, // got gamestate, waiting for first frame |
|---|
| 1230 | CA_ACTIVE, // game views should be displayed |
|---|
| 1231 | CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server |
|---|
| 1232 | } connstate_t; |
|---|
| 1233 | |
|---|
| 1234 | // font support |
|---|
| 1235 | |
|---|
| 1236 | #define GLYPH_START 0 |
|---|
| 1237 | #define GLYPH_END 255 |
|---|
| 1238 | #define GLYPH_CHARSTART 32 |
|---|
| 1239 | #define GLYPH_CHAREND 127 |
|---|
| 1240 | #define GLYPHS_PER_FONT GLYPH_END - GLYPH_START + 1 |
|---|
| 1241 | typedef struct { |
|---|
| 1242 | int height; // number of scan lines |
|---|
| 1243 | int top; // top of glyph in buffer |
|---|
| 1244 | int bottom; // bottom of glyph in buffer |
|---|
| 1245 | int pitch; // width for copying |
|---|
| 1246 | int xSkip; // x adjustment |
|---|
| 1247 | int imageWidth; // width of actual image |
|---|
| 1248 | int imageHeight; // height of actual image |
|---|
| 1249 | float s; // x offset in image where glyph starts |
|---|
| 1250 | float t; // y offset in image where glyph starts |
|---|
| 1251 | float s2; |
|---|
| 1252 | float t2; |
|---|
| 1253 | qhandle_t glyph; // handle to the shader with the glyph |
|---|
| 1254 | char shaderName[32]; |
|---|
| 1255 | } glyphInfo_t; |
|---|
| 1256 | |
|---|
| 1257 | typedef struct { |
|---|
| 1258 | glyphInfo_t glyphs [GLYPHS_PER_FONT]; |
|---|
| 1259 | float glyphScale; |
|---|
| 1260 | char name[MAX_QPATH]; |
|---|
| 1261 | } fontInfo_t; |
|---|
| 1262 | |
|---|
| 1263 | #define Square(x) ((x)*(x)) |
|---|
| 1264 | |
|---|
| 1265 | // real time |
|---|
| 1266 | //============================================= |
|---|
| 1267 | |
|---|
| 1268 | |
|---|
| 1269 | typedef struct qtime_s { |
|---|
| 1270 | int tm_sec; /* seconds after the minute - [0,59] */ |
|---|
| 1271 | int tm_min; /* minutes after the hour - [0,59] */ |
|---|
| 1272 | int tm_hour; /* hours since midnight - [0,23] */ |
|---|
| 1273 | int tm_mday; /* day of the month - [1,31] */ |
|---|
| 1274 | int tm_mon; /* months since January - [0,11] */ |
|---|
| 1275 | int tm_year; /* years since 1900 */ |
|---|
| 1276 | int tm_wday; /* days since Sunday - [0,6] */ |
|---|
| 1277 | int tm_yday; /* days since January 1 - [0,365] */ |
|---|
| 1278 | int tm_isdst; /* daylight savings time flag */ |
|---|
| 1279 | } qtime_t; |
|---|
| 1280 | |
|---|
| 1281 | |
|---|
| 1282 | // server browser sources |
|---|
| 1283 | // TTimo: AS_MPLAYER is no longer used |
|---|
| 1284 | #define AS_GLOBAL 2 |
|---|
| 1285 | #define AS_MPLAYER 1 |
|---|
| 1286 | #define AS_LOCAL 0 |
|---|
| 1287 | #define AS_FAVORITES 3 |
|---|
| 1288 | |
|---|
| 1289 | |
|---|
| 1290 | // cinematic states |
|---|
| 1291 | typedef enum { |
|---|
| 1292 | FMV_IDLE, |
|---|
| 1293 | FMV_PLAY, // play |
|---|
| 1294 | FMV_EOF, // all other conditions, i.e. stop/EOF/abort |
|---|
| 1295 | FMV_ID_BLT, |
|---|
| 1296 | FMV_ID_IDLE, |
|---|
| 1297 | FMV_LOOPED, |
|---|
| 1298 | FMV_ID_WAIT |
|---|
| 1299 | } e_status; |
|---|
| 1300 | |
|---|
| 1301 | typedef enum _flag_status { |
|---|
| 1302 | FLAG_ATBASE = 0, |
|---|
| 1303 | FLAG_TAKEN, // CTF |
|---|
| 1304 | FLAG_TAKEN_RED, // One Flag CTF |
|---|
| 1305 | FLAG_TAKEN_BLUE, // One Flag CTF |
|---|
| 1306 | FLAG_DROPPED |
|---|
| 1307 | } flagStatus_t; |
|---|
| 1308 | |
|---|
| 1309 | typedef enum { |
|---|
| 1310 | DS_NONE, |
|---|
| 1311 | |
|---|
| 1312 | DS_PLAYBACK, |
|---|
| 1313 | DS_RECORDING, |
|---|
| 1314 | |
|---|
| 1315 | DS_NUM_DEMO_STATES |
|---|
| 1316 | } demoState_t; |
|---|
| 1317 | |
|---|
| 1318 | |
|---|
| 1319 | #define MAX_GLOBAL_SERVERS 4096 |
|---|
| 1320 | #define MAX_OTHER_SERVERS 128 |
|---|
| 1321 | #define MAX_PINGREQUESTS 32 |
|---|
| 1322 | #define MAX_SERVERSTATUSREQUESTS 16 |
|---|
| 1323 | |
|---|
| 1324 | #define SAY_ALL 0 |
|---|
| 1325 | #define SAY_TEAM 1 |
|---|
| 1326 | #define SAY_TELL 2 |
|---|
| 1327 | #define SAY_ACTION 3 |
|---|
| 1328 | #define SAY_ACTION_T 4 |
|---|
| 1329 | #define SAY_ADMINS 5 |
|---|
| 1330 | |
|---|
| 1331 | #define MAX_EMOTICON_NAME_LEN 16 |
|---|
| 1332 | #define MAX_EMOTICONS 64 |
|---|
| 1333 | |
|---|
| 1334 | /* This should not be changed because this value is |
|---|
| 1335 | * expected to be the same on the client and on the server */ |
|---|
| 1336 | #define RSA_KEY_LENGTH 2048 |
|---|
| 1337 | #define RSA_STRING_LENGTH (RSA_KEY_LENGTH / 4 + 1) |
|---|
| 1338 | |
|---|
| 1339 | #endif // __Q_SHARED_H |
|---|