Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

q_shared.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #ifndef __Q_SHARED_H
00023 #define __Q_SHARED_H
00024 
00025 // q_shared.h -- included first by ALL program modules.
00026 // these are the definitions that have no dependance on
00027 // central system services, and can be used by any part
00028 // of the program without any state issues.
00029 
00030 // A user mod should never modify this file
00031 
00032 // incursion of DOOM code into the Q3A codebase
00033 //#define   Q3_VERSION      "DOOM 0.01"
00034 
00035 // alignment macros for SIMD
00036 #define ALIGN_ON
00037 #define ALIGN_OFF
00038 
00039 #ifdef _WIN32
00040 
00041 #pragma warning(disable : 4018)     // signed/unsigned mismatch
00042 #pragma warning(disable : 4032)
00043 #pragma warning(disable : 4051)
00044 #pragma warning(disable : 4057)     // slightly different base types
00045 #pragma warning(disable : 4100)     // unreferenced formal parameter
00046 #pragma warning(disable : 4115)
00047 #pragma warning(disable : 4125)     // decimal digit terminates octal escape sequence
00048 #pragma warning(disable : 4127)     // conditional expression is constant
00049 #pragma warning(disable : 4136)
00050 #pragma warning(disable : 4201)
00051 #pragma warning(disable : 4214)
00052 #pragma warning(disable : 4244)
00053 #pragma warning(disable : 4305)     // truncation from const double to float
00054 #pragma warning(disable : 4310)     // cast truncates constant value
00055 #pragma warning(disable : 4514)
00056 #pragma warning(disable : 4711)     // selected for automatic inline expansion
00057 #pragma warning(disable : 4220)     // varargs matches remaining parameters
00058 
00059 #endif
00060 
00061 #include <assert.h>
00062 #include <math.h>
00063 #include <stdio.h>
00064 #include <stdarg.h>
00065 #include <string.h>
00066 #include <stdlib.h>
00067 #include <time.h>
00068 #include <ctype.h>
00069 #ifdef WIN32                // mac doesn't have malloc.h
00070 #include <malloc.h>         // for _alloca()
00071 #endif
00072 #ifdef _WIN32
00073 
00074 //#pragma intrinsic( memset, memcpy )
00075 
00076 #endif
00077 
00078 
00079 // this is the define for determining if we have an asm version of a C function
00080 #if (defined _M_IX86 || defined __i386__) && !defined __sun__  && !defined __LCC__
00081 #define id386   1
00082 #else
00083 #define id386   0
00084 #endif
00085 
00086 // for windows fastcall option
00087 
00088 #define QDECL
00089 
00090 //======================= WIN32 DEFINES =================================
00091 
00092 #ifdef WIN32
00093 
00094 #define MAC_STATIC
00095 
00096 #undef QDECL
00097 #define QDECL   __cdecl
00098 
00099 // buildstring will be incorporated into the version string
00100 #ifdef NDEBUG
00101 #ifdef _M_IX86
00102 #define CPUSTRING   "win-x86"
00103 #elif defined _M_ALPHA
00104 #define CPUSTRING   "win-AXP"
00105 #endif
00106 #else
00107 #ifdef _M_IX86
00108 #define CPUSTRING   "win-x86-debug"
00109 #elif defined _M_ALPHA
00110 #define CPUSTRING   "win-AXP-debug"
00111 #endif
00112 #endif
00113 
00114 
00115 #define PATH_SEP '\\'
00116 
00117 #endif
00118 
00119 //======================= MAC OS X SERVER DEFINES =====================
00120 
00121 #if defined(__MACH__) && defined(__APPLE__)
00122 
00123 #define MAC_STATIC
00124 
00125 #ifdef __ppc__
00126 #define CPUSTRING   "MacOSXS-ppc"
00127 #elif defined __i386__
00128 #define CPUSTRING   "MacOSXS-i386"
00129 #else
00130 #define CPUSTRING   "MacOSXS-other"
00131 #endif
00132 
00133 #define PATH_SEP    '/'
00134 
00135 #define GAME_HARD_LINKED
00136 #define CGAME_HARD_LINKED
00137 #define UI_HARD_LINKED
00138 #define _alloca alloca
00139 
00140 #undef ALIGN_ON
00141 #undef ALIGN_OFF
00142 #define ALIGN_ON        #pragma align(16)
00143 #define ALIGN_OFF       #pragma align()
00144 
00145 #ifdef __cplusplus
00146     extern "C" {
00147 #endif
00148 
00149 void *osxAllocateMemory(long size);
00150 void osxFreeMemory(void *pointer);
00151 
00152 #ifdef __cplusplus
00153         }
00154 #endif
00155 
00156 #endif
00157 
00158 //======================= MAC DEFINES =================================
00159 
00160 #ifdef __MACOS__
00161 
00162 #define MAC_STATIC static
00163 
00164 #define CPUSTRING   "MacOS-PPC"
00165 
00166 #define PATH_SEP ':'
00167 
00168 void Sys_PumpEvents( void );
00169 
00170 #endif
00171 
00172 #ifdef __MRC__
00173 
00174 #define MAC_STATIC
00175 
00176 #define CPUSTRING   "MacOS-PPC"
00177 
00178 #define PATH_SEP ':'
00179 
00180 void Sys_PumpEvents( void );
00181 
00182 #undef QDECL
00183 #define QDECL   __cdecl
00184 
00185 #define _alloca alloca
00186 #endif
00187 
00188 //======================= LINUX DEFINES =================================
00189 
00190 // the mac compiler can't handle >32k of locals, so we
00191 // just waste space and make big arrays static...
00192 #ifdef __linux__
00193 
00194 // bk001205 - from Makefile
00195 #define stricmp strcasecmp
00196 
00197 #define MAC_STATIC // bk: FIXME
00198 
00199 #ifdef __i386__
00200 #define CPUSTRING   "linux-i386"
00201 #elif defined __axp__
00202 #define CPUSTRING   "linux-alpha"
00203 #else
00204 #define CPUSTRING   "linux-other"
00205 #endif
00206 
00207 #define PATH_SEP '/'
00208 
00209 // bk001205 - try
00210 #ifdef Q3_STATIC
00211 #define GAME_HARD_LINKED
00212 #define CGAME_HARD_LINKED
00213 #define UI_HARD_LINKED
00214 #define BOTLIB_HARD_LINKED
00215 #endif
00216 
00217 #endif
00218 
00219 //=============================================================
00220 
00221 
00222   
00223 typedef enum {qfalse, qtrue}    qboolean;
00224 
00225 typedef unsigned char       byte;
00226 
00227 #define EQUAL_EPSILON   0.001
00228 
00229 typedef int     qhandle_t;
00230 typedef int     sfxHandle_t;
00231 typedef int     fileHandle_t;
00232 typedef int     clipHandle_t;
00233 
00234 typedef enum {
00235     INVALID_JOINT = -1
00236 } jointHandle_t;
00237 
00238 #ifndef NULL
00239 #define NULL ((void *)0)
00240 #endif
00241 
00242 #define MAX_QINT            0x7fffffff
00243 #define MIN_QINT            (-MAX_QINT-1)
00244 
00245 #ifndef max
00246 #define max( x, y ) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )
00247 #define min( x, y ) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )
00248 #endif
00249 
00250 #ifndef sign
00251 #define sign( f )   ( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )
00252 #endif
00253 
00254 // angle indexes
00255 #define PITCH               0       // up / down
00256 #define YAW                 1       // left / right
00257 #define ROLL                2       // fall over
00258 
00259 // the game guarantees that no string from the network will ever
00260 // exceed MAX_STRING_CHARS
00261 #define MAX_STRING_CHARS    1024    // max length of a string passed to Cmd_TokenizeString
00262 #define MAX_STRING_TOKENS   256     // max tokens resulting from Cmd_TokenizeString
00263 #define MAX_TOKEN_CHARS     1024    // max length of an individual token
00264 
00265 #define MAX_INFO_STRING     1024
00266 #define MAX_INFO_KEY        1024
00267 #define MAX_INFO_VALUE      1024
00268 
00269 
00270 #define MAX_QPATH           64      // max length of a quake game pathname
00271 #define MAX_OSPATH          128     // max length of a filesystem pathname
00272 
00273 #define MAX_NAME_LENGTH     32      // max length of a client name
00274 
00275 // paramters for command buffer stuffing
00276 typedef enum {
00277     EXEC_NOW,           // don't return until completed, a VM should NEVER use this,
00278                         // because some commands might cause the VM to be unloaded...
00279     EXEC_INSERT,        // insert at current position, but don't run yet
00280     EXEC_APPEND         // add to end of the command buffer (normal case)
00281 } cbufExec_t;
00282 
00283 
00284 //
00285 // these aren't needed by any of the VMs.  put in another header?
00286 //
00287 #define MAX_MAP_AREA_BYTES      32      // bit vector of area visibility
00288 
00289 #undef ERR_FATAL                        // malloc.h on unix
00290 
00291 // parameters to the main Error routine
00292 typedef enum {
00293     ERR_NONE,
00294     ERR_FATAL,                  // exit the entire game with a popup window
00295     ERR_DROP,                   // print to console and disconnect from game
00296     ERR_DISCONNECT,             // don't kill server
00297     ERR_NEED_CD                 // pop up the need-cd dialog
00298 } errorParm_t;
00299 
00300 
00301 // font rendering values used by ui and cgame
00302 
00303 #define PROP_GAP_WIDTH          3
00304 #define PROP_SPACE_WIDTH        8
00305 #define PROP_HEIGHT             27
00306 #define PROP_SMALL_SIZE_SCALE   0.75
00307 
00308 #define BLINK_DIVISOR           200
00309 #define PULSE_DIVISOR           75
00310 
00311 #define UI_LEFT         0x00000000  // default
00312 #define UI_CENTER       0x00000001
00313 #define UI_RIGHT        0x00000002
00314 #define UI_FORMATMASK   0x00000007
00315 #define UI_SMALLFONT    0x00000010
00316 #define UI_BIGFONT      0x00000020  // default
00317 #define UI_GIANTFONT    0x00000040
00318 #define UI_DROPSHADOW   0x00000800
00319 #define UI_BLINK        0x00001000
00320 #define UI_INVERSE      0x00002000
00321 #define UI_PULSE        0x00004000
00322 
00323 
00324 /*
00325 ==============================================================
00326 
00327 MATHLIB
00328 
00329 ==============================================================
00330 */
00331 #ifdef __cplusplus          // so we can include this in C code
00332 #define SIDE_FRONT      0
00333 #define SIDE_BACK       1
00334 #define SIDE_ON         2
00335 #define SIDE_CROSS      3
00336 
00337 #define Q_PI    3.14159265358979323846
00338 #ifndef M_PI
00339 #define M_PI        3.14159265358979323846  // matches value in gcc v2 math.h
00340 #endif
00341 
00342 #include "math_vector.h"
00343 #include "math_angles.h"
00344 #include "math_matrix.h"
00345 #include "math_quaternion.h"
00346 
00347 class idVec3_t;                     // for defining vectors
00348 typedef idVec3_t &vec3_p;               // for passing vectors as function arguments
00349 typedef const idVec3_t &vec3_c;     // for passing vectors as const function arguments
00350                                     
00351 class angles_t;                     // for defining angle vectors
00352 typedef angles_t &angles_p;         // for passing angles as function arguments
00353 typedef const angles_t &angles_c;   // for passing angles as const function arguments
00354 
00355 class mat3_t;                       // for defining matrices
00356 typedef mat3_t &mat3_p;             // for passing matrices as function arguments
00357 typedef const mat3_t &mat3_c;       // for passing matrices as const function arguments
00358 
00359 
00360 
00361 #define NUMVERTEXNORMALS    162
00362 extern  idVec3_t    bytedirs[NUMVERTEXNORMALS];
00363 
00364 // all drawing is done to a 640*480 virtual screen size
00365 // and will be automatically scaled to the real resolution
00366 #define SCREEN_WIDTH        640
00367 #define SCREEN_HEIGHT       480
00368 
00369 #define TINYCHAR_WIDTH      (SMALLCHAR_WIDTH)
00370 #define TINYCHAR_HEIGHT     (SMALLCHAR_HEIGHT/2)
00371 
00372 #define SMALLCHAR_WIDTH     8
00373 #define SMALLCHAR_HEIGHT    16
00374 
00375 #define BIGCHAR_WIDTH       16
00376 #define BIGCHAR_HEIGHT      16
00377 
00378 #define GIANTCHAR_WIDTH     32
00379 #define GIANTCHAR_HEIGHT    48
00380 
00381 extern  vec4_t      colorBlack;
00382 extern  vec4_t      colorRed;
00383 extern  vec4_t      colorGreen;
00384 extern  vec4_t      colorBlue;
00385 extern  vec4_t      colorYellow;
00386 extern  vec4_t      colorMagenta;
00387 extern  vec4_t      colorCyan;
00388 extern  vec4_t      colorWhite;
00389 extern  vec4_t      colorLtGrey;
00390 extern  vec4_t      colorMdGrey;
00391 extern  vec4_t      colorDkGrey;
00392 
00393 #define Q_COLOR_ESCAPE  '^'
00394 #define Q_IsColorString(p)  ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && *((p)+1) != Q_COLOR_ESCAPE )
00395 
00396 #define COLOR_BLACK     '0'
00397 #define COLOR_RED       '1'
00398 #define COLOR_GREEN     '2'
00399 #define COLOR_YELLOW    '3'
00400 #define COLOR_BLUE      '4'
00401 #define COLOR_CYAN      '5'
00402 #define COLOR_MAGENTA   '6'
00403 #define COLOR_WHITE     '7'
00404 #define ColorIndex(c)   ( ( (c) - '0' ) & 7 )
00405 
00406 #define S_COLOR_BLACK   "^0"
00407 #define S_COLOR_RED     "^1"
00408 #define S_COLOR_GREEN   "^2"
00409 #define S_COLOR_YELLOW  "^3"
00410 #define S_COLOR_BLUE    "^4"
00411 #define S_COLOR_CYAN    "^5"
00412 #define S_COLOR_MAGENTA "^6"
00413 #define S_COLOR_WHITE   "^7"
00414 
00415 extern vec4_t   g_color_table[8];
00416 
00417 #define MAKERGB( v, r, g, b ) v[0]=r;v[1]=g;v[2]=b
00418 #define MAKERGBA( v, r, g, b, a ) v[0]=r;v[1]=g;v[2]=b;v[3]=a
00419 
00420 #define DEG2RAD( a ) ( ( (a) * M_PI ) / 180.0F )
00421 #define RAD2DEG( a ) ( ( (a) * 180.0f ) / M_PI )
00422 
00423 struct cplane_s;
00424 
00425 extern  idVec3_t    vec3_origin;
00426 extern  vec4_t  vec4_origin;
00427 extern  mat3_t  axisDefault;
00428 
00429 #define nanmask (255<<23)
00430 
00431 #define IS_NAN(x) (((*(int *)&x)&nanmask)==nanmask)
00432 
00433 float Q_fabs( float f );
00434 float Q_rsqrt( float f );       // reciprocal square root
00435 
00436 #define SQRTFAST( x ) ( 1.0f / Q_rsqrt( x ) )
00437 
00438 signed char ClampChar( int i );
00439 signed short ClampShort( int i );
00440 
00441 // this isn't a real cheap function to call!
00442 int DirToByte( const idVec3_t &dir );
00443 void ByteToDir( int b, vec3_p dir );
00444 
00445 #define DotProduct(a,b)         ((a)[0]*(b)[0]+(a)[1]*(b)[1]+(a)[2]*(b)[2])
00446 #define VectorSubtract(a,b,c)   ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
00447 #define VectorAdd(a,b,c)        ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
00448 #define VectorCopy(a,b)         ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
00449 //#define VectorCopy(a,b)           ((b).x=(a).x,(b).y=(a).y,(b).z=(a).z])
00450 
00451 #define VectorScale(v, s, o)    ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
00452 #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))
00453 #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])
00454 
00455 #define DotProduct4(x,y)        ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2]+(x)[3]*(y)[3])
00456 #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])
00457 #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])
00458 #define VectorCopy4(a,b)        ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
00459 #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))
00460 #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))
00461 
00462 
00463 #define VectorClear(a)          ((a)[0]=(a)[1]=(a)[2]=0)
00464 #define VectorNegate(a,b)       ((b)[0]=-(a)[0],(b)[1]=-(a)[1],(b)[2]=-(a)[2])
00465 #define VectorSet(v, x, y, z)   ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z))
00466 #define Vector4Copy(a,b)        ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3])
00467 
00468 #define SnapVector(v) {v[0]=(int)v[0];v[1]=(int)v[1];v[2]=(int)v[2];}
00469 
00470 float NormalizeColor( vec3_c in, vec3_p out );
00471 
00472 int VectorCompare( vec3_c v1, vec3_c v2 );
00473 float VectorLength( vec3_c v );
00474 float Distance( vec3_c p1, vec3_c p2 );
00475 float DistanceSquared( vec3_c p1, vec3_c p2 );
00476 float VectorNormalize (vec3_p v);       // returns vector length
00477 void VectorNormalizeFast(vec3_p v);     // does NOT return vector length, uses rsqrt approximation
00478 float VectorNormalize2( vec3_c v, vec3_p out );
00479 void VectorInverse (vec3_p v);
00480 void VectorRotate( vec3_c in, mat3_c matrix, vec3_p out );
00481 void VectorPolar(vec3_p v, float radius, float theta, float phi);
00482 void VectorSnap(vec3_p v);
00483 void Vector53Copy( const idVec5_t &in, vec3_p out);
00484 void Vector5Scale( const idVec5_t &v, float scale, idVec5_t &out);
00485 void Vector5Add( const idVec5_t &va, const idVec5_t &vb, idVec5_t &out);
00486 void VectorRotate3( vec3_c vIn, vec3_c vRotation, vec3_p out);
00487 void VectorRotate3Origin(vec3_c vIn, vec3_c vRotation, vec3_c vOrigin, vec3_p out);
00488 
00489 
00490 int Q_log2(int val);
00491 
00492 int     Q_rand( int *seed );
00493 float   Q_random( int *seed );
00494 float   Q_crandom( int *seed );
00495 
00496 #define random()    ((rand () & 0x7fff) / ((float)0x7fff))
00497 #define crandom()   (2.0 * (random() - 0.5))
00498 
00499 float Q_rint( float in );
00500 
00501 void vectoangles( vec3_c value1, angles_p angles);
00502 void AnglesToAxis( angles_c angles, mat3_p axis );
00503 
00504 void AxisCopy( mat3_c in, mat3_p out );
00505 qboolean AxisRotated( mat3_c in );          // assumes a non-degenerate axis
00506 
00507 int SignbitsForNormal( vec3_c normal );
00508 int BoxOnPlaneSide( const Bounds &b, struct cplane_s *p );
00509 
00510 float   AngleMod(float a);
00511 float   LerpAngle (float from, float to, float frac);
00512 float   AngleSubtract( float a1, float a2 );
00513 void    AnglesSubtract( angles_c v1, angles_c v2, angles_p v3 );
00514 
00515 float AngleNormalize360 ( float angle );
00516 float AngleNormalize180 ( float angle );
00517 float AngleDelta ( float angle1, float angle2 );
00518 
00519 qboolean PlaneFromPoints( vec4_t &plane, vec3_c a, vec3_c b, vec3_c c );
00520 void ProjectPointOnPlane( vec3_p dst, vec3_c p, vec3_c normal );
00521 void RotatePointAroundVector( vec3_p dst, vec3_c dir, vec3_c point, float degrees );
00522 void RotateAroundDirection( mat3_p axis, float yaw );
00523 void MakeNormalVectors( vec3_c forward, vec3_p right, vec3_p up );
00524 // perpendicular vector could be replaced by this
00525 
00526 int PlaneTypeForNormal( vec3_c normal );
00527 
00528 void MatrixMultiply( mat3_c in1, mat3_c in2, mat3_p out );
00529 void MatrixInverseMultiply( mat3_c in1, mat3_c in2, mat3_p out );   // in2 is transposed during multiply
00530 void MatrixTransformVector( vec3_c in, mat3_c matrix, vec3_p out );
00531 void MatrixProjectVector( vec3_c in, mat3_c matrix, vec3_p out ); // Places the vector into a new coordinate system.
00532 void AngleVectors( angles_c angles, vec3_p forward, vec3_p right, vec3_p up);
00533 void PerpendicularVector( vec3_p dst, vec3_c src );
00534 
00535 float TriangleArea( vec3_c a, vec3_c b, vec3_c c );
00536 #endif                                      // __cplusplus
00537 
00538 //=============================================
00539 
00540 float Com_Clamp( float min, float max, float value );
00541 
00542 #define FILE_HASH_SIZE      1024
00543 int Com_HashString( const char *fname );
00544 
00545 char    *Com_SkipPath( char *pathname );
00546 
00547 // it is ok for out == in
00548 void    Com_StripExtension( const char *in, char *out );
00549 
00550 // "extension" should include the dot: ".map"
00551 void    Com_DefaultExtension( char *path, int maxSize, const char *extension );
00552 
00553 int     Com_ParseInfos( const char *buf, int max, char infos[][MAX_INFO_STRING] );
00554 
00555 /*
00556 =====================================================================================
00557 
00558 SCRIPT PARSING
00559 
00560 =====================================================================================
00561 */
00562 
00563 // this just controls the comment printing, it doesn't actually load a file
00564 void Com_BeginParseSession( const char *filename );
00565 void Com_EndParseSession( void );
00566 
00567 int Com_GetCurrentParseLine( void );
00568 
00569 // Will never return NULL, just empty strings.
00570 // An empty string will only be returned at end of file.
00571 // ParseOnLine will return empty if there isn't another token on this line
00572 
00573 // this funny typedef just means a moving pointer into a const char * buffer
00574 const char *Com_Parse( const char *(*data_p) );
00575 const char *Com_ParseOnLine( const char *(*data_p) );
00576 const char *Com_ParseRestOfLine( const char *(*data_p) );
00577 
00578 void Com_UngetToken( void );
00579 
00580 #ifdef __cplusplus
00581 void Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning = qfalse );
00582 #else
00583 void Com_MatchToken( const char *(*buf_p), const char *match, qboolean warning );
00584 #endif
00585 
00586 void Com_ScriptError( const char *msg, ... );
00587 void Com_ScriptWarning( const char *msg, ... );
00588 
00589 void Com_SkipBracedSection( const char *(*program) );
00590 void Com_SkipRestOfLine( const char *(*data) );
00591 
00592 float Com_ParseFloat( const char *(*buf_p) );
00593 int Com_ParseInt( const char *(*buf_p) );
00594 
00595 void Com_Parse1DMatrix( const char *(*buf_p), int x, float *m );
00596 void Com_Parse2DMatrix( const char *(*buf_p), int y, int x, float *m );
00597 void Com_Parse3DMatrix( const char *(*buf_p), int z, int y, int x, float *m );
00598 
00599 //=====================================================================================
00600 #ifdef __cplusplus
00601     extern "C" {
00602 #endif
00603 
00604 void    QDECL Com_sprintf (char *dest, int size, const char *fmt, ...);
00605 
00606 
00607 // mode parm for FS_FOpenFile
00608 typedef enum {
00609     FS_READ,
00610     FS_WRITE,
00611     FS_APPEND,
00612     FS_APPEND_SYNC
00613 } fsMode_t;
00614 
00615 typedef enum {
00616     FS_SEEK_CUR,
00617     FS_SEEK_END,
00618     FS_SEEK_SET
00619 } fsOrigin_t;
00620 
00621 //=============================================
00622 
00623 int Q_isprint( int c );
00624 int Q_islower( int c );
00625 int Q_isupper( int c );
00626 int Q_isalpha( int c );
00627 
00628 // portable case insensitive compare
00629 int     Q_stricmp (const char *s1, const char *s2);
00630 int     Q_strncmp (const char *s1, const char *s2, int n);
00631 int     Q_stricmpn (const char *s1, const char *s2, int n);
00632 char    *Q_strlwr( char *s1 );
00633 char    *Q_strupr( char *s1 );
00634 char    *Q_strrchr( const char* string, int c );
00635 
00636 // buffer size safe library replacements
00637 void    Q_strncpyz( char *dest, const char *src, int destsize );
00638 void    Q_strcat( char *dest, int size, const char *src );
00639 
00640 // strlen that discounts Quake color sequences
00641 int Q_PrintStrlen( const char *string );
00642 // removes color sequences from string
00643 char *Q_CleanStr( char *string );
00644 
00645 int         Com_Filter( const char *filter, const char *name, int casesensitive );
00646 const char *Com_StringContains( const char *str1, const char *str2, int casesensitive );
00647 
00648 
00649 //=============================================
00650 
00651 short   BigShort(short l);
00652 short   LittleShort(short l);
00653 int     BigLong (int l);
00654 int     LittleLong (int l);
00655 float   BigFloat (float l);
00656 float   LittleFloat (float l);
00657 
00658 void    Swap_Init (void);
00659 char    * QDECL va(char *format, ...);
00660 
00661 #ifdef __cplusplus
00662     }
00663 #endif
00664 
00665 
00666 //=============================================
00667 #ifdef __cplusplus
00668 //
00669 // mapfile parsing
00670 //
00671 typedef struct ePair_s {
00672     char    *key;
00673     char    *value;
00674 } ePair_t;
00675 
00676 typedef struct mapSide_s {
00677     char        material[MAX_QPATH];
00678     vec4_t      plane;
00679     vec4_t      textureVectors[2];
00680 } mapSide_t;
00681 
00682 typedef struct {
00683     int         numSides;
00684     mapSide_t   **sides;
00685 } mapBrush_t;
00686 
00687 typedef struct {
00688     idVec3_t        xyz;
00689     float       st[2];
00690 } patchVertex_t;
00691 
00692 typedef struct {
00693     char        material[MAX_QPATH];
00694     int         width, height;
00695     patchVertex_t   *patchVerts;
00696 } mapPatch_t;
00697 
00698 typedef struct {
00699     char        modelName[MAX_QPATH];
00700     float       matrix[16];
00701 } mapModel_t;
00702 
00703 typedef struct mapPrimitive_s {
00704     int             numEpairs;
00705     ePair_t         **ePairs;
00706 
00707     // only one of these will be non-NULL
00708     mapBrush_t      *brush;
00709     mapPatch_t      *patch;
00710     mapModel_t      *model;
00711 } mapPrimitive_t;
00712 
00713 typedef struct mapEntity_s {
00714     int             numPrimitives;
00715     mapPrimitive_t  **primitives;
00716 
00717     int             numEpairs;
00718     ePair_t         **ePairs;
00719 } mapEntity_t;
00720 
00721 typedef struct {
00722     int             numEntities;
00723     mapEntity_t     **entities;
00724 } mapFile_t;
00725 
00726 
00727 // the order of entities, brushes, and sides will be maintained, the
00728 // lists won't be swapped on each load or save
00729 mapFile_t *ParseMapFile( const char *text );
00730 void FreeMapFile( mapFile_t *mapFile );
00731 void WriteMapFile( const mapFile_t *mapFile, FILE *f );
00732 
00733 // key names are case-insensitive
00734 const char  *ValueForMapEntityKey( const mapEntity_t *ent, const char *key );
00735 float   FloatForMapEntityKey( const mapEntity_t *ent, const char *key );
00736 qboolean    GetVectorForMapEntityKey( const mapEntity_t *ent, const char *key, idVec3_t &vec );
00737 
00738 typedef struct {
00739     idVec3_t        xyz;
00740     idVec2_t        st;
00741     idVec3_t        normal;
00742     idVec3_t        tangents[2];
00743     byte        smoothing[4];       // colors for silhouette smoothing
00744 } drawVert_t;
00745 
00746 typedef struct {
00747     int         width, height;
00748     drawVert_t  *verts;
00749 } drawVertMesh_t;
00750 
00751 // Tesselate a map patch into smoothed, drawable vertexes
00752 // MaxError of around 4 is reasonable
00753 drawVertMesh_t *SubdivideMapPatch( const mapPatch_t *patch, float maxError );
00754 #endif          // __cplusplus
00755 
00756 //=========================================
00757 
00758 #ifdef __cplusplus
00759     extern "C" {
00760 #endif
00761 
00762 void    QDECL Com_Error( int level, const char *error, ... );
00763 void    QDECL Com_Printf( const char *msg, ... );
00764 void    QDECL Com_DPrintf( const char *msg, ... );
00765 
00766 #ifdef __cplusplus
00767     }
00768 #endif
00769 
00770 
00771 typedef struct {
00772     qboolean    frameMemory;
00773     int     currentElements;
00774     int     maxElements;        // will reallocate and move when exceeded
00775     void    **elements;
00776 } growList_t;
00777 
00778 // you don't need to init the growlist if you don't mind it growing and moving
00779 // the list as it expands
00780 void        Com_InitGrowList( growList_t *list, int maxElements );
00781 int         Com_AddToGrowList( growList_t *list, void *data );
00782 void        *Com_GrowListElement( const growList_t *list, int index );
00783 int         Com_IndexForGrowListElement( const growList_t *list, const void *element );
00784 
00785 
00786 //
00787 // key / value info strings
00788 //
00789 char *Info_ValueForKey( const char *s, const char *key );
00790 void Info_RemoveKey( char *s, const char *key );
00791 void Info_SetValueForKey( char *s, const char *key, const char *value );
00792 qboolean Info_Validate( const char *s );
00793 void Info_NextPair( const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE] );
00794 
00795 // get cvar defs, collision defs, etc
00796 //#include "../shared/interface.h"
00797 
00798 // get key code numbers for events
00799 //#include "../shared/keycodes.h"
00800 
00801 #ifdef __cplusplus
00802 // get the polygon winding functions
00803 //#include "../shared/windings.h"
00804 
00805 // get the flags class
00806 //#include "../shared/idflags.h"
00807 #endif  // __cplusplus
00808 
00809 #endif  // __Q_SHARED_H
00810 

Generated on Thu Aug 25 12:37:34 2005 for Quake III Arena by  doxygen 1.3.9.1