codemp/game/q_shared.c File Reference

#include "q_shared.h"

Go to the source code of this file.

Data Structures

union  _FloatByteUnion

Functions

int GetIDForString (stringID_table_t *table, const char *string)
const char * GetStringForID (stringID_table_t *table, int id)
int Com_Clampi (int min, int max, int value)
float Com_Clamp (float min, float max, float value)
char * COM_SkipPath (char *pathname)
void COM_StripExtension (const char *in, char *out)
void COM_DefaultExtension (char *path, int maxSize, const char *extension)
short ShortSwap (short l)
short ShortNoSwap (short l)
int LongSwap (int l)
int LongNoSwap (int l)
qint64 Long64Swap (qint64 ll)
qint64 Long64NoSwap (qint64 ll)
float FloatSwap (const float *f)
float FloatNoSwap (const float *f)
void COM_BeginParseSession (const char *name)
int COM_GetCurrentParseLine (void)
char * COM_Parse (const char **data_p)
void COM_ParseError (char *format,...)
void COM_ParseWarning (char *format,...)
const char * SkipWhitespace (const char *data, qboolean *hasNewLines)
int COM_Compress (char *data_p)
char * COM_ParseExt (const char **data_p, qboolean allowLineBreaks)
qboolean COM_ParseString (const char **data, const char **s)
qboolean COM_ParseInt (const char **data, int *i)
qboolean COM_ParseFloat (const char **data, float *f)
qboolean COM_ParseVec4 (const char **buffer, vec4_t *c)
void COM_MatchToken (const char **buf_p, char *match)
void SkipBracedSection (const char **program)
void SkipRestOfLine (const char **data)
void Parse1DMatrix (const char **buf_p, int x, float *m)
void Parse2DMatrix (const char **buf_p, int y, int x, float *m)
void Parse3DMatrix (const char **buf_p, int z, int y, int x, float *m)
int Q_isprint (int c)
int Q_islower (int c)
int Q_isupper (int c)
int Q_isalpha (int c)
char * Q_strrchr (const char *string, int c)
void Q_strncpyz (char *dest, const char *src, int destsize)
int Q_stricmpn (const char *s1, const char *s2, int n)
int Q_strncmp (const char *s1, const char *s2, int n)
int Q_stricmp (const char *s1, const char *s2)
char * Q_strlwr (char *s1)
char * Q_strupr (char *s1)
void Q_strcat (char *dest, int size, const char *src)
int Q_PrintStrlen (const char *string)
char * Q_CleanStr (char *string)
void QDECL Com_sprintf (char *dest, int size, const char *fmt,...)
char *QDECL va (const char *format,...)
char * Info_ValueForKey (const char *s, const char *key)
void Info_NextPair (const char **head, char *key, char *value)
void Info_RemoveKey (char *s, const char *key)
void Info_RemoveKey_Big (char *s, const char *key)
qboolean Info_Validate (const char *s)
void Info_SetValueForKey (char *s, const char *key, const char *value)
void Info_SetValueForKey_Big (char *s, const char *key, const char *value)


Function Documentation

void COM_BeginParseSession const char *  name  ) 
 

Definition at line 284 of file q_shared.c.

References Com_sprintf(), and name.

Referenced by NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), UI_SaberGetHiltInfo(), UI_SaberParseParm(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), WP_SaberParseParm(), and WP_SaberParseParms().

00285 {
00286         com_lines = 0;
00287         Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
00288 }

float Com_Clamp float  min,
float  max,
float  value
 

Definition at line 64 of file q_shared.c.

References min.

00064                                                      {
00065         if ( value < min ) {
00066                 return min;
00067         }
00068         if ( value > max ) {
00069                 return max;
00070         }
00071         return value;
00072 }

int Com_Clampi int  min,
int  max,
int  value
 

Definition at line 51 of file q_shared.c.

References min.

00052 {
00053         if ( value < min ) 
00054         {
00055                 return min;
00056         }
00057         if ( value > max ) 
00058         {
00059                 return max;
00060         }
00061         return value;
00062 }

int COM_Compress char *  data_p  ) 
 

Definition at line 353 of file q_shared.c.

References qboolean, qfalse, and qtrue.

Referenced by NPC_LoadParms(), UI_SaberLoadParms(), and WP_SaberLoadParms().

00353                                  {
00354         char *in, *out;
00355         int c;
00356         qboolean newline = qfalse, whitespace = qfalse;
00357         
00358         in = out = data_p;
00359         if (in) {
00360                 while ((c = *in) != 0) {
00361                         // skip double slash comments
00362                         if ( c == '/' && in[1] == '/' ) {
00363                                 while (*in && *in != '\n') {
00364                                         in++;
00365                                 }
00366                                 // skip /* */ comments
00367                         } else if ( c == '/' && in[1] == '*' ) {
00368                                 while ( *in && ( *in != '*' || in[1] != '/' ) ) 
00369                                         in++;
00370                                 if ( *in ) 
00371                                         in += 2;
00372                                 // record when we hit a newline
00373                         } else if ( c == '\n' || c == '\r' ) {
00374                                 newline = qtrue;
00375                                 in++;
00376                                 // record when we hit whitespace
00377                         } else if ( c == ' ' || c == '\t') {
00378                                 whitespace = qtrue;
00379                                 in++;
00380                                 // an actual token
00381                         } else {
00382                                 // if we have a pending newline, emit it (and it counts as whitespace)
00383                                 if (newline) {
00384                                         *out++ = '\n';
00385                                         newline = qfalse;
00386                                         whitespace = qfalse;
00387                                 } if (whitespace) {
00388                                         *out++ = ' ';
00389                                         whitespace = qfalse;
00390                                 }
00391                                 
00392                                 // copy quoted strings unmolested
00393                                 if (c == '"') {
00394                                         *out++ = c;
00395                                         in++;
00396                                         while (1) {
00397                                                 c = *in;
00398                                                 if (c && c != '"') {
00399                                                         *out++ = c;
00400                                                         in++;
00401                                                 } else {
00402                                                         break;
00403                                                 }
00404                                         }
00405                                         if (c == '"') {
00406                                                 *out++ = c;
00407                                                 in++;
00408                                         }
00409                                 } else {
00410                                         *out = c;
00411                                         out++;
00412                                         in++;
00413                                 }
00414                         }
00415                 }
00416         }
00417         *out = 0;
00418         return out - data_p;
00419 }

void COM_DefaultExtension char *  path,
int  maxSize,
const char *  extension
 

Definition at line 112 of file q_shared.c.

References Com_sprintf(), MAX_QPATH, Q_strncpyz(), and strlen().

00112                                                                             {
00113         char    oldPath[MAX_QPATH];
00114         char    *src;
00115 
00116 //
00117 // if path doesn't have a .EXT, append extension
00118 // (extension should include the .)
00119 //
00120         src = path + strlen(path) - 1;
00121 
00122         while (*src != '/' && src != path) {
00123                 if ( *src == '.' ) {
00124                         return;                 // it has an extension
00125                 }
00126                 src--;
00127         }
00128 
00129         Q_strncpyz( oldPath, path, sizeof( oldPath ) );
00130         Com_sprintf( path, maxSize, "%s%s", oldPath, extension );
00131 }

int COM_GetCurrentParseLine void   ) 
 

Definition at line 290 of file q_shared.c.

00291 {
00292         return com_lines;
00293 }

void COM_MatchToken const char **  buf_p,
char *  match
 

Definition at line 666 of file q_shared.c.

References Com_Error(), COM_Parse(), ERR_DROP, and strcmp().

Referenced by Parse1DMatrix(), Parse2DMatrix(), and Parse3DMatrix().

00666                                                        {
00667         char    *token;
00668 
00669         token = COM_Parse( buf_p );
00670         if ( strcmp( token, match ) ) {
00671                 Com_Error( ERR_DROP, "MatchToken: %s != %s", token, match );
00672         }
00673 }

char* COM_Parse const char **  data_p  ) 
 

Definition at line 295 of file q_shared.c.

References COM_ParseExt(), and qtrue.

Referenced by BG_ParseAnimationEvtFile(), BG_ParseAnimationFile(), CG_NewParticleArea(), CG_StartMusic(), COM_MatchToken(), G_ParseInfos(), Parse1DMatrix(), ParseAnimationEvtBlock(), UI_ParseAnimationFile(), and UI_ParseInfos().

00296 {
00297         return COM_ParseExt( data_p, qtrue );
00298 }

void COM_ParseError char *  format,
... 
 

Definition at line 300 of file q_shared.c.

References Com_Printf(), va_end, va_list, va_start, and vsprintf().

00301 {
00302         va_list argptr;
00303         static char string[4096];
00304 
00305         va_start (argptr, format);
00306         vsprintf (string, format, argptr);
00307         va_end (argptr);
00308 
00309         Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string);
00310 }

char* COM_ParseExt const char **  data_p,
qboolean  allowLineBreaks
 

Definition at line 421 of file q_shared.c.

References MAX_TOKEN_CHARS, NULL, qboolean, qfalse, and SkipWhitespace().

Referenced by Asset_Parse(), BG_ParseAnimationFile(), BG_ParseLiteral(), CG_DrawSkyBoxPortal(), CG_Load_Menu(), CG_LoadMenus(), CG_ParseSurfsFile(), COM_Parse(), COM_ParseFloat(), COM_ParseInt(), COM_ParseString(), Float_Parse(), G_ParseInfos(), Int_Parse(), NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), ParseAnimationEvtBlock(), SkipBracedSection(), String_Parse(), UI_ParseInfos(), UI_ParseLiteral(), UI_ParseLiteralSilent(), UI_SaberGetHiltInfo(), UI_SaberParseParm(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), WP_SaberParseParm(), and WP_SaberParseParms().

00422 {
00423         int c = 0, len;
00424         qboolean hasNewLines = qfalse;
00425         const char *data;
00426 
00427         data = *data_p;
00428         len = 0;
00429         com_token[0] = 0;
00430 
00431         // make sure incoming data is valid
00432         if ( !data )
00433         {
00434                 *data_p = NULL;
00435                 return com_token;
00436         }
00437 
00438         while ( 1 )
00439         {
00440                 // skip whitespace
00441                 data = SkipWhitespace( data, &hasNewLines );
00442                 if ( !data )
00443                 {
00444                         *data_p = NULL;
00445                         return com_token;
00446                 }
00447                 if ( hasNewLines && !allowLineBreaks )
00448                 {
00449                         *data_p = data;
00450                         return com_token;
00451                 }
00452 
00453                 c = *data;
00454 
00455                 // skip double slash comments
00456                 if ( c == '/' && data[1] == '/' )
00457                 {
00458                         data += 2;
00459                         while (*data && *data != '\n') {
00460                                 data++;
00461                         }
00462                 }
00463                 // skip /* */ comments
00464                 else if ( c=='/' && data[1] == '*' ) 
00465                 {
00466                         data += 2;
00467                         while ( *data && ( *data != '*' || data[1] != '/' ) ) 
00468                         {
00469                                 data++;
00470                         }
00471                         if ( *data ) 
00472                         {
00473                                 data += 2;
00474                         }
00475                 }
00476                 else
00477                 {
00478                         break;
00479                 }
00480         }
00481 
00482         // handle quoted strings
00483         if (c == '\"')
00484         {
00485                 data++;
00486                 while (1)
00487                 {
00488                         c = *data++;
00489                         if (c=='\"' || !c)
00490                         {
00491                                 com_token[len] = 0;
00492                                 *data_p = ( char * ) data;
00493                                 return com_token;
00494                         }
00495                         if (len < MAX_TOKEN_CHARS)
00496                         {
00497                                 com_token[len] = c;
00498                                 len++;
00499                         }
00500                 }
00501         }
00502 
00503         // parse a regular word
00504         do
00505         {
00506                 if (len < MAX_TOKEN_CHARS)
00507                 {
00508                         com_token[len] = c;
00509                         len++;
00510                 }
00511                 data++;
00512                 c = *data;
00513                 if ( c == '\n' )
00514                         com_lines++;
00515         } while (c>32);
00516 
00517         if (len == MAX_TOKEN_CHARS)
00518         {
00519 //              Com_Printf ("Token exceeded %i chars, discarded.\n", MAX_TOKEN_CHARS);
00520                 len = 0;
00521         }
00522         com_token[len] = 0;
00523 
00524         *data_p = ( char * ) data;
00525         return com_token;
00526 }

qboolean COM_ParseFloat const char **  data,
float *  f
 

Definition at line 625 of file q_shared.c.

References atof(), COM_ParseExt(), Com_Printf(), qboolean, qfalse, and qtrue.

Referenced by COM_ParseVec4(), NPC_ParseParms(), ParseRect(), Script_Transition2(), and WP_SaberParseParms().

00626 {
00627         const char      *token;
00628 
00629         token = COM_ParseExt( data, qfalse );
00630         if ( token[0] == 0 ) 
00631         {
00632                 Com_Printf( "unexpected EOF\n" );
00633                 return qtrue;
00634         }
00635 
00636         *f = atof( token );
00637         return qfalse;
00638 }

qboolean COM_ParseInt const char **  data,
int *  i
 

Definition at line 605 of file q_shared.c.

References atoi(), COM_ParseExt(), Com_Printf(), qboolean, qfalse, and qtrue.

Referenced by NPC_ParseParms(), and WP_SaberParseParms().

00606 {
00607         const char      *token;
00608 
00609         token = COM_ParseExt( data, qfalse );
00610         if ( token[0] == 0 ) 
00611         {
00612                 Com_Printf( "unexpected EOF\n" );
00613                 return qtrue;
00614         }
00615 
00616         *i = atoi( token );
00617         return qfalse;
00618 }

qboolean COM_ParseString const char **  data,
const char **  s
 

Definition at line 588 of file q_shared.c.

References COM_ParseExt(), Com_Printf(), qboolean, qfalse, and qtrue.

Referenced by CG_ParseSurfsFile(), NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), UI_SaberParseParm(), WP_SaberParseParm(), and WP_SaberParseParms().

00589 {
00590 //      *s = COM_ParseExt( data, qtrue );
00591         *s = COM_ParseExt( data, qfalse );
00592         if ( s[0] == 0 ) 
00593         {
00594                 Com_Printf("unexpected EOF\n");
00595                 return qtrue;
00596         }
00597         return qfalse;
00598 }

qboolean COM_ParseVec4 const char **  buffer,
vec4_t c
 

Definition at line 645 of file q_shared.c.

References COM_ParseFloat(), qboolean, qfalse, qtrue, and vec4_t.

00646 {
00647         int i;
00648         float f;
00649 
00650         for (i = 0; i < 4; i++) 
00651         {
00652                 if (COM_ParseFloat(buffer, &f)) 
00653                 {
00654                         return qtrue;
00655                 }
00656                 (*c)[i] = f;
00657         }
00658         return qfalse;
00659 }

void COM_ParseWarning char *  format,
... 
 

Definition at line 312 of file q_shared.c.

References Com_Printf(), va_end, va_list, va_start, and vsprintf().

00313 {
00314         va_list argptr;
00315         static char string[4096];
00316 
00317         va_start (argptr, format);
00318         vsprintf (string, format, argptr);
00319         va_end (argptr);
00320 
00321         Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string);
00322 }

char* COM_SkipPath char *  pathname  ) 
 

Definition at line 80 of file q_shared.c.

00081 {
00082         char    *last;
00083         
00084         last = pathname;
00085         while (*pathname)
00086         {
00087                 if (*pathname=='/')
00088                         last = pathname+1;
00089                 pathname++;
00090         }
00091         return last;
00092 }

void QDECL Com_sprintf char *  dest,
int  size,
const char *  fmt,
... 
 

Definition at line 985 of file q_shared.c.

References Com_Error(), Com_Printf(), ERR_FATAL, Q_strncpyz(), QDECL, va_end, va_list, va_start, and vsprintf().

Referenced by BG_GetRootSurfNameWithVariant(), BG_ParseAnimationEvtFile(), BotUtilizePersonality(), BuildShaderStateConfig(), CalculateAwards(), CG_DrawHUD(), CG_DrawNumField(), CG_G2AnimEntModelLoad(), CG_GlassShatter_Old(), CG_InitSiegeMode(), CG_LoadCISounds(), CG_ParseServerinfo(), CG_ParseSurfsFile(), CG_PlaceString(), CG_PrecacheSiegeObjectiveAssetsForTeam(), CG_PrintCTFMessage(), CG_ROFF_NotetrackCallback(), CG_SE_UpdateMusic(), CG_SiegeBriefingDisplay(), CG_SiegeGetObjectiveDescription(), CG_SiegeGetObjectiveFinal(), CG_SiegeObjectiveCompleted(), CG_SiegeRoundOver(), Cmd_CallTeamVote_f(), Cmd_CallVote_f(), COM_BeginParseSession(), COM_DefaultExtension(), DeathmatchScoreboardMessage(), decompTriggerUse(), G_Dismember(), G_GetStringEdString(), G_ItemDisabled(), G_LogPrintf(), G_LogWeaponOutput(), G_RemapTeamShaders(), G_Say(), G_SendG2KillQueue(), G_SiegeClientExData(), Info_SetValueForKey(), Info_SetValueForKey_Big(), InitSiegeMode(), Item_Model_Paint(), ItemParse_asset_model(), LoadPathData(), NAV_WaypointsTooFar(), NPC_ParseParms(), NPC_Precache(), Q3_SetParm(), SavePathData(), SetupGameGhoul2Model(), SiegeRoundComplete(), siegeTriggerUse(), SP_misc_bsp(), SP_worldspawn(), Team_GetLocationMsg(), TeamplayInfoMessage(), UI_FeederSelection(), UI_hasSkinForBase(), UI_LoadBestScores(), UI_LoadForceConfig_List(), UI_ReadLegalForce(), UI_SaveForceTemplate(), UI_SetSiegeTeams(), UI_UpdateCharacterSkin(), UpdateTournamentInfo(), vtos(), and WP_InitForcePowers().

00985                                                                     {
00986         int             len;
00987         va_list         argptr;
00988         char    bigbuffer[32000];       // big, but small enough to fit in PPC stack
00989 
00990         va_start (argptr,fmt);
00991         len = vsprintf (bigbuffer,fmt,argptr);
00992         va_end (argptr);
00993         if ( len >= sizeof( bigbuffer ) ) {
00994                 Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" );
00995         }
00996         if (len >= size) {
00997                 Com_Printf ("Com_sprintf: overflow of %i in %i\n", len, size);
00998 #ifdef  _DEBUG
00999                 __asm {
01000                         int 3;
01001                 }
01002 #endif
01003         }
01004         Q_strncpyz (dest, bigbuffer, size );
01005 }

void COM_StripExtension const char *  in,
char *  out
 

Definition at line 99 of file q_shared.c.

Referenced by CG_CustomSound(), CG_LoadCISounds(), CG_RegisterWeapon(), Q3_PlaySound(), and UI_LoadForceConfig_List().

00099                                                      {
00100         while ( *in && *in != '.' ) {
00101                 *out++ = *in++;
00102         }
00103         *out = 0;
00104 }

float FloatNoSwap const float *  f  ) 
 

Definition at line 230 of file q_shared.c.

00231 {
00232         return *f;
00233 }

float FloatSwap const float *  f  ) 
 

Definition at line 220 of file q_shared.c.

References _FloatByteUnion::f, _FloatByteUnion::i, and LongSwap().

00220                                  {
00221         const _FloatByteUnion *in;
00222         _FloatByteUnion out;
00223 
00224         in = (_FloatByteUnion *)f;
00225         out.i = LongSwap(in->i);
00226 
00227         return out.f;
00228 }

int GetIDForString stringID_table_t table,
const char *  string
 

Definition at line 13 of file q_shared.c.

References stringID_table_s::id, stringID_table_s::name, name, NULL, Q_stricmp(), and stringID_table_t.

Referenced by BG_ParseAnimationFile(), G_ActivateBehavior(), NPC_Kill_f(), NPC_ParseParms(), NPC_Precache(), ParseAnimationEvtBlock(), Q3_GetFloat(), Q3_GetString(), Q3_GetVector(), Q3_Set(), SP_misc_weapon_shooter(), UI_ParseAnimationFile(), vmMain(), and WP_SaberParseParms().

00014 {
00015         int     index = 0;
00016 
00017         while ( ( table[index].name != NULL ) &&
00018                         ( table[index].name[0] != 0 ) )
00019         {
00020                 if ( !Q_stricmp( table[index].name, string ) )
00021                         return table[index].id;
00022 
00023                 index++;
00024         }
00025 
00026         return -1;
00027 }

const char* GetStringForID stringID_table_t table,
int  id
 

Definition at line 35 of file q_shared.c.

References stringID_table_s::id, stringID_table_s::name, NULL, and stringID_table_t.

Referenced by G_ActivateBehavior().

00036 {
00037         int     index = 0;
00038 
00039         while ( ( table[index].name != NULL ) &&
00040                         ( table[index].name[0] != 0 ) )
00041         {
00042                 if ( table[index].id == id )
00043                         return table[index].name;
00044 
00045                 index++;
00046         }
00047 
00048         return NULL;
00049 }

void Info_NextPair const char **  head,
char *  key,
char *  value
 

Definition at line 1108 of file q_shared.c.

01108                                                                 {
01109         char    *o;
01110         const char      *s;
01111 
01112         s = *head;
01113 
01114         if ( *s == '\\' ) {
01115                 s++;
01116         }
01117         key[0] = 0;
01118         value[0] = 0;
01119 
01120         o = key;
01121         while ( *s != '\\' ) {
01122                 if ( !*s ) {
01123                         *o = 0;
01124                         *head = s;
01125                         return;
01126                 }
01127                 *o++ = *s++;
01128         }
01129         *o = 0;
01130         s++;
01131 
01132         o = value;
01133         while ( *s != '\\' && *s ) {
01134                 *o++ = *s++;
01135         }
01136         *o = 0;
01137 
01138         *head = s;
01139 }

void Info_RemoveKey char *  s,
const char *  key
 

Definition at line 1147 of file q_shared.c.

References Com_Error(), ERR_DROP, MAX_INFO_KEY, MAX_INFO_STRING, MAX_INFO_VALUE, strchr(), strcmp(), strcpy(), and strlen().

Referenced by Info_SetValueForKey().

01147                                                 {
01148         char    *start;
01149         char    pkey[MAX_INFO_KEY];
01150         char    value[MAX_INFO_VALUE];
01151         char    *o;
01152 
01153         if ( strlen( s ) >= MAX_INFO_STRING ) {
01154                 Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" );
01155         }
01156 
01157         if (strchr (key, '\\')) {
01158                 return;
01159         }
01160 
01161         while (1)
01162         {
01163                 start = s;
01164                 if (*s == '\\')
01165                         s++;
01166                 o = pkey;
01167                 while (*s != '\\')
01168                 {
01169                         if (!*s)
01170                                 return;
01171                         *o++ = *s++;
01172                 }
01173                 *o = 0;
01174                 s++;
01175 
01176                 o = value;
01177                 while (*s != '\\' && *s)
01178                 {
01179                         if (!*s)
01180                                 return;
01181                         *o++ = *s++;
01182                 }
01183                 *o = 0;
01184 
01185                 if (!strcmp (key, pkey) )
01186                 {
01187                         strcpy (start, s);      // remove this part
01188                         return;
01189                 }
01190 
01191                 if (!*s)
01192                         return;
01193         }
01194 
01195 }

void Info_RemoveKey_Big char *  s,
const char *  key
 

Definition at line 1202 of file q_shared.c.

References BIG_INFO_KEY, BIG_INFO_STRING, BIG_INFO_VALUE, Com_Error(), ERR_DROP, strchr(), strcmp(), strcpy(), and strlen().

Referenced by Info_SetValueForKey_Big().

01202                                                     {
01203         char    *start;
01204         char    pkey[BIG_INFO_KEY];
01205         char    value[BIG_INFO_VALUE];
01206         char    *o;
01207 
01208         if ( strlen( s ) >= BIG_INFO_STRING ) {
01209                 Com_Error( ERR_DROP, "Info_RemoveKey_Big: oversize infostring" );
01210         }
01211 
01212         if (strchr (key, '\\')) {
01213                 return;
01214         }
01215 
01216         while (1)
01217         {
01218                 start = s;
01219                 if (*s == '\\')
01220                         s++;
01221                 o = pkey;
01222                 while (*s != '\\')
01223                 {
01224                         if (!*s)
01225                                 return;
01226                         *o++ = *s++;
01227                 }
01228                 *o = 0;
01229                 s++;
01230 
01231                 o = value;
01232                 while (*s != '\\' && *s)
01233                 {
01234                         if (!*s)
01235                                 return;
01236                         *o++ = *s++;
01237                 }
01238                 *o = 0;
01239 
01240                 if (!strcmp (key, pkey) )
01241                 {
01242                         strcpy (start, s);      // remove this part
01243                         return;
01244                 }
01245 
01246                 if (!*s)
01247                         return;
01248         }
01249 
01250 }

void Info_SetValueForKey char *  s,
const char *  key,
const char *  value
 

Definition at line 1280 of file q_shared.c.

References Com_Error(), Com_Printf(), Com_sprintf(), ERR_DROP, Info_RemoveKey(), MAX_INFO_STRING, strcat(), strchr(), strcpy(), and strlen().

Referenced by ClientBegin(), ClientSpawn(), ClientUserinfoChanged(), Cmd_TeamTask_f(), G_ParseInfos(), SetTeamQuick(), SP_terrain(), and UI_ParseInfos().

01280                                                                         {
01281         char    newi[MAX_INFO_STRING];
01282 
01283         if ( strlen( s ) >= MAX_INFO_STRING ) {
01284                 Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
01285         }
01286 
01287         if (strchr (key, '\\') || strchr (value, '\\'))
01288         {
01289                 Com_Printf ("Can't use keys or values with a \\\n");
01290                 return;
01291         }
01292 
01293         if (strchr (key, ';') || strchr (value, ';'))
01294         {
01295                 Com_Printf ("Can't use keys or values with a semicolon\n");
01296                 return;
01297         }
01298 
01299         if (strchr (key, '\"') || strchr (value, '\"'))
01300         {
01301                 Com_Printf ("Can't use keys or values with a \"\n");
01302                 return;
01303         }
01304 
01305         Info_RemoveKey (s, key);
01306         if (!value || !strlen(value))
01307                 return;
01308 
01309         Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
01310 
01311         if (strlen(newi) + strlen(s) > MAX_INFO_STRING)
01312         {
01313                 Com_Printf ("Info string length exceeded\n");
01314                 return;
01315         }
01316 
01317         strcat (newi, s);
01318         strcpy (s, newi);
01319 }

void Info_SetValueForKey_Big char *  s,
const char *  key,
const char *  value
 

Definition at line 1328 of file q_shared.c.

References BIG_INFO_STRING, Com_Error(), Com_Printf(), Com_sprintf(), ERR_DROP, Info_RemoveKey_Big(), strcat(), strchr(), and strlen().

01328                                                                             {
01329         char    newi[BIG_INFO_STRING];
01330 
01331         if ( strlen( s ) >= BIG_INFO_STRING ) {
01332                 Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
01333         }
01334 
01335         if (strchr (key, '\\') || strchr (value, '\\'))
01336         {
01337                 Com_Printf ("Can't use keys or values with a \\\n");
01338                 return;
01339         }
01340 
01341         if (strchr (key, ';') || strchr (value, ';'))
01342         {
01343                 Com_Printf ("Can't use keys or values with a semicolon\n");
01344                 return;
01345         }
01346 
01347         if (strchr (key, '\"') || strchr (value, '\"'))
01348         {
01349                 Com_Printf ("Can't use keys or values with a \"\n");
01350                 return;
01351         }
01352 
01353         Info_RemoveKey_Big (s, key);
01354         if (!value || !strlen(value))
01355                 return;
01356 
01357         Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
01358 
01359         if (strlen(newi) + strlen(s) > BIG_INFO_STRING)
01360         {
01361                 Com_Printf ("BIG Info string length exceeded\n");
01362                 return;
01363         }
01364 
01365         strcat (s, newi);
01366 }

qboolean Info_Validate const char *  s  ) 
 

Definition at line 1263 of file q_shared.c.

References qboolean, qfalse, qtrue, and strchr().

Referenced by ClientUserinfoChanged().

01263                                         {
01264         if ( strchr( s, '\"' ) ) {
01265                 return qfalse;
01266         }
01267         if ( strchr( s, ';' ) ) {
01268                 return qfalse;
01269         }
01270         return qtrue;
01271 }

char* Info_ValueForKey const char *  s,
const char *  key
 

Definition at line 1051 of file q_shared.c.

References BIG_INFO_KEY, BIG_INFO_STRING, BIG_INFO_VALUE, Com_Error(), ERR_DROP, Q_stricmp(), and strlen().

Referenced by CG_DrawInformation(), CG_DrawSiegeInfo(), CG_LoadingClient(), CG_NewClientInfo(), CG_ParseServerinfo(), ClientBegin(), ClientConnect(), ClientSpawn(), ClientUserinfoChanged(), Cmd_CallVote_f(), G_AddRandomBot(), G_BotConnect(), G_DoesMapSupportGametype(), G_GetArenaInfoByMap(), G_GetBotInfoByName(), G_InitSessionData(), G_LogWeaponOutput(), G_RefreshNextMap(), Svcmd_BotList_f(), UI_DrawConnectScreen(), UI_FeederSelection(), UI_ForceConfigHandle(), UI_ForceSide_HandleKey(), UI_GetBotInfoByName(), UI_GetBotNameByNumber(), UI_HasSetSaberOnly(), UI_LoadArenas(), UI_ParseInfos(), UI_ReadLegalForce(), UI_SetSiegeTeams(), UI_TrueJediEnabled(), UpdateForceStatus(), and WP_InitForcePowers().

01051                                                          {
01052         char    pkey[BIG_INFO_KEY];
01053         static  char value[2][BIG_INFO_VALUE];  // use two buffers so compares
01054                                                                                         // work without stomping on each other
01055         static  int     valueindex = 0;
01056         char    *o;
01057         
01058         if ( !s || !key ) {
01059                 return "";
01060         }
01061 
01062         if ( strlen( s ) >= BIG_INFO_STRING ) {
01063                 Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" );
01064         }
01065 
01066         valueindex ^= 1;
01067         if (*s == '\\')
01068                 s++;
01069         while (1)
01070         {
01071                 o = pkey;
01072                 while (*s != '\\')
01073                 {
01074                         if (!*s)
01075                                 return "";
01076                         *o++ = *s++;
01077                 }
01078                 *o = 0;
01079                 s++;
01080 
01081                 o = value[valueindex];
01082 
01083                 while (*s != '\\' && *s)
01084                 {
01085                         *o++ = *s++;
01086                 }
01087                 *o = 0;
01088 
01089                 if (!Q_stricmp (key, pkey) )
01090                         return value[valueindex];
01091 
01092                 if (!*s)
01093                         break;
01094                 s++;
01095         }
01096 
01097         return "";
01098 }

qint64 Long64NoSwap qint64  ll  ) 
 

Definition at line 210 of file q_shared.c.

00211 {
00212         return ll;
00213 }

qint64 Long64Swap qint64  ll  ) 
 

Definition at line 194 of file q_shared.c.

References qint64::b0, qint64::b1, qint64::b2, qint64::b3, qint64::b4, qint64::b5, qint64::b6, and qint64::b7.

00195 {
00196         qint64  result;
00197 
00198         result.b0 = ll.b7;
00199         result.b1 = ll.b6;
00200         result.b2 = ll.b5;
00201         result.b3 = ll.b4;
00202         result.b4 = ll.b3;
00203         result.b5 = ll.b2;
00204         result.b6 = ll.b1;
00205         result.b7 = ll.b0;
00206 
00207         return result;
00208 }

int LongNoSwap int  l  ) 
 

Definition at line 189 of file q_shared.c.

00190 {
00191         return l;
00192 }

int LongSwap int  l  ) 
 

Definition at line 177 of file q_shared.c.

References byte.

Referenced by FloatSwap().

00178 {
00179         byte    b1,b2,b3,b4;
00180 
00181         b1 = l&255;
00182         b2 = (l>>8)&255;
00183         b3 = (l>>16)&255;
00184         b4 = (l>>24)&255;
00185 
00186         return ((int)b1<<24) + ((int)b2<<16) + ((int)b3<<8) + b4;
00187 }

void Parse1DMatrix const char **  buf_p,
int  x,
float *  m
 

Definition at line 724 of file q_shared.c.

References atof(), COM_MatchToken(), and COM_Parse().

Referenced by Parse2DMatrix().

00724                                                          {
00725         char    *token;
00726         int             i;
00727 
00728         COM_MatchToken( buf_p, "(" );
00729 
00730         for (i = 0 ; i < x ; i++) {
00731                 token = COM_Parse(buf_p);
00732                 m[i] = atof(token);
00733         }
00734 
00735         COM_MatchToken( buf_p, ")" );
00736 }

void Parse2DMatrix const char **  buf_p,
int  y,
int  x,
float *  m
 

Definition at line 738 of file q_shared.c.

References COM_MatchToken(), and Parse1DMatrix().

Referenced by Parse3DMatrix().

00738                                                                 {
00739         int             i;
00740 
00741         COM_MatchToken( buf_p, "(" );
00742 
00743         for (i = 0 ; i < y ; i++) {
00744                 Parse1DMatrix (buf_p, x, m + i * x);
00745         }
00746 
00747         COM_MatchToken( buf_p, ")" );
00748 }

void Parse3DMatrix const char **  buf_p,
int  z,
int  y,
int  x,
float *  m
 

Definition at line 750 of file q_shared.c.

References COM_MatchToken(), and Parse2DMatrix().

00750                                                                        {
00751         int             i;
00752 
00753         COM_MatchToken( buf_p, "(" );
00754 
00755         for (i = 0 ; i < z ; i++) {
00756                 Parse2DMatrix (buf_p, y, x, m + i * x*y);
00757         }
00758 
00759         COM_MatchToken( buf_p, ")" );
00760 }

char* Q_CleanStr char *  string  ) 
 

Definition at line 963 of file q_shared.c.

References Q_IsColorString.

Referenced by CG_DrawInformation(), CG_LoadingClient(), Cmd_CallTeamVote_f(), G_AddRandomBot(), G_KickAllBots(), and G_RemoveRandomBot().

00963                                  {
00964         char*   d;
00965         char*   s;
00966         int             c;
00967 
00968         s = string;
00969         d = string;
00970         while ((c = *s) != 0 ) {
00971                 if ( Q_IsColorString( s ) ) {
00972                         s++;
00973                 }               
00974                 else if ( c >= 0x20 && c <= 0x7E ) {
00975                         *d++ = c;
00976                 }
00977                 s++;
00978         }
00979         *d = '\0';
00980 
00981         return string;
00982 }

int Q_isalpha int  c  ) 
 

Definition at line 792 of file q_shared.c.

00793 {
00794         if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
00795                 return ( 1 );
00796         return ( 0 );
00797 }

int Q_islower int  c  ) 
 

Definition at line 778 of file q_shared.c.

00779 {
00780         if (c >= 'a' && c <= 'z')
00781                 return ( 1 );
00782         return ( 0 );
00783 }

int Q_isprint int  c  ) 
 

Definition at line 771 of file q_shared.c.

00772 {
00773         if ( c >= 0x20 && c <= 0x7E )
00774                 return ( 1 );
00775         return ( 0 );
00776 }

int Q_isupper int  c  ) 
 

Definition at line 785 of file q_shared.c.

00786 {
00787         if (c >= 'A' && c <= 'Z')
00788                 return ( 1 );
00789         return ( 0 );
00790 }

int Q_PrintStrlen const char *  string  ) 
 

Definition at line 940 of file q_shared.c.

References Q_IsColorString.

00940                                         {
00941         int                     len;
00942         const char      *p;
00943 
00944         if( !string ) {
00945                 return 0;
00946         }
00947 
00948         len = 0;
00949         p = string;
00950         while( *p ) {
00951                 if( Q_IsColorString( p ) ) {
00952                         p += 2;
00953                         continue;
00954                 }
00955                 p++;
00956                 len++;
00957         }
00958 
00959         return len;
00960 }

void Q_strcat char *  dest,
int  size,
const char *  src
 

Definition at line 929 of file q_shared.c.

References Com_Error(), ERR_FATAL, Q_strncpyz(), and strlen().

Referenced by BG_LegalizedForcePowers(), BG_ValidateSkinForTeam(), BuildShaderStateConfig(), CG_BuildSpectatorString(), CG_ParseSurfsFile(), CG_PrintCTFMessage(), G_SendG2KillQueue(), G_SiegeClientExData(), InitSiegeMode(), Item_RunScript(), NPC_ParseParms(), PC_Script_Parse(), and WP_SaberLoadParms().

00929                                                        {
00930         int             l1;
00931 
00932         l1 = strlen( dest );
00933         if ( l1 >= size ) {
00934                 Com_Error( ERR_FATAL, "Q_strcat: already overflowed" );
00935         }
00936         Q_strncpyz( dest + l1, src, size - l1 );
00937 }

int Q_stricmp const char *  s1,
const char *  s2
 

Definition at line 900 of file q_shared.c.

References Q_stricmpn().

Referenced by AcceptBotCommand(), AddRemap(), AddSpawnField(), AimAtTarget(), Asset_Parse(), BeginAutoPathRoutine(), BG_FindItem(), BG_IsValidCharacterModel(), BG_ParseAnimationEvtFile(), BG_ParseAnimationFile(), BG_ParseField(), BG_ParseLiteral(), BG_PrecacheSabersForSiegeTeam(), BG_SiegeCheckClassLegality(), BG_SiegeFindClassByName(), BG_SiegeFindClassIndexByName(), BG_SiegeFindTeamForTheme(), BG_SiegeGetPairedValue(), BG_SiegeGetValueGroup(), BG_SiegeTranslateForcePowers(), BG_SiegeTranslateGenericTable(), BG_ValidateSkinForTeam(), BindingFromName(), BindingIDFromName(), BotAI(), CG_Asset_Parse(), CG_ClientNumFromName(), CG_ConsoleCommand(), CG_GetStringForVoiceSound(), CG_InitSiegeMode(), CG_Load_Menu(), CG_LoadCISounds(), CG_LoadMenus(), CG_NewClientInfo(), CG_ParseMenu(), CG_ParseSurfsFile(), CG_ParticleExplosion(), CG_PlayerAnimEventDo(), CG_RegisterItemVisuals(), CG_SpawnCGameEntFromVars(), CheckCvars(), ClientCommand(), ClientConnect(), ClientForString(), ClientSpawn(), ClientUserinfoChanged(), Cmd_CallTeamVote_f(), Cmd_CallVote_f(), Cmd_DebugSetBodyAnim_f(), Cmd_DuelTeam_f(), Cmd_Give_f(), Cmd_NPC_f(), ConsoleCommand(), EntIsGlass(), ForceThrow(), G_AddRandomBot(), G_DoesMapSupportGametype(), G_EntIsBreakable(), G_EntIsDoor(), G_EntIsRemovableUsable(), G_EntIsUnlockedDoor(), G_Find(), G_GetArenaInfoByMap(), G_GetBotInfoByName(), G_GetHitLocFromSurfName(), G_MissileImpact(), G_NameInTriggerClassList(), G_RefreshNextMap(), G_SetEnemy(), G_SetSaber(), G_SpawnString(), G_TeamForSiegeClass(), G_TryPushingEntity(), G_ValidateSiegeClassForTeam(), GetClosestSpawn(), GetIDForString(), GetNextSpawnInIndex(), Info_ValueForKey(), InitSiegeMode(), Item_EnableShowViaCvar(), Item_Multi_FindCvarByValue(), Item_Multi_Setting(), Item_RunScript(), ItemParse_asset_model_go(), ItemParse_cvarStrList(), ItemParse_flag(), ItemParse_model_g2anim(), ItemParse_model_g2anim_go(), Jedi_CanPullBackSaber(), KeywordHash_Find(), maglock_link(), Menu_FindItemByName(), Menu_GetMatchingItemByNumber(), Menu_ItemsMatchingGroup(), MenuParse_name(), Menus_ActivateByName(), Menus_FindByName(), multi_trigger(), NAV_GetStoredWaypoint(), NAVNEW_ResolveEntityCollision(), NPC_Begin(), NPC_BSGM_Attack(), NPC_Jedi_Pain(), NPC_Kill_f(), NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), NPC_Respond(), NPC_SetMiscDefaultData(), NPC_SetSurfaceOnOff(), NPC_Spawn_Do(), NPC_Spawn_f(), NPC_SpawnType(), NPC_VehiclePrecache(), NPC_WeaponsForTeam(), ParseAnimationEvtBlock(), PC_Script_Parse(), PC_String_Parse(), PM_VehicleImpact(), Q3_Kill(), Q3_Lerp2Angles(), Q3_Lerp2End(), Q3_Lerp2Origin(), Q3_Lerp2Pos(), Q3_Lerp2Start(), Q3_Play(), Q3_PlaySound(), Q3_Remove(), Q3_Set(), Q3_SetLoopSound(), Script_Close(), Script_SetColor(), Script_SetItemColor(), Script_SetItemColorCvar(), SelectDuelSpawnPoint(), SelectRandomTeamSpawnPoint(), SetTeam(), SP_gametype_item(), SP_misc_siege_item(), SP_worldspawn(), Svcmd_Nav_f(), TAG_Find(), TAG_FindOwner(), TIMER_GetExisting(), TIMER_GetNew(), Touch_Multi(), TranslateSaberColor(), TranslateSaberStyle(), TranslateSaberType(), TryHeal(), UI_ConsoleCommand(), UI_DrawConnectScreen(), UI_GetBotInfoByName(), UI_LoadMenus(), UI_ParseAnimationFile(), UI_ParseLiteral(), UI_ParseLiteralSilent(), UI_ParseMenu(), UI_SaberParseParm(), UI_SaveForceTemplate(), UI_SetSiegeTeams(), UI_SiegeSetCvarsForClass(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), VEH_VehicleIndexForName(), VEH_VehWeaponIndexForName(), WP_ResistForcePush(), WP_SaberInitBladeData(), WP_SaberParseParm(), WP_SaberParseParms(), and WP_SetSaber().

00900                                                {
00901         return (s1 && s2) ? Q_stricmpn (s1, s2, 99999) : -1;
00902 }

int Q_stricmpn const char *  s1,
const char *  s2,
int  n
 

Definition at line 842 of file q_shared.c.

References NULL.

Referenced by BG_ValidateSkinForTeam(), CG_PlayerAnimEventDo(), ParseAnimationEvtBlock(), Q_stricmp(), and WP_SaberParseParms().

00842                                                        {
00843         int             c1, c2;
00844 
00845         // bk001129 - moved in 1.17 fix not in id codebase
00846         if ( s1 == NULL ) {
00847            if ( s2 == NULL )
00848              return 0;
00849            else
00850              return -1;
00851         }
00852         else if ( s2==NULL )
00853           return 1;
00854 
00855 
00856         
00857         do {
00858                 c1 = *s1++;
00859                 c2 = *s2++;
00860 
00861                 if (!n--) {
00862                         return 0;               // strings are equal until end point
00863                 }
00864                 
00865                 if (c1 != c2) {
00866                         if (c1 >= 'a' && c1 <= 'z') {
00867                                 c1 -= ('a' - 'A');
00868                         }
00869                         if (c2 >= 'a' && c2 <= 'z') {
00870                                 c2 -= ('a' - 'A');
00871                         }
00872                         if (c1 != c2) {
00873                                 return c1 < c2 ? -1 : 1;
00874                         }
00875                 }
00876         } while (c1);
00877         
00878         return 0;               // strings are equal
00879 }

char* Q_strlwr char *  s1  ) 
 

Definition at line 905 of file q_shared.c.

References tolower().

Referenced by NPC_Spawn_Do(), and TAG_Add().

00905                            {
00906     char        *s;
00907 
00908     s = s1;
00909         while ( *s ) {
00910                 *s = tolower(*s);
00911                 s++;
00912         }
00913     return s1;
00914 }

int Q_strncmp const char *  s1,
const char *  s2,
int  n
 

Definition at line 881 of file q_shared.c.

Referenced by BG_ValidateSkinForTeam(), CheckTeamVote(), G_GetHitLocFromSurfName(), G_SpawnGEntityFromSpawnVars(), NPC_SpawnType(), NPC_WeaponsForTeam(), and Q3_Set().

00881                                                       {
00882         int             c1, c2;
00883         
00884         do {
00885                 c1 = *s1++;
00886                 c2 = *s2++;
00887 
00888                 if (!n--) {
00889                         return 0;               // strings are equal until end point
00890                 }
00891                 
00892                 if (c1 != c2) {
00893                         return c1 < c2 ? -1 : 1;
00894                 }
00895         } while (c1);
00896         
00897         return 0;               // strings are equal
00898 }

void Q_strncpyz char *  dest,
const char *  src,
int  destsize
 

Definition at line 826 of file q_shared.c.

References Com_Error(), ERR_FATAL, and strncpy().

Referenced by BG_GetRootSurfNameWithVariant(), BG_ValidateSkinForTeam(), CG_CenterPrint(), CG_DrawInformation(), CG_LoadClientInfo(), CG_LoadingClient(), CG_LoadingString(), CG_NewClientInfo(), CG_ParseSurfsFile(), CG_StartMusic(), CG_TestModel_f(), ClientConnect(), ClientUserinfoChanged(), Cmd_CallTeamVote_f(), COM_DefaultExtension(), Com_sprintf(), G_BotConnect(), G_Dismember(), G_ParseInfos(), G_ProcessIPBans(), G_Say(), Item_EnableShowViaCvar(), NAV_StoreWaypoint(), NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), Q3_PlaySound(), Q_strcat(), Script_Defer(), SP_target_speaker(), TAG_Add(), UI_FeederSelection(), UI_GetSaberForMenu(), UI_ParseInfos(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), and WP_InitForcePowers().

00826                                                              {
00827   // bk001129 - also NULL dest
00828   if ( !dest ) {
00829     Com_Error( ERR_FATAL, "Q_strncpyz: NULL dest" );
00830   }
00831         if ( !src ) {
00832                 Com_Error( ERR_FATAL, "Q_strncpyz: NULL src" );
00833         }
00834         if ( destsize < 1 ) {
00835                 Com_Error(ERR_FATAL,"Q_strncpyz: destsize < 1" ); 
00836         }
00837 
00838         strncpy( dest, src, destsize-1 );
00839   dest[destsize-1] = 0;
00840 }

char* Q_strrchr const char *  string,
int  c
 

Definition at line 799 of file q_shared.c.

Referenced by CG_CacheG2AnimInfo(), CG_G2AnimEntModelLoad(), CG_G2EvIndexForModel(), CG_G2SkelForModel(), CG_HandleAppendedSkin(), ItemParse_asset_model_go(), NPC_VehiclePrecache(), and SetupGameGhoul2Model().

00800 {
00801         char cc = c;
00802         char *s;
00803         char *sp=(char *)0;
00804 
00805         s = (char*)string;
00806 
00807         while (*s)
00808         {
00809                 if (*s == cc)
00810                         sp = s;
00811                 s++;
00812         }
00813         if (cc == 0)
00814                 sp = s;
00815 
00816         return sp;
00817 }

char* Q_strupr char *  s1  ) 
 

Definition at line 916 of file q_shared.c.

References toupper().

Referenced by CG_DrawInvenSelect(), CG_DrawWeaponSelect(), CG_LoadingItem(), and Q3_PlaySound().

00916                            {
00917     char        *s;
00918 
00919     s = s1;
00920         while ( *s ) {
00921                 *s = toupper(*s);
00922                 s++;
00923         }
00924     return s1;
00925 }

short ShortNoSwap short  l  ) 
 

Definition at line 172 of file q_shared.c.

00173 {
00174         return l;
00175 }

short ShortSwap short  l  ) 
 

Definition at line 162 of file q_shared.c.

References byte.

00163 {
00164         byte    b1,b2;
00165 
00166         b1 = l&255;
00167         b2 = (l>>8)&255;
00168 
00169         return (b1<<8) + b2;
00170 }

void SkipBracedSection const char **  program  ) 
 

Definition at line 685 of file q_shared.c.

References COM_ParseExt(), and qtrue.

Referenced by NPC_ParseParms(), NPC_Precache(), NPC_PrecacheAnimationCFG(), UI_SaberGetHiltInfo(), UI_SaberParseParm(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), WP_SaberParseParm(), and WP_SaberParseParms().

00685                                               {
00686         char                    *token;
00687         int                             depth;
00688 
00689         depth = 0;
00690         do {
00691                 token = COM_ParseExt( program, qtrue );
00692                 if( token[1] == 0 ) {
00693                         if( token[0] == '{' ) {
00694                                 depth++;
00695                         }
00696                         else if( token[0] == '}' ) {
00697                                 depth--;
00698                         }
00699                 }
00700         } while( depth && *program );
00701 }

void SkipRestOfLine const char **  data  ) 
 

Definition at line 708 of file q_shared.c.

Referenced by NPC_ParseParms(), ParseAnimationEvtBlock(), UI_SaberGetHiltInfo(), UI_SaberParseParm(), VEH_LoadVehicle(), VEH_LoadVehWeapon(), WP_SaberParseParm(), and WP_SaberParseParms().

00708                                           {
00709         const char      *p;
00710         int             c;
00711 
00712         p = *data;
00713         while ( (c = *p++) != 0 ) {
00714                 if ( c == '\n' ) {
00715                         com_lines++;
00716                         break;
00717                 }
00718         }
00719 
00720         *data = p;
00721 }

const char* SkipWhitespace const char *  data,
qboolean hasNewLines
 

Definition at line 336 of file q_shared.c.

References NULL, and qtrue.

Referenced by COM_ParseExt().

00336                                                                       {
00337         int c;
00338 
00339         while( (c = *data) <= ' ') {
00340                 if( !c ) {
00341                         return NULL;
00342                 }
00343                 if( c == '\n' ) {
00344                         com_lines++;
00345                         *hasNewLines = qtrue;
00346                 }
00347                 data++;
00348         }
00349 
00350         return data;
00351 }

char* QDECL va const char *  format,
... 
 

Definition at line 1017 of file q_shared.c.

References QDECL, va_end, va_list, va_start, and vsprintf().

Referenced by _UI_Init(), AdjustTournamentScores(), AssetCache(), BG_LegalizedForcePowers(), BG_ParseAnimationEvtFile(), BG_SiegeParseTeamFile(), BG_ValidateSkinForTeam(), BG_VehicleLoadParms(), BG_VehWeaponLoadParms(), BindingFromName(), BroadcastTeamChange(), CalculateRanks(), CG_AddSaberBlade(), CG_BuildSpectatorString(), CG_CacheG2AnimInfo(), CG_Chunks(), CG_DrawActiveFrame(), CG_DrawHUD(), CG_DrawInformation(), CG_DrawInvenSelect(), CG_DrawMedal(), CG_DrawOldScoreboard(), CG_DrawRadar(), CG_DrawWeaponSelect(), CG_EntityEvent(), CG_G2AnimEntModelLoad(), CG_G2SaberEffects(), CG_GetGameStatusText(), CG_GetKillerText(), CG_GetMenuBuffer(), CG_GetStringEdString(), CG_HandleAppendedSkin(), CG_Init(), CG_InitSiegeMode(), CG_LoadCISounds(), CG_LoadMenus(), CG_ParseServerinfo(), CG_ParseSiegeObjectiveStatus(), CG_PlaceString(), CG_Player(), CG_PlayerAnimEventDo(), CG_PrecachePlayersForSiegeTeam(), CG_SetSiegeTimerCvar(), CG_SiegeBriefingDisplay(), CG_SiegeCountCvars(), CG_SiegeGetObjectiveDescription(), CG_SiegeGetObjectiveFinal(), CG_TargetCommand_f(), CheatsOk(), CheckExitRules(), CheckIntermissionExit(), CheckTeamVote(), CheckTournament(), CheckVote(), ClientBegin(), ClientCommand(), ClientConnect(), ClientNumberFromString(), ClientSpawn(), ClientThink_real(), ClientUserinfoChanged(), Cmd_CallTeamVote_f(), Cmd_CallVote_f(), Cmd_DuelTeam_f(), Cmd_EngageDuel_f(), Cmd_ForceChanged_f(), Cmd_God_f(), Cmd_Kill_f(), Cmd_Noclip_f(), Cmd_Notarget_f(), Cmd_SaberAttackCycle_f(), Cmd_SetViewpos_f(), Cmd_SiegeClass_f(), Cmd_Team_f(), Cmd_TeamTask_f(), Cmd_TeamVote_f(), Cmd_Vote_f(), Cmd_Where_f(), Com_Error(), Com_Printf(), ConsoleCommand(), DeathFX(), DeathmatchScoreboardMessage(), DoGripAction(), Droid_Patrol(), ForceLightningDamage(), G_ActivateBehavior(), G_AddRandomBot(), G_BounceMissile(), G_BreakArm(), G_DroidSounds(), G_FreeEntity(), G_GetBotInfoByNumber(), G_InitGame(), G_KickAllBots(), G_KillG2Queue(), G_ModelIndex(), G_ParseInfos(), G_ReadSessionData(), G_RefreshNextMap(), G_RemoveRandomBot(), G_RunFrame(), G_SaberModelSetup(), G_SendG2KillQueue(), G_TeamCommand(), G_UpdateCvars(), G_WriteClientSessionData(), G_WriteSessionData(), GetMenuBuffer(), ImperialProbe_AttackDecision(), ImperialProbe_Patrol(), InitSiegeMode(), Interrogator_Attack(), Item_Multi_HandleKey(), Item_Slider_HandleKey(), Item_YesNo_HandleKey(), ItemParse_cvarStrList(), ItemParse_flag(), JMSaberTouch(), MaintainBodyQueue(), Mark1_die(), Mark1_dying(), Menu_PaintAll(), MineMonster_TryDamage(), NPC_BSRancor_Default(), NPC_BSWampa_Default(), NPC_LoadParms(), NPC_Mark1_Pain(), NPC_Mark2_Pain(), NPC_MineMonster_Precache(), NPC_Mouse_Precache(), NPC_ParseParms(), NPC_Precache(), NPC_Probe_Precache(), NPC_R2D2_Precache(), NPC_R5D2_Precache(), NPC_Rancor_Precache(), NPC_Respond(), NPC_Sentry_Patrol(), NPC_Sentry_Precache(), NPC_VehiclePrecache(), ParseAnimationEvtBlock(), PC_Script_Parse(), Script_Exec(), scriptrunner_run(), Sentry_AttackDecision(), SetLeader(), SetTeam(), SetupGameGhoul2Model(), SiegeBeginRound(), SiegeCheckTimers(), SiegeRoundComplete(), SiegeSetCompleteData(), SP_CreateRain(), SP_CreateSpaceDust(), SP_misc_skyportal(), SP_terrain(), SP_worldspawn(), Svcmd_BotList_f(), target_level_change_use(), TeamplayInfoMessage(), Text_PaintWithCursor(), UI_ClearScores(), UI_DrawConnectScreen(), UI_FeederSelection(), UI_ForceConfigHandle(), UI_ForceMaxRank_HandleKey(), UI_GetBotInfoByNumber(), UI_GetStringEdString(), UI_LoadArenas(), UI_LoadMenus(), UI_ParseInfos(), UI_SaberBladeLengthForSaber(), UI_SaberBladeRadiusForSaber(), UI_SaberDrawBlade(), UI_SaberLoadParms(), UI_SaveForceTemplate(), UI_SetBestScores(), UI_SiegeSetCvarsForClass(), UI_UpdateClientForcePowers(), UI_UpdateSiegeObjectiveGraphics(), UI_UpdateSiegeStatusIcons(), Use_Target_Print(), VEH_LoadVehicle(), WP_FireMelee(), WP_FireStunBaton(), WP_InitForcePowers(), WP_SaberBounceSound(), and WP_SaberLoadParms().

01017                                               {
01018         va_list         argptr;
01019         static char             string[2][32000];       // in case va is called by nested functions
01020         static int              index = 0;
01021         char    *buf;
01022 
01023         buf = string[index & 1];
01024         index++;
01025 
01026         va_start (argptr, format);
01027         vsprintf (buf, format,argptr);
01028         va_end (argptr);
01029 
01030         return buf;
01031 }