| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#ifndef __Q_SHARED_H |
| 23 |
#define __Q_SHARED_H |
| 24 |
|
| 25 |
#include "globaldefs.h" |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
#define Q3_VERSION "DOOM 0.01" |
| 35 |
|
| 36 |
|
| 37 |
#define ALIGN_ON |
| 38 |
#define ALIGN_OFF |
| 39 |
|
| 40 |
#if GDEF_COMPILER_MSVC |
| 41 |
|
| 42 |
#pragma warning(disable : 4018) // signed/unsigned mismatch |
| 43 |
#pragma warning(disable : 4032) |
| 44 |
#pragma warning(disable : 4051) |
| 45 |
#pragma warning(disable : 4057) // slightly different base types |
| 46 |
#pragma warning(disable : 4100) // unreferenced formal parameter |
| 47 |
#pragma warning(disable : 4115) |
| 48 |
#pragma warning(disable : 4125) // decimal digit terminates octal escape sequence |
| 49 |
#pragma warning(disable : 4127) // conditional expression is constant |
| 50 |
#pragma warning(disable : 4136) |
| 51 |
#pragma warning(disable : 4201) |
| 52 |
#pragma warning(disable : 4214) |
| 53 |
#pragma warning(disable : 4244) |
| 54 |
#pragma warning(disable : 4305) // truncation from const double to float |
| 55 |
#pragma warning(disable : 4310) // cast truncates constant value |
| 56 |
#pragma warning(disable : 4514) |
| 57 |
#pragma warning(disable : 4711) // selected for automatic inline expansion |
| 58 |
#pragma warning(disable : 4220) // varargs matches remaining parameters |
| 59 |
|
| 60 |
#endif |
| 61 |
|
| 62 |
#include <assert.h> |
| 63 |
#include <math.h> |
| 64 |
#include <stdio.h> |
| 65 |
#include <stdarg.h> |
| 66 |
#include <string.h> |
| 67 |
#include <stdlib.h> |
| 68 |
#include <time.h> |
| 69 |
#include <ctype.h> |
| 70 |
#include <cstddef> |
| 71 |
|
| 72 |
#if GDEF_OS_WINDOWS |
| 73 |
#include <malloc.h> |
| 74 |
#endif |
| 75 |
#if GDEF_COMPILER_MSVC |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
#endif |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
#if GDEF_ARCH_BITS_32 && !defined __sun__ && !defined __LCC__ |
| 84 |
#define id386 1 |
| 85 |
#else |
| 86 |
#define id386 0 |
| 87 |
#endif |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
#define QDECL |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
#if GDEF_OS_WINDOWS |
| 96 |
|
| 97 |
#define MAC_STATIC |
| 98 |
|
| 99 |
#undef QDECL |
| 100 |
#define QDECL __cdecl |
| 101 |
|
| 102 |
|
| 103 |
#ifdef NDEBUG |
| 104 |
#if GDEF_ARCH_BITS_32 |
| 105 |
#define CPUSTRING "win-x86" |
| 106 |
#elif defined _M_ALPHA |
| 107 |
#define CPUSTRING "win-AXP" |
| 108 |
#endif |
| 109 |
#else |
| 110 |
#if GDEF_ARCH_BITS_32 |
| 111 |
#define CPUSTRING "win-x86-debug" |
| 112 |
#elif defined _M_ALPHA |
| 113 |
#define CPUSTRING "win-AXP-debug" |
| 114 |
#endif |
| 115 |
#endif |
| 116 |
|
| 117 |
|
| 118 |
#define PATH_SEP '\\' |
| 119 |
|
| 120 |
#endif |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
#if GDEF_OS_MACOS && defined( __MACH__ ) |
| 125 |
|
| 126 |
#define MAC_STATIC |
| 127 |
|
| 128 |
#ifdef __ppc__ |
| 129 |
#define CPUSTRING "MacOSXS-ppc" |
| 130 |
#elif GDEF_ARCH_BITS_32 |
| 131 |
#define CPUSTRING "MacOSXS-i386" |
| 132 |
#else |
| 133 |
#define CPUSTRING "MacOSXS-other" |
| 134 |
#endif |
| 135 |
|
| 136 |
#define PATH_SEP '/' |
| 137 |
|
| 138 |
#define GAME_HARD_LINKED |
| 139 |
#define CGAME_HARD_LINKED |
| 140 |
#define UI_HARD_LINKED |
| 141 |
#define _alloca alloca |
| 142 |
|
| 143 |
#undef ALIGN_ON |
| 144 |
#undef ALIGN_OFF |
| 145 |
#define ALIGN_ON #pragma align( 16 ) |
| 146 |
#define ALIGN_OFF #pragma align() |
| 147 |
|
| 148 |
#ifdef __cplusplus |
| 149 |
extern "C" { |
| 150 |
#endif |
| 151 |
|
| 152 |
void *osxAllocateMemory( long size ); |
| 153 |
void osxFreeMemory( void *pointer ); |
| 154 |
|
| 155 |
#ifdef __cplusplus |
| 156 |
} |
| 157 |
#endif |
| 158 |
|
| 159 |
#endif |
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
#ifdef __MACOS__ |
| 164 |
|
| 165 |
#define MAC_STATIC static |
| 166 |
|
| 167 |
#define CPUSTRING "MacOS-PPC" |
| 168 |
|
| 169 |
#define PATH_SEP ':' |
| 170 |
|
| 171 |
void Sys_PumpEvents( void ); |
| 172 |
|
| 173 |
#endif |
| 174 |
|
| 175 |
#ifdef __MRC__ |
| 176 |
|
| 177 |
#define MAC_STATIC |
| 178 |
|
| 179 |
#define CPUSTRING "MacOS-PPC" |
| 180 |
|
| 181 |
#define PATH_SEP ':' |
| 182 |
|
| 183 |
void Sys_PumpEvents( void ); |
| 184 |
|
| 185 |
#undef QDECL |
| 186 |
#define QDECL __cdecl |
| 187 |
|
| 188 |
#define _alloca alloca |
| 189 |
#endif |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
#if GDEF_OS_LINUX |
| 196 |
|
| 197 |
#define MAC_STATIC |
| 198 |
|
| 199 |
#if GDEF_ARCH_BITS_32 |
| 200 |
#define CPUSTRING "linux-i386" |
| 201 |
#elif defined __axp__ |
| 202 |
#define CPUSTRING "linux-alpha" |
| 203 |
#else |
| 204 |
#define CPUSTRING "linux-other" |
| 205 |
#endif |
| 206 |
|
| 207 |
#define PATH_SEP '/' |
| 208 |
|
| 209 |
#endif |
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
typedef enum {qfalse, qtrue} qboolean; |
| 214 |
|
| 215 |
typedef unsigned char byte; |
| 216 |
|
| 217 |
#define EQUAL_EPSILON 0.001 |
| 218 |
|
| 219 |
typedef int qhandle_t; |
| 220 |
typedef int sfxHandle_t; |
| 221 |
typedef int fileHandle_t; |
| 222 |
typedef int clipHandle_t; |
| 223 |
|
| 224 |
typedef enum { |
| 225 |
INVALID_JOINT = -1 |
| 226 |
} jointHandle_t; |
| 227 |
|
| 228 |
#ifndef NULL |
| 229 |
#define NULL ( (void *)0 ) |
| 230 |
#endif |
| 231 |
|
| 232 |
#define MAX_QINT 0x7fffffff |
| 233 |
#define MIN_QINT ( -MAX_QINT - 1 ) |
| 234 |
|
| 235 |
#if !defined(__cplusplus) && !defined(max) |
| 236 |
#define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) ) |
| 237 |
#define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) ) |
| 238 |
#endif |
| 239 |
|
| 240 |
#ifndef sign |
| 241 |
#define sign( f ) ( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) ) |
| 242 |
#endif |
| 243 |
|
| 244 |
|
| 245 |
#define PITCH 0 // up / down |
| 246 |
#define YAW 1 // left / right |
| 247 |
#define ROLL 2 // fall over |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
#define MAX_STRING_CHARS 1024 // max length of a string passed to Cmd_TokenizeString |
| 252 |
#define MAX_STRING_TOKENS 256 // max tokens resulting from Cmd_TokenizeString |
| 253 |
#define MAX_TOKEN_CHARS 1024 // max length of an individual token |
| 254 |
|
| 255 |
#define MAX_INFO_STRING 1024 |
| 256 |
#define MAX_INFO_KEY 1024 |
| 257 |
#define MAX_INFO_VALUE 1024 |
| 258 |
|
| 259 |
|
| 260 |
#define MAX_QPATH 64 // max length of a quake game pathname |
| 261 |
#ifdef PATH_MAX |
| 262 |
#define MAX_OSPATH PATH_MAX // max length of a filesystem pathname |
| 263 |
#else |
| 264 |
#define MAX_OSPATH 128 // max length of a filesystem pathname |
| 265 |
#endif |
| 266 |
|
| 267 |
#define MAX_NAME_LENGTH 32 // max length of a client name |
| 268 |
|
| 269 |
|
| 270 |
typedef enum { |
| 271 |
EXEC_NOW, |
| 272 |
|
| 273 |
EXEC_INSERT, |
| 274 |
EXEC_APPEND |
| 275 |
} cbufExec_t; |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
#define MAX_MAP_AREA_BYTES 32 // bit vector of area visibility |
| 282 |
|
| 283 |
#undef ERR_FATAL // malloc.h on unix |
| 284 |
|
| 285 |
|
| 286 |
typedef enum { |
| 287 |
ERR_NONE, |
| 288 |
ERR_FATAL, |
| 289 |
ERR_DROP, |
| 290 |
ERR_DISCONNECT, |
| 291 |
ERR_NEED_CD |
| 292 |
} errorParm_t; |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
#define PROP_GAP_WIDTH 3 |
| 298 |
#define PROP_SPACE_WIDTH 8 |
| 299 |
#define PROP_HEIGHT 27 |
| 300 |
#define PROP_SMALL_SIZE_SCALE 0.75 |
| 301 |
|
| 302 |
#define BLINK_DIVISOR 200 |
| 303 |
#define PULSE_DIVISOR 75 |
| 304 |
|
| 305 |
#define UI_LEFT 0x00000000 // default |
| 306 |
#define UI_CENTER 0x00000001 |
| 307 |
#define UI_RIGHT 0x00000002 |
| 308 |
#define UI_FORMATMASK 0x00000007 |
| 309 |
#define UI_SMALLFONT 0x00000010 |
| 310 |
#define UI_BIGFONT 0x00000020 // default |
| 311 |
#define UI_GIANTFONT 0x00000040 |
| 312 |
#define UI_DROPSHADOW 0x00000800 |
| 313 |
#define UI_BLINK 0x00001000 |
| 314 |
#define UI_INVERSE 0x00002000 |
| 315 |
#define UI_PULSE 0x00004000 |
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
#ifdef __cplusplus |
| 326 |
#define SIDE_FRONT 0 |
| 327 |
#define SIDE_BACK 1 |
| 328 |
#define SIDE_ON 2 |
| 329 |
#define SIDE_CROSS 3 |
| 330 |
|
| 331 |
#define Q_PI 3.14159265358979323846 |
| 332 |
#ifndef M_PI |
| 333 |
#define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h |
| 334 |
#endif |
| 335 |
|
| 336 |
#include "math_vector.h" |
| 337 |
#include "math_angles.h" |
| 338 |
#include "math_matrix.h" |
| 339 |
#include "math_quaternion.h" |
| 340 |
|
| 341 |
class idVec3; |
| 342 |
typedef idVec3 &vec3_p; |
| 343 |
typedef const idVec3 &vec3_c; |
| 344 |
|
| 345 |
class angles_t; |
| 346 |
typedef angles_t &angles_p; |
| 347 |
typedef const angles_t &angles_c; |
| 348 |
|
| 349 |
class mat3_t; |
| 350 |
typedef mat3_t &mat3_p; |
| 351 |
typedef const mat3_t &mat3_c; |
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
#define NUMVERTEXNORMALS 162 |
| 356 |
extern idVec3 bytedirs[NUMVERTEXNORMALS]; |
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
#define SCREEN_WIDTH 640 |
| 361 |
#define SCREEN_HEIGHT 480 |
| 362 |
|
| 363 |
#define TINYCHAR_WIDTH ( SMALLCHAR_WIDTH ) |
| 364 |
#define TINYCHAR_HEIGHT ( SMALLCHAR_HEIGHT / 2 ) |
| 365 |
|
| 366 |
#define SMALLCHAR_WIDTH 8 |
| 367 |
#define SMALLCHAR_HEIGHT 16 |
| 368 |
|
| 369 |
#define BIGCHAR_WIDTH 16 |
| 370 |
#define BIGCHAR_HEIGHT 16 |
| 371 |
|
| 372 |
#define GIANTCHAR_WIDTH 32 |
| 373 |
#define GIANTCHAR_HEIGHT 48 |
| 374 |
|
| 375 |
extern idVec4 colorBlack; |
| 376 |
extern idVec4 colorRed; |
| 377 |
extern idVec4 colorGreen; |
| 378 |
extern idVec4 colorBlue; |
| 379 |
extern idVec4 colorYellow; |
| 380 |
extern idVec4 colorMagenta; |
| 381 |
extern idVec4 colorCyan; |
| 382 |
extern idVec4 colorWhite; |
| 383 |
extern idVec4 colorLtGrey; |
| 384 |
extern idVec4 colorMdGrey; |
| 385 |
extern idVec4 colorDkGrey; |
| 386 |
|
| 387 |
#define Q_COLOR_ESCAPE '^' |
| 388 |
#define Q_IsColorString( p ) ( p && *( p ) == Q_COLOR_ESCAPE && *( ( p ) + 1 ) && *( ( p ) + 1 ) != Q_COLOR_ESCAPE ) |
| 389 |
|
| 390 |
#define COLOR_BLACK '0' |
| 391 |
#define COLOR_RED '1' |
| 392 |
#define COLOR_GREEN '2' |
| 393 |
#define COLOR_YELLOW '3' |
| 394 |
#define COLOR_BLUE '4' |
| 395 |
#define COLOR_CYAN '5' |
| 396 |
#define COLOR_MAGENTA '6' |
| 397 |
#define COLOR_WHITE '7' |
| 398 |
#define ColorIndex( c ) ( ( ( c ) - '0' ) & 7 ) |
| 399 |
|
| 400 |
#define S_COLOR_BLACK "^0" |
| 401 |
#define S_COLOR_RED "^1" |
| 402 |
#define S_COLOR_GREEN "^2" |
| 403 |
#define S_COLOR_YELLOW "^3" |
| 404 |
#define S_COLOR_BLUE "^4" |
| 405 |
#define S_COLOR_CYAN "^5" |
| 406 |
#define S_COLOR_MAGENTA "^6" |
| 407 |
#define S_COLOR_WHITE "^7" |
| 408 |
|
| 409 |
extern idVec4 g_color_table[8]; |
| 410 |
|
| 411 |
#define MAKERGB( v, r, g, b ) v[0] = r; v[1] = g; v[2] = b |
| 412 |
#define MAKERGBA( v, r, g, b, a ) v[0] = r; v[1] = g; v[2] = b; v[3] = a |
| 413 |
|
| 414 |
#define DEG2RAD( a ) ( ( ( a ) * M_PI ) / 180.0F ) |
| 415 |
#define RAD2DEG( a ) ( ( ( a ) * 180.0f ) / M_PI ) |
| 416 |
|
| 417 |
struct cplane_s; |
| 418 |
|
| 419 |
extern idVec3 vec3_origin; |
| 420 |
extern idVec4 vec4_origin; |
| 421 |
extern mat3_t axisDefault; |
| 422 |
|
| 423 |
#define nanmask ( 255 << 23 ) |
| 424 |
|
| 425 |
#define IS_NAN( x ) ( ( ( *(int *)&x ) & nanmask ) == nanmask ) |
| 426 |
|
| 427 |
float Q_fabs( float f ); |
| 428 |
float Q_rsqrt( float f ); |
| 429 |
|
| 430 |
#define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) ) |
| 431 |
|
| 432 |
signed char ClampChar( int i ); |
| 433 |
signed short ClampShort( int i ); |
| 434 |
|
| 435 |
|
| 436 |
int DirToByte( const idVec3 &dir ); |
| 437 |
void ByteToDir( int b, vec3_p dir ); |
| 438 |
|
| 439 |
#define DotProduct( a,b ) ( ( a )[0] * ( b )[0] + ( a )[1] * ( b )[1] + ( a )[2] * ( b )[2] ) |
| 440 |
#define VectorSubtract( a,b,c ) ( ( c )[0] = ( a )[0] - ( b )[0],( c )[1] = ( a )[1] - ( b )[1],( c )[2] = ( a )[2] - ( b )[2] ) |
| 441 |
#define VectorAdd( a,b,c ) ( ( c )[0] = ( a )[0] + ( b )[0],( c )[1] = ( a )[1] + ( b )[1],( c )[2] = ( a )[2] + ( b )[2] ) |
| 442 |
#define VectorCopy( a,b ) ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2] ) |
| 443 |
|
| 444 |
|
| 445 |
#define VectorScale( v, s, o ) ( ( o )[0] = ( v )[0] * ( s ),( o )[1] = ( v )[1] * ( s ),( o )[2] = ( v )[2] * ( s ) ) |
| 446 |
#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 ) ) |
| 447 |
#define CrossProduct( a,b,c ) ( ( c )[0] = ( a )[1] * ( b )[2] - ( a )[2] * ( b )[1],( c )[1] = ( a )[2] * ( b )[0] - ( a )[0] * ( b )[2],( c )[2] = ( a )[0] * ( b )[1] - ( a )[1] * ( b )[0] ) |
| 448 |
|
| 449 |
#define DotProduct4( x,y ) ( ( x )[0] * ( y )[0] + ( x )[1] * ( y )[1] + ( x )[2] * ( y )[2] + ( x )[3] * ( y )[3] ) |
| 450 |
#define VectorSubtract4( 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] ) |
| 451 |
#define VectorAdd4( 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] ) |
| 452 |
#define VectorCopy4( a,b ) ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2],( b )[3] = ( a )[3] ) |
| 453 |
#define VectorScale4( v, s, o ) ( ( o )[0] = ( v )[0] * ( s ),( o )[1] = ( v )[1] * ( s ),( o )[2] = ( v )[2] * ( s ),( o )[3] = ( v )[3] * ( s ) ) |
| 454 |
#define VectorMA4( v, s, b, o ) ( ( o )[0] = ( v )[0] + ( b )[0] * ( s ),( o )[1] = ( v )[1] + ( b )[1] * ( s ),( o )[2] = ( v )[2] + ( b )[2] * ( s ),( o )[3] = ( v )[3] + ( b )[3] * ( s ) ) |
| 455 |
|
| 456 |
|
| 457 |
#define VectorClear( a ) ( ( a )[0] = ( a )[1] = ( a )[2] = 0 ) |
| 458 |
#define VectorNegate( a,b ) ( ( b )[0] = -( a )[0],( b )[1] = -( a )[1],( b )[2] = -( a )[2] ) |
| 459 |
#define VectorSet( v, x, y, z ) ( ( v )[0] = ( x ), ( v )[1] = ( y ), ( v )[2] = ( z ) ) |
| 460 |
#define Vector4Copy( a,b ) ( ( b )[0] = ( a )[0],( b )[1] = ( a )[1],( b )[2] = ( a )[2],( b )[3] = ( a )[3] ) |
| 461 |
|
| 462 |
#define SnapVector( v ) {v[0] = (int)v[0]; v[1] = (int)v[1]; v[2] = (int)v[2]; } |
| 463 |
|
| 464 |
float NormalizeColor( vec3_c in, vec3_p out ); |
| 465 |
|
| 466 |
int VectorCompare( vec3_c v1, vec3_c v2 ); |
| 467 |
float VectorLength( vec3_c v ); |
| 468 |
float Distance( vec3_c p1, vec3_c p2 ); |
| 469 |
float DistanceSquared( vec3_c p1, vec3_c p2 ); |
| 470 |
float VectorNormalize( vec3_p v ); |
| 471 |
void VectorNormalizeFast( vec3_p v ); |
| 472 |
float VectorNormalize2( vec3_c v, vec3_p out ); |
| 473 |
void VectorInverse( vec3_p v ); |
| 474 |
void VectorRotate( vec3_c in, mat3_c matrix, vec3_p out ); |
| 475 |
void VectorPolar( vec3_p v, float radius, float theta, float phi ); |
| 476 |
void VectorSnap( vec3_p v ); |
| 477 |
void Vector53Copy( const idVec5_t &in, vec3_p out ); |
| 478 |
void Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out ); |
| 479 |
void Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out ); |
| 480 |
void VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out ); |
| 481 |
void VectorRotate3Origin( vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out ); |
| 482 |
|
| 483 |
|
| 484 |
int Q_log2( int val ); |
| 485 |
|
| 486 |
int Q_rand( int *seed ); |
| 487 |
float Q_random( int *seed ); |
| 488 |
float Q_crandom( int *seed ); |
| 489 |
|
| 490 |
#define random() ( ( rand() & 0x7fff ) / ( (float)0x7fff ) ) |
| 491 |
#define crandom() ( 2.0 * ( random() - 0.5 ) ) |
| 492 |
|
| 493 |
float Q_rint( float in ); |
| 494 |
|
| 495 |
void vectoangles( vec3_c value1, angles_p angles ); |
| 496 |
void AnglesToAxis( angles_c angles, mat3_p axis ); |
| 497 |
|
| 498 |
void AxisCopy( mat3_c in, mat3_p out ); |
| 499 |
qboolean AxisRotated( mat3_c in ); |
| 500 |
|
| 501 |
int SignbitsForNormal( vec3_c normal ); |
| 502 |
int BoxOnPlaneSide( const Bounds &b, struct cplane_s *p ); |
| 503 |
|
| 504 |
float AngleMod( float a ); |
| 505 |
float LerpAngle( float from, float to, float frac ); |
| 506 |
float AngleSubtract( float a1, float a2 ); |
| 507 |
void AnglesSubtract( angles_c v1, angles_c v2, angles_p v3 ); |
| 508 |
|
| 509 |
float AngleNormalize360( float angle ); |
| 510 |
float AngleNormalize180( float angle ); |
| 511 |
float AngleDelta( float angle1, float angle2 ); |
| 512 |
|
| 513 |
qboolean PlaneFromPoints( idVec4 &plane, vec3_c a, vec3_c b, vec3_c c ); |
| 514 |
void ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal ); |
| 515 |
void RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees ); |
| 516 |
void RotateAroundDirection( mat3_p axis, float yaw ); |
| 517 |
void MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up ); |
| 518 |
|
| 519 |
|
| 520 |
int PlaneTypeForNormal( vec3_c normal ); |
| 521 |
|
| 522 |
void MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out ); |
| 523 |
void MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out ); |
| 524 |
void MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out ); |
| 525 |
void MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); |
| 526 |
void AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up ); |
| 527 |
void PerpendicularVector( vec3_p dst, vec3_c src ); |
| 528 |
|
| 529 |
float TriangleArea( vec3_c a, vec3_c b, vec3_c c ); |
| 530 |
#endif |
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
float Com_Clamp( float min, float max, float value ); |
| 535 |
|
| 536 |
#define FILE_HASH_SIZE 1024 |
| 537 |
int Com_HashString( const char *fname ); |
| 538 |
|
| 539 |
char *Com_SkipPath( char *pathname ); |
| 540 |
|
| 541 |
|
| 542 |
void Com_StripExtension( const char *in, char *out ); |
| 543 |
|
| 544 |
|
| 545 |
void Com_DefaultExtension( char *path, int maxSize, const char *extension ); |
| 546 |
|
| 547 |
int Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] ); |
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
void Com_BeginParseSession( const char *filename ); |
| 559 |
void Com_EndParseSession( void ); |
| 560 |
|
| 561 |
int Com_GetCurrentParseLine( void ); |
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
const char *Com_Parse( const char *( *data_p ) ); |
| 569 |
const char *Com_ParseOnLine( const char *( *data_p ) ); |
| 570 |
const char *Com_ParseRestOfLine( const char *( *data_p ) ); |
| 571 |
|
| 572 |
void Com_UngetToken( void ); |
| 573 |
|
| 574 |
#ifdef __cplusplus |
| 575 |
void Com_MatchToken( const char *( *buf_p ), const char *match, qboolean warning = qfalse ); |
| 576 |
#else |
| 577 |
void Com_MatchToken( const char *( *buf_p ), const char *match, qboolean warning ); |
| 578 |
#endif |
| 579 |
|
| 580 |
void Com_ScriptError( const char *msg, ... ); |
| 581 |
void Com_ScriptWarning( const char *msg, ... ); |
| 582 |
|
| 583 |
void Com_SkipBracedSection( const char *( *program ) ); |
| 584 |
void Com_SkipRestOfLine( const char *( *data ) ); |
| 585 |
|
| 586 |
float Com_ParseFloat( const char *( *buf_p ) ); |
| 587 |
int Com_ParseInt( const char *( *buf_p ) ); |
| 588 |
|
| 589 |
void Com_Parse1DMatrix( const char *( *buf_p ), int x, float *m ); |
| 590 |
void Com_Parse2DMatrix( const char *( *buf_p ), int y, int x, float *m ); |
| 591 |
void Com_Parse3DMatrix( const char *( *buf_p ), int z, int y, int x, float *m ); |
| 592 |
|
| 593 |
|
| 594 |
#ifdef __cplusplus |
| 595 |
extern "C" { |
| 596 |
#endif |
| 597 |
|
| 598 |
void QDECL Com_sprintf( char *dest, std::size_t size, const char *fmt, ... ); |
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
typedef enum { |
| 603 |
FS_READ, |
| 604 |
FS_WRITE, |
| 605 |
FS_APPEND, |
| 606 |
FS_APPEND_SYNC |
| 607 |
} fsMode_t; |
| 608 |
|
| 609 |
typedef enum { |
| 610 |
FS_SEEK_CUR, |
| 611 |
FS_SEEK_END, |
| 612 |
FS_SEEK_SET |
| 613 |
} fsOrigin_t; |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
int Q_isprint( int c ); |
| 618 |
int Q_islower( int c ); |
| 619 |
int Q_isupper( int c ); |
| 620 |
int Q_isalpha( int c ); |
| 621 |
|
| 622 |
|
| 623 |
int Q_stricmp( const char *s1, const char *s2 ); |
| 624 |
int Q_strncmp( const char *s1, const char *s2, int n ); |
| 625 |
int Q_stricmpn( const char *s1, const char *s2, int n ); |
| 626 |
char *Q_strlwr( char *s1 ); |
| 627 |
char *Q_strupr( char *s1 ); |
| 628 |
char *Q_strrchr( const char* string, int c ); |
| 629 |
|
| 630 |
|
| 631 |
void Q_strncpyz( char *dest, const char *src, std::size_t destsize ); |
| 632 |
void Q_strcat( char *dest, std::size_t size, const char *src ); |
| 633 |
|
| 634 |
|
| 635 |
int Q_PrintStrlen( const char *string ); |
| 636 |
|
| 637 |
char *Q_CleanStr( char *string ); |
| 638 |
|
| 639 |
int Com_Filter( const char *filter, const char *name, int casesensitive ); |
| 640 |
const char *Com_StringContains( const char *str1, const char *str2, int casesensitive ); |
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
short BigShort( short l ); |
| 646 |
short LittleShort( short l ); |
| 647 |
int BigLong( int l ); |
| 648 |
int LittleLong( int l ); |
| 649 |
float BigFloat( float l ); |
| 650 |
float LittleFloat( float l ); |
| 651 |
|
| 652 |
void Swap_Init( void ); |
| 653 |
char *QDECL va( const char *format, ... ); |
| 654 |
|
| 655 |
#ifdef __cplusplus |
| 656 |
} |
| 657 |
#endif |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
#ifdef __cplusplus |
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
typedef struct ePair_s { |
| 666 |
char *key; |
| 667 |
char *value; |
| 668 |
} ePair_t; |
| 669 |
|
| 670 |
typedef struct mapSide_s { |
| 671 |
char material[MAX_QPATH]; |
| 672 |
idVec4 plane; |
| 673 |
idVec4 textureVectors[2]; |
| 674 |
} mapSide_t; |
| 675 |
|
| 676 |
typedef struct { |
| 677 |
int numSides; |
| 678 |
mapSide_t **sides; |
| 679 |
} mapBrush_t; |
| 680 |
|
| 681 |
typedef struct { |
| 682 |
idVec3 xyz; |
| 683 |
float st[2]; |
| 684 |
} patchVertex_t; |
| 685 |
|
| 686 |
typedef struct { |
| 687 |
char material[MAX_QPATH]; |
| 688 |
int width, height; |
| 689 |
patchVertex_t *patchVerts; |
| 690 |
} mapPatch_t; |
| 691 |
|
| 692 |
typedef struct { |
| 693 |
char modelName[MAX_QPATH]; |
| 694 |
float matrix[16]; |
| 695 |
} mapModel_t; |
| 696 |
|
| 697 |
typedef struct mapPrimitive_s { |
| 698 |
int numEpairs; |
| 699 |
ePair_t **ePairs; |
| 700 |
|
| 701 |
|
| 702 |
mapBrush_t *brush; |
| 703 |
mapPatch_t *patch; |
| 704 |
mapModel_t *model; |
| 705 |
} mapPrimitive_t; |
| 706 |
|
| 707 |
typedef struct mapEntity_s { |
| 708 |
int numPrimitives; |
| 709 |
mapPrimitive_t **primitives; |
| 710 |
|
| 711 |
int numEpairs; |
| 712 |
ePair_t **ePairs; |
| 713 |
} mapEntity_t; |
| 714 |
|
| 715 |
typedef struct { |
| 716 |
int numEntities; |
| 717 |
mapEntity_t **entities; |
| 718 |
} mapFile_t; |
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
mapFile_t *ParseMapFile( const char *text ); |
| 724 |
void FreeMapFile( mapFile_t *mapFile ); |
| 725 |
void WriteMapFile( const mapFile_t *mapFile, FILE *f ); |
| 726 |
|
| 727 |
|
| 728 |
const char *ValueForMapEntityKey( const mapEntity_t *ent, const char *key ); |
| 729 |
float FloatForMapEntityKey( const mapEntity_t *ent, const char *key ); |
| 730 |
qboolean GetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3 &vec ); |
| 731 |
|
| 732 |
typedef struct { |
| 733 |
idVec3 xyz; |
| 734 |
idVec2 st; |
| 735 |
idVec3 normal; |
| 736 |
idVec3 tangents[2]; |
| 737 |
byte smoothing[4]; |
| 738 |
} drawVert_t; |
| 739 |
|
| 740 |
typedef struct { |
| 741 |
int width, height; |
| 742 |
drawVert_t *verts; |
| 743 |
} drawVertMesh_t; |
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
drawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError ); |
| 748 |
#endif |
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
#ifdef __cplusplus |
| 753 |
extern "C" { |
| 754 |
#endif |
| 755 |
|
| 756 |
void QDECL Com_Error( int level, const char *error, ... ); |
| 757 |
void QDECL Com_Printf( const char *msg, ... ); |
| 758 |
void QDECL Com_DPrintf( const char *msg, ... ); |
| 759 |
|
| 760 |
#ifdef __cplusplus |
| 761 |
} |
| 762 |
#endif |
| 763 |
|
| 764 |
|
| 765 |
typedef struct { |
| 766 |
qboolean frameMemory; |
| 767 |
int currentElements; |
| 768 |
int maxElements; |
| 769 |
void **elements; |
| 770 |
} growList_t; |
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
void Com_InitGrowList( growList_t *list, int maxElements ); |
| 775 |
int Com_AddToGrowList( growList_t *list, void *data ); |
| 776 |
void *Com_GrowListElement( const growList_t *list, int index ); |
| 777 |
int Com_IndexForGrowListElement( const growList_t *list, const void *element ); |
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
const char *Info_ValueForKey( const char *s, const char *key ); |
| 784 |
void Info_RemoveKey( char *s, const char *key ); |
| 785 |
void Info_SetValueForKey( char *s, const char *key, const char *value ); |
| 786 |
qboolean Info_Validate( const char *s ); |
| 787 |
void Info_NextPair( const char *( *s ), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] ); |
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
#ifdef __cplusplus |
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
#endif |
| 802 |
|
| 803 |
#endif |