#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
Include dependency graph for q_shared.hpp:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | growList_t |
Defines | |
| #define | ALIGN_OFF |
| #define | ALIGN_ON |
| #define | BLINK_DIVISOR 200 |
| #define | EQUAL_EPSILON 0.001 |
| #define | FILE_HASH_SIZE 1024 |
| #define | id386 0 |
| #define | max(x, y) ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) ) |
| #define | MAX_INFO_KEY 1024 |
| #define | MAX_INFO_STRING 1024 |
| #define | MAX_INFO_VALUE 1024 |
| #define | MAX_MAP_AREA_BYTES 32 |
| #define | MAX_NAME_LENGTH 32 |
| #define | MAX_OSPATH 128 |
| #define | MAX_QINT 0x7fffffff |
| #define | MAX_QPATH 64 |
| #define | MAX_STRING_CHARS 1024 |
| #define | MAX_STRING_TOKENS 256 |
| #define | MAX_TOKEN_CHARS 1024 |
| #define | min(x, y) ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) ) |
| #define | MIN_QINT (-MAX_QINT-1) |
| #define | NULL ((void *)0) |
| #define | PITCH 0 |
| #define | PROP_GAP_WIDTH 3 |
| #define | PROP_HEIGHT 27 |
| #define | PROP_SMALL_SIZE_SCALE 0.75 |
| #define | PROP_SPACE_WIDTH 8 |
| #define | PULSE_DIVISOR 75 |
| #define | QDECL |
| #define | ROLL 2 |
| #define | sign(f) ( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) ) |
| #define | UI_BIGFONT 0x00000020 |
| #define | UI_BLINK 0x00001000 |
| #define | UI_CENTER 0x00000001 |
| #define | UI_DROPSHADOW 0x00000800 |
| #define | UI_FORMATMASK 0x00000007 |
| #define | UI_GIANTFONT 0x00000040 |
| #define | UI_INVERSE 0x00002000 |
| #define | UI_LEFT 0x00000000 |
| #define | UI_PULSE 0x00004000 |
| #define | UI_RIGHT 0x00000002 |
| #define | UI_SMALLFONT 0x00000010 |
| #define | YAW 1 |
Typedefs | |
| typedef unsigned char | byte |
| typedef int | clipHandle_t |
| typedef int | fileHandle_t |
| typedef int | qhandle_t |
| typedef int | sfxHandle_t |
Enumerations | |
| enum | cbufExec_t { EXEC_NOW, EXEC_INSERT, EXEC_APPEND } |
| enum | errorParm_t { ERR_NONE, ERR_FATAL, ERR_DROP, ERR_DISCONNECT, ERR_NEED_CD } |
| enum | fsMode_t { FS_READ, FS_WRITE, FS_APPEND, FS_APPEND_SYNC } |
| enum | fsOrigin_t { FS_SEEK_CUR, FS_SEEK_END, FS_SEEK_SET } |
| enum | jointHandle_t { INVALID_JOINT = -1 } |
| enum | qboolean { qfalse, qtrue } |
Functions | |
| float | BigFloat (float l) |
| int | BigLong (int l) |
| short | BigShort (short l) |
| int | Com_AddToGrowList (growList_t *list, void *data) |
| void | Com_BeginParseSession (const char *filename) |
| float | Com_Clamp (float min, float max, float value) |
| void | Com_DefaultExtension (char *path, int maxSize, const char *extension) |
| void QDECL | Com_DPrintf (const char *msg,...) |
| void | Com_EndParseSession (void) |
| void QDECL | Com_Error (int level, const char *error,...) |
| int | Com_Filter (const char *filter, const char *name, int casesensitive) |
| int | Com_GetCurrentParseLine (void) |
| void * | Com_GrowListElement (const growList_t *list, int index) |
| int | Com_HashString (const char *fname) |
| int | Com_IndexForGrowListElement (const growList_t *list, const void *element) |
| void | Com_InitGrowList (growList_t *list, int maxElements) |
| void | Com_MatchToken (const char *(*buf_p), const char *match, qboolean warning) |
| const char * | Com_Parse (const char *(*data_p)) |
| void | Com_Parse1DMatrix (const char *(*buf_p), int x, float *m) |
| void | Com_Parse2DMatrix (const char *(*buf_p), int y, int x, float *m) |
| void | Com_Parse3DMatrix (const char *(*buf_p), int z, int y, int x, float *m) |
| float | Com_ParseFloat (const char *(*buf_p)) |
| int | Com_ParseInfos (const char *buf, int max, char infos[][MAX_INFO_STRING]) |
| int | Com_ParseInt (const char *(*buf_p)) |
| const char * | Com_ParseOnLine (const char *(*data_p)) |
| const char * | Com_ParseRestOfLine (const char *(*data_p)) |
| void QDECL | Com_Printf (const char *msg,...) |
| void | Com_ScriptError (const char *msg,...) |
| void | Com_ScriptWarning (const char *msg,...) |
| void | Com_SkipBracedSection (const char *(*program)) |
| char * | Com_SkipPath (char *pathname) |
| void | Com_SkipRestOfLine (const char *(*data)) |
| void QDECL | Com_sprintf (char *dest, int size, const char *fmt,...) |
| const char * | Com_StringContains (const char *str1, const char *str2, int casesensitive) |
| void | Com_StripExtension (const char *in, char *out) |
| void | Com_UngetToken (void) |
| void | Info_NextPair (const char *(*s), char key[MAX_INFO_KEY], char value[MAX_INFO_VALUE]) |
| void | Info_RemoveKey (char *s, const char *key) |
| void | Info_SetValueForKey (char *s, const char *key, const char *value) |
| qboolean | Info_Validate (const char *s) |
| char * | Info_ValueForKey (const char *s, const char *key) |
| float | LittleFloat (float l) |
| int | LittleLong (int l) |
| short | LittleShort (short l) |
| char * | Q_CleanStr (char *string) |
| int | Q_isalpha (int c) |
| int | Q_islower (int c) |
| int | Q_isprint (int c) |
| int | Q_isupper (int c) |
| int | Q_PrintStrlen (const char *string) |
| void | Q_strcat (char *dest, int size, const char *src) |
| int | Q_stricmp (const char *s1, const char *s2) |
| int | Q_stricmpn (const char *s1, const char *s2, int n) |
| char * | Q_strlwr (char *s1) |
| int | Q_strncmp (const char *s1, const char *s2, int n) |
| void | Q_strncpyz (char *dest, const char *src, int destsize) |
| char * | Q_strrchr (const char *string, int c) |
| char * | Q_strupr (char *s1) |
| void | Swap_Init (void) |
| char *QDECL | va (char *format,...) |
|
|
Definition at line 37 of file q_shared.hpp. |
|
|
Definition at line 36 of file q_shared.hpp. |
|
|
Definition at line 308 of file q_shared.hpp. |
|
|
Definition at line 227 of file q_shared.hpp. |
|
|
Definition at line 542 of file q_shared.hpp. |
|
|
Definition at line 83 of file q_shared.hpp. |
|
|
Definition at line 246 of file q_shared.hpp. |
|
|
Definition at line 266 of file q_shared.hpp. |
|
|
Definition at line 265 of file q_shared.hpp. |
|
|
Definition at line 267 of file q_shared.hpp. |
|
|
Definition at line 287 of file q_shared.hpp. |
|
|
Definition at line 273 of file q_shared.hpp. |
|
|
Definition at line 271 of file q_shared.hpp. |
|
|
Definition at line 242 of file q_shared.hpp. |
|
|
Definition at line 270 of file q_shared.hpp. |
|
|
Definition at line 261 of file q_shared.hpp. |
|
|
Definition at line 262 of file q_shared.hpp. |
|
|
Definition at line 263 of file q_shared.hpp. |
|
|
Definition at line 247 of file q_shared.hpp. |
|
|
Definition at line 243 of file q_shared.hpp. |
|
|
Definition at line 239 of file q_shared.hpp. |
|
|
Definition at line 255 of file q_shared.hpp. |
|
|
Definition at line 303 of file q_shared.hpp. |
|
|
Definition at line 305 of file q_shared.hpp. |
|
|
Definition at line 306 of file q_shared.hpp. |
|
|
Definition at line 304 of file q_shared.hpp. |
|
|
Definition at line 309 of file q_shared.hpp. |
|
|
Definition at line 88 of file q_shared.hpp. |
|
|
Definition at line 257 of file q_shared.hpp. |
|
|
Definition at line 251 of file q_shared.hpp. |
|
|
Definition at line 316 of file q_shared.hpp. |
|
|
Definition at line 319 of file q_shared.hpp. |
|
|
Definition at line 312 of file q_shared.hpp. |
|
|
Definition at line 318 of file q_shared.hpp. |
|
|
Definition at line 314 of file q_shared.hpp. |
|
|
Definition at line 317 of file q_shared.hpp. |
|
|
Definition at line 320 of file q_shared.hpp. |
|
|
Definition at line 311 of file q_shared.hpp. |
|
|
Definition at line 321 of file q_shared.hpp. |
|
|
Definition at line 313 of file q_shared.hpp. |
|
|
Definition at line 315 of file q_shared.hpp. |
|
|
Definition at line 256 of file q_shared.hpp. |
|
|
Definition at line 225 of file q_shared.hpp. |
|
|
Definition at line 232 of file q_shared.hpp. |
|
|
Definition at line 231 of file q_shared.hpp. |
|
|
Definition at line 229 of file q_shared.hpp. |
|
|
Definition at line 230 of file q_shared.hpp. |
|
|
Definition at line 276 of file q_shared.hpp. 00276 {
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;
|
|
|
Definition at line 292 of file q_shared.hpp. 00292 {
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;
|
|
|
Definition at line 608 of file q_shared.hpp. 00608 {
00609 FS_READ,
00610 FS_WRITE,
00611 FS_APPEND,
00612 FS_APPEND_SYNC
00613 } fsMode_t;
|
|
|
Definition at line 615 of file q_shared.hpp. 00615 {
00616 FS_SEEK_CUR,
00617 FS_SEEK_END,
00618 FS_SEEK_SET
00619 } fsOrigin_t;
|
|
|
Definition at line 234 of file q_shared.hpp. 00234 {
00235 INVALID_JOINT = -1
00236 } jointHandle_t;
|
|
|
Definition at line 223 of file q_shared.hpp. 00223 {qfalse, qtrue} qboolean;
|
|
|
Definition at line 1052 of file l_cmd.c. 01053 {
01054 union {byte b[4]; float f;} in, out;
01055
01056 in.f = l;
01057 out.b[0] = in.b[3];
01058 out.b[1] = in.b[2];
01059 out.b[2] = in.b[1];
01060 out.b[3] = in.b[0];
01061
01062 return out.f;
01063 }
|
|
|
Definition at line 1035 of file l_cmd.c. 01036 {
01037 byte b1,b2,b3,b4;
01038
01039 b1 = l&255;
01040 b2 = (l>>8)&255;
01041 b3 = (l>>16)&255;
01042 b4 = (l>>24)&255;
01043
01044 return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
01045 }
|
|
|
Definition at line 1019 of file l_cmd.c. 01020 {
01021 byte b1,b2;
01022
01023 b1 = l&255;
01024 b2 = (l>>8)&255;
01025
01026 return (b1<<8) + b2;
01027 }
|
|
||||||||||||
|
Definition at line 43 of file q_shared.cpp. 00043 {
00044 void **old;
00045
00046 if ( list->currentElements != list->maxElements ) {
00047 list->elements[list->currentElements] = data;
00048 return list->currentElements++;
00049 }
00050
00051 // grow, reallocate and move
00052 old = list->elements;
00053
00054 if ( list->maxElements < 0 ) {
00055 Com_Error( ERR_FATAL, "Com_AddToGrowList: maxElements = %i", list->maxElements );
00056 }
00057
00058 if ( list->maxElements == 0 ) {
00059 // initialize the list to hold 100 elements
00060 Com_InitGrowList( list, 100 );
00061 return Com_AddToGrowList( list, data );
00062 }
00063
00064 list->maxElements *= 2;
00065
00066 Com_DPrintf( "Resizing growlist to %i maxElements\n", list->maxElements );
00067
00068 list->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );
00069
00070 if ( !list->elements ) {
00071 Com_Error( ERR_DROP, "Growlist alloc failed" );
00072 }
00073
00074 memcpy( list->elements, old, list->currentElements * sizeof( void * ) );
00075
00076 Com_Dealloc( old );
00077
00078 return Com_AddToGrowList( list, data );
00079 }
|
|
|
Definition at line 58 of file q_parse.cpp. 00058 {
00059 if ( parseInfoNum == MAX_PARSE_INFO - 1 ) {
00060 Com_Error( ERR_FATAL, "Com_BeginParseSession: session overflow" );
00061 }
00062 parseInfoNum++;
00063 pi = &parseInfo[parseInfoNum];
00064
00065 pi->lines = 1;
00066 Q_strncpyz( pi->parseFile, filename, sizeof( pi->parseFile ) );
00067 }
|
|
||||||||||||||||
|
Definition at line 26 of file q_shared.c. 00026 {
00027 if ( value < min ) {
00028 return min;
00029 }
00030 if ( value > max ) {
00031 return max;
00032 }
00033 return value;
00034 }
|
|
||||||||||||||||
|
Definition at line 285 of file q_shared.cpp. 00285 {
00286 char oldPath[MAX_QPATH];
00287 char *src;
00288
00289 //
00290 // if path doesn't have a .EXT, append extension
00291 // (extension should include the .)
00292 //
00293 src = path + strlen(path) - 1;
00294
00295 while (*src != '/' && src != path) {
00296 if ( *src == '.' ) {
00297 return; // it has an extension
00298 }
00299 src--;
00300 }
00301
00302 Q_strncpyz( oldPath, path, sizeof( oldPath ) );
00303 Com_sprintf( path, maxSize, "%s%s", oldPath, extension );
00304 }
|
|
||||||||||||
|
Definition at line 209 of file common.c. 00209 {
00210 va_list argptr;
00211 char msg[MAXPRINTMSG];
00212
00213 if ( !com_developer || !com_developer->integer ) {
00214 return; // don't confuse non-developers with techie stuff...
00215 }
00216
00217 va_start (argptr,fmt);
00218 Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
00219 va_end (argptr);
00220
00221 Com_Printf ("%s", msg);
00222 }
|
|
|
Definition at line 74 of file q_parse.cpp. 00074 {
00075 if ( parseInfoNum == 0 ) {
00076 Com_Error( ERR_FATAL, "Com_EndParseSession: session underflow" );
00077 }
00078 parseInfoNum--;
00079 pi = &parseInfo[parseInfoNum];
00080 }
|
|
||||||||||||||||
|
Definition at line 444 of file cg_main.c. 00444 {
00445 va_list argptr;
00446 char text[1024];
00447
00448 va_start (argptr, error);
00449 vsprintf (text, error, argptr);
00450 va_end (argptr);
00451
00452 CG_Error( "%s", text);
00453 }
|
|
||||||||||||||||
|
Definition at line 147 of file q_shared.cpp. 00148 {
00149 char buf[MAX_TOKEN_CHARS];
00150 const char *ptr;
00151 int i, found;
00152
00153 while(*filter) {
00154 if (*filter == '*') {
00155 filter++;
00156 for (i = 0; *filter; i++) {
00157 if (*filter == '*' || *filter == '?') break;
00158 buf[i] = *filter;
00159 filter++;
00160 }
00161 buf[i] = '\0';
00162 if (strlen(buf)) {
00163 ptr = Com_StringContains(name, buf, casesensitive);
00164 if (!ptr) return qfalse;
00165 name = ptr + strlen(buf);
00166 }
00167 }
00168 else if (*filter == '?') {
00169 filter++;
00170 name++;
00171 }
00172 else if (*filter == '[' && *(filter+1) == '[') {
00173 filter++;
00174 }
00175 else if (*filter == '[') {
00176 filter++;
00177 found = qfalse;
00178 while(*filter && !found) {
00179 if (*filter == ']' && *(filter+1) != ']') break;
00180 if (*(filter+1) == '-' && *(filter+2) && (*(filter+2) != ']' || *(filter+3) == ']')) {
00181 if (casesensitive) {
00182 if (*name >= *filter && *name <= *(filter+2)) found = qtrue;
00183 }
00184 else {
00185 if (toupper(*name) >= toupper(*filter) &&
00186 toupper(*name) <= toupper(*(filter+2))) found = qtrue;
00187 }
00188 filter += 3;
00189 }
00190 else {
00191 if (casesensitive) {
00192 if (*filter == *name) found = qtrue;
00193 }
00194 else {
00195 if (toupper(*filter) == toupper(*name)) found = qtrue;
00196 }
00197 filter++;
00198 }
00199 }
00200 if (!found) return qfalse;
00201 while(*filter) {
00202 if (*filter == ']' && *(filter+1) != ']') break;
00203 filter++;
00204 }
00205 filter++;
00206 name++;
00207 }
00208 else {
00209 if (casesensitive) {
00210 if (*filter != *name) return qfalse;
00211 }
00212 else {
00213 if (toupper(*filter) != toupper(*name)) return qfalse;
00214 }
00215 filter++;
00216 name++;
00217 }
00218 }
00219 return qtrue;
00220 }
|
|
|
Definition at line 87 of file q_parse.cpp.
|
|
||||||||||||
|
Definition at line 81 of file q_shared.cpp. 00081 {
00082 if ( index < 0 || index >= list->currentElements ) {
00083 Com_Error( ERR_DROP, "Com_GrowListElement: %i out of range of %i",
00084 index, list->currentElements );
00085 }
00086 return list->elements[index];
00087 }
|
|
|
Definition at line 229 of file q_shared.cpp. 00229 {
00230 int i;
00231 long hash;
00232 char letter;
00233
00234 hash = 0;
00235 i = 0;
00236 while (fname[i] != '\0') {
00237 letter = tolower(fname[i]);
00238 if (letter =='.') break; // don't include extension
00239 if (letter =='\\') letter = '/'; // damn path names
00240 hash+=(long)(letter)*(i+119);
00241 i++;
00242 }
00243 hash &= (FILE_HASH_SIZE-1);
00244 return hash;
00245 }
|
|
||||||||||||
|
Definition at line 89 of file q_shared.cpp. 00089 {
00090 int i;
00091
00092 for ( i = 0 ; i < list->currentElements ; i++ ) {
00093 if ( list->elements[i] == element ) {
00094 return i;
00095 }
00096 }
00097 return -1;
00098 }
|
|
||||||||||||
|
Definition at line 37 of file q_shared.cpp. 00037 {
00038 list->maxElements = maxElements;
00039 list->currentElements = 0;
00040 list->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );
00041 }
|
|
||||||||||||||||
|
Definition at line 390 of file q_parse.cpp. 00390 {
00391 const char *token;
00392
00393 token = Com_Parse( buf_p );
00394 if ( strcmp( token, match ) ) {
00395 if (warning) {
00396 Com_ScriptWarning( "MatchToken: %s != %s", token, match );
00397 } else {
00398 Com_ScriptError( "MatchToken: %s != %s", token, match );
00399 }
00400 }
00401 }
|
|
|
Definition at line 362 of file q_parse.cpp. 00362 {
00363 if ( pi->ungetToken ) {
00364 pi->ungetToken = qfalse;
00365 return pi->token;
00366 }
00367 return Com_ParseExt( data_p, qtrue );
00368 }
|
|
||||||||||||||||
|
Definition at line 498 of file q_parse.cpp. 00498 {
00499 const char *token;
00500 int i;
00501
00502 Com_MatchToken( buf_p, "(" );
00503
00504 for (i = 0 ; i < x ; i++) {
00505 token = Com_Parse(buf_p);
00506 m[i] = atof(token);
00507 }
00508
00509 Com_MatchToken( buf_p, ")" );
00510 }
|
|
||||||||||||||||||||
|
Definition at line 512 of file q_parse.cpp. 00512 {
00513 int i;
00514
00515 Com_MatchToken( buf_p, "(" );
00516
00517 for (i = 0 ; i < y ; i++) {
00518 Com_Parse1DMatrix (buf_p, x, m + i * x);
00519 }
00520
00521 Com_MatchToken( buf_p, ")" );
00522 }
|
|
||||||||||||||||||||||||
|
Definition at line 524 of file q_parse.cpp. 00524 {
00525 int i;
00526
00527 Com_MatchToken( buf_p, "(" );
00528
00529 for (i = 0 ; i < z ; i++) {
00530 Com_Parse2DMatrix (buf_p, y, x, m + i * x*y);
00531 }
00532
00533 Com_MatchToken( buf_p, ")" );
00534 }
|
|
|
Definition at line 476 of file q_parse.cpp. 00476 {
00477 const char *token;
00478
00479 token = Com_Parse( buf_p );
00480 if ( !token[0] ) {
00481 return 0;
00482 }
00483 return atof( token );
00484 }
|
|
||||||||||||||||
|
Definition at line 420 of file q_shared.cpp. |