#include "q_shared.h"
Include dependency graph for q_shared.cpp:

Go to the source code of this file.
Functions | |
| float | BigFloat (float l) |
| int | BigLong (int l) |
| short | BigShort (short l) |
| int | Com_AddToGrowList (growList_t *list, void *data) |
| void * | Com_Allocate (int bytes) |
| float | Com_Clamp (float min, float max, float value) |
| void | Com_Dealloc (void *ptr) |
| void | Com_DefaultExtension (char *path, int maxSize, const char *extension) |
| int | Com_Filter (const char *filter, const char *name, int casesensitive) |
| 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) |
| int | Com_ParseInfos (const char *buf, int max, char infos[][MAX_INFO_STRING]) |
| char * | Com_SkipPath (char *pathname) |
| 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) |
| float | FloatNoSwap (float f) |
| float | FloatSwap (float f) |
| void | Info_NextPair (const char *(*head), 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) |
| int | LongNoSwap (int l) |
| int | LongSwap (int l) |
| int | ParseHex (const char *text) |
| 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) |
| short | ShortNoSwap (short l) |
| short | ShortSwap (short l) |
| void | Swap_Init (void) |
| char *QDECL | va (char *format,...) |
Variables | |
| float(* | _BigFloat )(float l) |
| int(* | _BigLong )(int l) |
| short(* | _BigShort )(short l) |
| float(* | _LittleFloat )(float l) |
| int(* | _LittleLong )(int l) |
| short(* | _LittleShort )(short l) |
|
|
Definition at line 327 of file q_shared.cpp. References _BigFloat, b, byte, in, and l. 00327 {return _BigFloat(l);}
|
|
|
Definition at line 325 of file q_shared.cpp. References _BigLong, byte, and l. Referenced by ByteSwapTri(), LoadLBM(), Texture_InitPalette(), TRI_LoadPolysets(), and WriteLBMfile(). 00325 {return _BigLong(l);}
|
|
|
Definition at line 323 of file q_shared.cpp. References _BigShort, byte, and l. Referenced by CL_Connect_f(), CL_GlobalServers_f(), CL_LocalServers_f(), CL_Rcon_f(), CL_RequestAuthorization(), CL_RequestMotd(), CL_ServersResponsePacket(), LoadLBM(), NET_StringToAdr(), SV_Ban_f(), SV_BanNum_f(), SV_GetChallenge(), SV_MasterHeartbeat(), and WriteLBMfile(). 00323 {return _BigShort(l);}
|
|
||||||||||||
|
Definition at line 43 of file q_shared.cpp. References Com_AddToGrowList(), Com_Allocate(), Com_Dealloc(), Com_DPrintf(), Com_Error(), Com_InitGrowList(), growList_t::currentElements, data, growList_t::elements, ERR_DROP, ERR_FATAL, growList_t::maxElements, and memcpy(). Referenced by Com_AddToGrowList(). 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 }
|
Here is the call graph for this function:

|
|
Definition at line 681 of file WIN_QE3.CPP. References malloc(). Referenced by Com_AddToGrowList(), and Com_InitGrowList(). 00681 {
00682 return malloc(bytes);
00683 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 103 of file q_shared.cpp. References value. Referenced by ArenaServers_MenuInit(), PlayerSettings_SetMenuItems(), Preferences_SetMenuItems(), Punkbuster_ConfirmDisable(), Punkbuster_ConfirmEnable(), ServerOptions_MenuInit(), ServerOptions_SetMenuItems(), ServerOptions_Start(), UI_AddBotsMenu_Init(), UI_DrawHandicap(), UI_Handicap_HandleKey(), UI_OwnerDrawWidth(), UI_RunMenuScript(), and UI_SPSkillMenu_Init(). 00103 {
00104 if ( value < min ) {
00105 return min;
00106 }
00107 if ( value > max ) {
00108 return max;
00109 }
00110 return value;
00111 }
|
|
|
Definition at line 685 of file WIN_QE3.CPP. Referenced by Com_AddToGrowList(), and FS_FreeFile(). 00685 {
00686 free(ptr);
00687 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 285 of file q_shared.cpp. References Com_sprintf(), Q_strncpyz(), src, and strlen(). 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 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 147 of file q_shared.cpp. References Com_StringContains(), i, name, ptr(), strlen(), and toupper(). Referenced by Cmd_List_f(), Com_FilterPath(), and Cvar_List_f(). 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 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 81 of file q_shared.cpp. References Com_Error(), growList_t::currentElements, growList_t::elements, and ERR_DROP. 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 }
|
Here is the call graph for this function:

|
|
Definition at line 229 of file q_shared.cpp. References FILE_HASH_SIZE, i, and tolower(). 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 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 89 of file q_shared.cpp. References growList_t::currentElements, growList_t::elements, and i. 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. References Com_Allocate(), growList_t::currentElements, growList_t::elements, and growList_t::maxElements. Referenced by Com_AddToGrowList(). 00037 {
00038 list->maxElements = maxElements;
00039 list->currentElements = 0;
00040 list->elements = (void **)Com_Allocate( list->maxElements * sizeof( void * ) );
00041 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 420 of file q_shared.cpp. References Com_Parse(), Com_ParseOnLine(), Com_Printf(), count, Info_SetValueForKey(), Q_strncpyz(), strcmp(), and token. 00420 {
00421 const char *token;
00422 int count;
00423 char key[MAX_TOKEN_CHARS];
00424
00425 count = 0;
00426
00427 while ( 1 ) {
00428 token = Com_Parse( &buf );
00429 if ( !token[0] ) {
00430 break;
00431 }
00432 if ( strcmp( token, "{" ) ) {
00433 Com_Printf( "Missing { in info file\n" );
00434 break;
00435 }
00436
00437 if ( count == max ) {
00438 Com_Printf( "Max infos exceeded\n" );
00439 break;
00440 }
00441
00442 infos[count][0] = 0;
00443 while ( 1 ) {
00444 token = Com_Parse( &buf );
00445 if ( !token[0] ) {
00446 Com_Printf( "Unexpected end of info file\n" );
00447 break;
00448 }
00449 if ( !strcmp( token, "}" ) ) {
00450 break;
00451 }
00452 Q_strncpyz( key, token, sizeof( key ) );
00453
00454 token = Com_ParseOnLine( &buf );
00455 if ( !token[0] ) {
00456 token = "<NULL>";
00457 }
00458 Info_SetValueForKey( infos[count], key, token );
00459 }
00460 count++;
00461 }
00462
00463 return count;
00464 }
|
Here is the call graph for this function:

|
|
Definition at line 253 of file q_shared.cpp. 00254 {
00255 char *last;
00256
00257 last = pathname;
00258 while (*pathname)
00259 {
00260 if (*pathname=='/')
00261 last = pathname+1;
00262 pathname++;
00263 }
00264 return last;
00265 }
|
|
||||||||||||||||||||
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 118 of file q_shared.cpp. References i, j, strlen(), and toupper(). Referenced by Com_Filter(). 00118 {
00119 int len, i, j;
00120
00121 len = strlen(str1) - strlen(str2);
00122 for (i = 0; i <= len; i++, str1++) {
00123 for (j = 0; str2[j]; j++) {
00124 if (casesensitive) {
00125 if (str1[j] != str2[j]) {
00126 break;
00127 }
00128 }
00129 else {
00130 if (toupper(str1[j]) != toupper(str2[j])) {
00131 break;
00132 }
00133 }
00134 }
00135 if (!str2[j]) {
00136 return str1;
00137 }
00138 }
00139 return NULL;
00140 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 272 of file q_shared.cpp. References in.
|
|
|
Definition at line 379 of file q_shared.cpp. 00380 {
00381 return f;
00382 }
|
|
|
Definition at line 362 of file q_shared.cpp. 00363 {
00364 union
00365 {
00366 float f;
00367 byte b[4];
00368 } dat1, dat2;
00369
00370
00371 dat1.f = f;
00372 dat2.b[0] = dat1.b[3];
00373 dat2.b[1] = dat1.b[2];
00374 dat2.b[2] = dat1.b[1];
00375 dat2.b[3] = dat1.b[0];
00376 return dat2.f;
00377 }
|
|
||||||||||||||||
|
Definition at line 792 of file q_shared.cpp. Referenced by CL_SystemInfoChanged(), ServerInfo_MenuDraw(), and UI_ServerInfoMenu(). 00792 {
00793 char *o;
00794 const char *s;
00795
00796 s = *head;
00797
00798 if ( *s == '\\' ) {
00799 s++;
00800 }
00801 key[0] = 0;
00802 value[0] = 0;
00803
00804 o = key;
00805 while ( *s != '\\' ) {
00806 if ( !*s ) {
00807 *o = 0;
00808 *head = s;
00809 return;
00810 }
00811 *o++ = *s++;
00812 }
00813 *o = 0;
00814 s++;
00815
00816 o = value;
00817 while ( *s != '\\' && *s ) {
00818 *o++ = *s++;
00819 }
00820 *o = 0;
00821
00822 *head = s;
00823 }
|
|
||||||||||||
|
Definition at line 831 of file q_shared.cpp. References Com_Error(), ERR_DROP, s, strchr(), strcmp(), strcpy(), and strlen(). Referenced by Info_SetValueForKey(). 00831 {
00832 char *start;
00833 char pkey[MAX_INFO_KEY];
00834 char value[MAX_INFO_VALUE];
00835 char *o;
00836
00837 if ( strlen( s ) >= MAX_INFO_STRING ) {
00838 Com_Error( ERR_DROP, "Info_RemoveKey: oversize infostring" );
00839 }
00840
00841 if (strchr (key, '\\')) {
00842 return;
00843 }
00844
00845 while (1)
00846 {
00847 start = s;
00848 if (*s == '\\')
00849 s++;
00850 o = pkey;
00851 while (*s != '\\')
00852 {
00853 if (!*s)
00854 return;
00855 *o++ = *s++;
00856 }
00857 *o = 0;
00858 s++;
00859
00860 o = value;
00861 while (*s != '\\' && *s)
00862 {
00863 if (!*s)
00864 return;
00865 *o++ = *s++;
00866 }
00867 *o = 0;
00868
00869 if (!strcmp (key, pkey) )
00870 {
00871 strcpy (start, s); // remove this part
00872 return;
00873 }
00874
00875 if (!*s)
00876 return;
00877 }
00878
00879 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 907 of file q_shared.cpp. References Com_Error(), Com_Printf(), Com_sprintf(), ERR_DROP, Info_RemoveKey(), s, strcat(), strchr(), strcpy(), strlen(), and value. Referenced by ArenaServers_InsertFavorites(), BotDeathmatchAI(), BotSetUserInfo(), CL_CheckForResend(), CL_RequestMotd(), CL_ServerInfoPacket(), Cmd_TeamTask_f(), Com_ParseInfos(), Cvar_InfoString(), G_AddBot(), G_LoadArenas(), G_ParseInfos(), LAN_GetServerInfo(), SV_DirectConnect(), SV_RankNewGameCBF(), SV_UserinfoChanged(), SVC_Info(), SVC_Status(), UI_LoadArenas(), UI_LogAwardData(), UI_ParseInfos(), UI_SetBestScore(), UI_ShowTierVideo(), UI_SPUnlock_f(), and UI_SPUnlockMedals_f(). 00907 {
00908 char newi[MAX_INFO_STRING];
00909
00910 if ( strlen( s ) >= MAX_INFO_STRING ) {
00911 Com_Error( ERR_DROP, "Info_SetValueForKey: oversize infostring" );
00912 }
00913
00914 if (strchr (key, '\\') || strchr (value, '\\'))
00915 {
00916 Com_Printf ("Can't use keys or values with a \\\n");
00917 return;
00918 }
00919
00920 if (strchr (key, ';') || strchr (value, ';'))
00921 {
00922 Com_Printf ("Can't use keys or values with a semicolon\n");
00923 return;
00924 }
00925
00926 if (strchr (key, '\"') || strchr (value, '\"'))
00927 {
00928 Com_Printf ("Can't use keys or values with a \"\n");
00929 return;
00930 }
00931
00932 Info_RemoveKey (s, key);
00933 if (!value || !strlen(value))
00934 return;
00935
00936 Com_sprintf (newi, sizeof(newi), "\\%s\\%s", key, value);
00937
00938 if (strlen(newi) + strlen(s) > MAX_INFO_STRING)
00939 {
00940 Com_Printf ("Info string length exceeded\n");
00941 return;
00942 }
00943
00944 strcat (s, newi);
00945 }
|
Here is the call graph for this function:

|
|
Definition at line 890 of file q_shared.cpp. References qboolean, s, and strchr(). Referenced by ClientUserinfoChanged(). 00890 {
00891 if ( strchr( s, '\"' ) ) {
00892 return qfalse;
00893 }
00894 if ( strchr( s, ';' ) ) {
00895 return qfalse;
00896 }
00897 return qtrue;
00898 }
|
Here is the call graph for this function:

|
||||||||||||