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

q_shared.h File Reference

#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.h:

Include dependency graph

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

Included by dependency graph

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 Q3_VERSION   "DOOM 0.01"
#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,...)


Define Documentation

#define ALIGN_OFF
 

Definition at line 36 of file q_shared.h.

#define ALIGN_ON
 

Definition at line 35 of file q_shared.h.

#define BLINK_DIVISOR   200
 

Definition at line 296 of file q_shared.h.

#define EQUAL_EPSILON   0.001
 

Definition at line 215 of file q_shared.h.

#define FILE_HASH_SIZE   1024
 

Definition at line 530 of file q_shared.h.

#define id386   0
 

Definition at line 82 of file q_shared.h.

#define max x,
y   )     ( ( ( x ) > ( y ) ) ? ( x ) : ( y ) )
 

Definition at line 234 of file q_shared.h.

#define MAX_INFO_KEY   1024
 

Definition at line 254 of file q_shared.h.

#define MAX_INFO_STRING   1024
 

Definition at line 253 of file q_shared.h.

#define MAX_INFO_VALUE   1024
 

Definition at line 255 of file q_shared.h.

#define MAX_MAP_AREA_BYTES   32
 

Definition at line 275 of file q_shared.h.

#define MAX_NAME_LENGTH   32
 

Definition at line 261 of file q_shared.h.

#define MAX_OSPATH   128
 

Definition at line 259 of file q_shared.h.

#define MAX_QINT   0x7fffffff
 

Definition at line 230 of file q_shared.h.

#define MAX_QPATH   64
 

Definition at line 258 of file q_shared.h.

#define MAX_STRING_CHARS   1024
 

Definition at line 249 of file q_shared.h.

#define MAX_STRING_TOKENS   256
 

Definition at line 250 of file q_shared.h.

#define MAX_TOKEN_CHARS   1024
 

Definition at line 251 of file q_shared.h.

#define min x,
y   )     ( ( ( x ) < ( y ) ) ? ( x ) : ( y ) )
 

Definition at line 235 of file q_shared.h.

#define MIN_QINT   (-MAX_QINT-1)
 

Definition at line 231 of file q_shared.h.

#define NULL   ((void *)0)
 

Definition at line 227 of file q_shared.h.

#define PITCH   0
 

Definition at line 243 of file q_shared.h.

#define PROP_GAP_WIDTH   3
 

Definition at line 291 of file q_shared.h.

#define PROP_HEIGHT   27
 

Definition at line 293 of file q_shared.h.

#define PROP_SMALL_SIZE_SCALE   0.75
 

Definition at line 294 of file q_shared.h.

#define PROP_SPACE_WIDTH   8
 

Definition at line 292 of file q_shared.h.

#define PULSE_DIVISOR   75
 

Definition at line 297 of file q_shared.h.

#define Q3_VERSION   "DOOM 0.01"
 

Definition at line 32 of file q_shared.h.

#define QDECL
 

Definition at line 87 of file q_shared.h.

#define ROLL   2
 

Definition at line 245 of file q_shared.h.

#define sign  )     ( ( f > 0 ) ? 1 : ( ( f < 0 ) ? -1 : 0 ) )
 

Definition at line 239 of file q_shared.h.

#define UI_BIGFONT   0x00000020
 

Definition at line 304 of file q_shared.h.

#define UI_BLINK   0x00001000
 

Definition at line 307 of file q_shared.h.

#define UI_CENTER   0x00000001
 

Definition at line 300 of file q_shared.h.

#define UI_DROPSHADOW   0x00000800
 

Definition at line 306 of file q_shared.h.

#define UI_FORMATMASK   0x00000007
 

Definition at line 302 of file q_shared.h.

#define UI_GIANTFONT   0x00000040
 

Definition at line 305 of file q_shared.h.

#define UI_INVERSE   0x00002000
 

Definition at line 308 of file q_shared.h.

#define UI_LEFT   0x00000000
 

Definition at line 299 of file q_shared.h.

#define UI_PULSE   0x00004000
 

Definition at line 309 of file q_shared.h.

#define UI_RIGHT   0x00000002
 

Definition at line 301 of file q_shared.h.

#define UI_SMALLFONT   0x00000010
 

Definition at line 303 of file q_shared.h.

#define YAW   1
 

Definition at line 244 of file q_shared.h.


Typedef Documentation

typedef unsigned char byte
 

Definition at line 213 of file q_shared.h.

typedef int clipHandle_t
 

Definition at line 220 of file q_shared.h.

typedef int fileHandle_t
 

Definition at line 219 of file q_shared.h.

typedef int qhandle_t
 

Definition at line 217 of file q_shared.h.

typedef int sfxHandle_t
 

Definition at line 218 of file q_shared.h.


Enumeration Type Documentation

enum cbufExec_t
 

Enumeration values:
EXEC_NOW 
EXEC_INSERT 
EXEC_APPEND 

Definition at line 264 of file q_shared.h.

00264              {
00265     EXEC_NOW,           // don't return until completed, a VM should NEVER use this,
00266                         // because some commands might cause the VM to be unloaded...
00267     EXEC_INSERT,        // insert at current position, but don't run yet
00268     EXEC_APPEND         // add to end of the command buffer (normal case)
00269 } cbufExec_t;

enum errorParm_t
 

Enumeration values:
ERR_NONE 
ERR_FATAL 
ERR_DROP 
ERR_DISCONNECT 
ERR_NEED_CD 

Definition at line 280 of file q_shared.h.

00280              {
00281     ERR_NONE,
00282     ERR_FATAL,                  // exit the entire game with a popup window
00283     ERR_DROP,                   // print to console and disconnect from game
00284     ERR_DISCONNECT,             // don't kill server
00285     ERR_NEED_CD                 // pop up the need-cd dialog
00286 } errorParm_t;

enum fsMode_t
 

Enumeration values:
FS_READ 
FS_WRITE 
FS_APPEND 
FS_APPEND_SYNC 

Definition at line 596 of file q_shared.h.

00596              {
00597     FS_READ,
00598     FS_WRITE,
00599     FS_APPEND,
00600     FS_APPEND_SYNC
00601 } fsMode_t;

enum fsOrigin_t
 

Enumeration values:
FS_SEEK_CUR 
FS_SEEK_END 
FS_SEEK_SET 

Definition at line 603 of file q_shared.h.

00603              {
00604     FS_SEEK_CUR,
00605     FS_SEEK_END,
00606     FS_SEEK_SET
00607 } fsOrigin_t;

enum jointHandle_t
 

Enumeration values:
INVALID_JOINT 

Definition at line 222 of file q_shared.h.

00222              {
00223     INVALID_JOINT = -1
00224 } jointHandle_t;

enum qboolean
 

Enumeration values:
qfalse 
qtrue 

Definition at line 211 of file q_shared.h.

00211 {qfalse, qtrue} qboolean;


Function Documentation

float BigFloat float  l  ) 
 

Definition at line 1052 of file l_cmd.c.

References _BigFloat, b, byte, in, and l.

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 }

int BigLong int  l  ) 
 

Definition at line 1035 of file l_cmd.c.

References _BigLong, byte, and l.

Referenced by ByteSwapTri(), LoadLBM(), Texture_InitPalette(), TRI_LoadPolysets(), and WriteLBMfile().

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 }

short BigShort short  l  ) 
 

Definition at line 1019 of file l_cmd.c.

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().

01020 {
01021     byte    b1,b2;
01022 
01023     b1 = l&255;
01024     b2 = (l>>8)&255;
01025 
01026     return (b1<<8) + b2;
01027 }

int Com_AddToGrowList growList_t list,
void *  data
 

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:

void Com_BeginParseSession const char *  filename  ) 
 

Definition at line 58 of file q_parse.cpp.

References Com_Error(), ERR_FATAL, parseInfo_t::lines, MAX_PARSE_INFO, parseInfo_t::parseFile, parseInfo, parseInfoNum, pi, and Q_strncpyz().

Referenced by idCameraDef::load().

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 }

Here is the call graph for this function:

float Com_Clamp float  min,
float  max,
float  value
 

Definition at line 26 of file q_shared.c.

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().

00026                                                      {
00027     if ( value < min ) {
00028         return min;
00029     }
00030     if ( value > max ) {
00031         return max;
00032     }
00033     return value;
00034 }

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

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:

void QDECL Com_DPrintf const char *  msg,
  ...
 

Definition at line 209 of file common.c.

References com_developer, Com_Printf(), cvar_s::integer, Q_vsnprintf, QDECL, va_end, va_list, and va_start.

Referenced by CIN_PlayCinematic(), CIN_StopCinematic(), CL_BeginDownload(), CL_ConnectionlessPacket(), CL_GetServerCommand(), CL_GetSnapshot(), CL_NextDemo(), CL_PacketEvent(), CL_ParseDownload(), CL_PlayCinematic_f(), CL_RefPrintf(), CL_ServerInfoPacket(), CL_ServersResponsePacket(), CL_UISystemCalls(), CL_WritePacket(), CM_AddFacetBevels(), CM_LoadMap(), CM_SetBorderInward(), Cmd_TokenizeString(), Com_AddToGrowList(), Cvar_Get(), Cvar_Set2(), FS_FOpenFileRead(), FS_PureServerSetLoadedPaks(), FS_ReadFile(), FS_SV_FOpenFileWrite(), GLimp_SetGamma(), MainWndProc(), RoQInterrupt(), RoQShutdown(), S_ChannelSetup(), S_FreeOldestSound(), S_GetSoundtime(), S_LoadSound(), S_RawSamples(), S_StartBackgroundTrack(), S_Update(), SCR_DrawScreenField(), SNDDMA_Init(), SNDDMA_InitDS(), SNDDMA_Shutdown(), SV_AddEntitiesVisibleFromPoint(), SV_CheckTimeouts(), SV_ClientCommand(), SV_ClientEnterWorld(), SV_ConnectionlessPacket(), SV_DirectConnect(), SV_DoneDownload_f(), SV_DropClient(), SV_ExecuteClientCommand(), SV_ExecuteClientMessage(), SV_GetChallenge(), SV_LinkEntity(), SV_Netchan_Transmit(), SV_Netchan_TransmitNextFragment(), SV_NextDownload_f(), SV_RankBegin(), SV_RankCleanupCBF(), SV_RankCloseContext(), SV_RankDecodePlayerID(), SV_RankDecodePlayerKey(), SV_RankEncodeGameID(), SV_RankEnd(), SV_RankError(), SV_RankJoinGameCBF(), SV_RankNewGameCBF(), SV_RankQuit(), SV_RankReportInt(), SV_RankReportStr(), SV_RankSendReportsCBF(), SV_RankUserCBF(), SV_RankUserCreate(), SV_RankUserLogin(), SV_RankUserLogout(), SV_RankUserValidate(), SV_SendClientGameState(), SV_StopDownload_f(), SV_UserMove(), SV_VerifyPaks_f(), SV_WriteDownloadToClient(), SV_WriteSnapshotToClient(), Sys_ConsoleInput(), and VID_AppActivate().

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 }

Here is the call graph for this function:

void Com_EndParseSession void   ) 
 

Definition at line 74 of file q_parse.cpp.

References Com_Error(), ERR_FATAL, parseInfo, parseInfoNum, and pi.

00074                                  {
00075     if ( parseInfoNum == 0 ) {
00076         Com_Error( ERR_FATAL, "Com_EndParseSession: session underflow" );
00077     }
00078     parseInfoNum--;
00079     pi = &parseInfo[parseInfoNum];
00080 }

Here is the call graph for this function:

void QDECL Com_Error int  level,
const char *  error,
  ...
 

Definition at line 444 of file cg_main.c.

References CG_Error(), error(), QDECL, Sys_Printf(), TranslateString(), va_end, va_list, va_start, and vsprintf().

Referenced by BaseWindingForPlane(), BG_CanItemBeGrabbed(), BG_EvaluateTrajectory(), BG_EvaluateTrajectoryDelta(), BG_FindItemForHoldable(), BG_FindItemForWeapon(), BotImport_HunkAlloc(), BotImport_Print(), Cbuf_ExecuteText(), CheckWinding(), ChopWindingInPlace(), CIN_HandleForVideo(), CL_AddReliableCommand(), CL_CgameError(), CL_CgameSystemCalls(), CL_CheckForResend(), CL_ConfigstringModified(), CL_Disconnect_f(), CL_GetParseEntityState(), CL_GetServerCommand(), CL_GetSnapshot(), CL_GetUserCmd(), CL_InitCGame(), CL_InitRef(), CL_InitUI(), CL_JoystickEvent(), CL_ParseDownload(), CL_ParseGamestate(), CL_ParsePacketEntities(), CL_ParseServerMessage(), CL_PlayDemo_f(), CL_ReadDemoMessage(), CL_SetCGameTime(), CL_UISystemCalls(), ClipWindingEpsilon(), CM_AdjustAreaPortalState(), CM_AreasConnected(), CM_ClipHandleToModel(), CM_EdgePlaneNum(), CM_FindPlane(), CM_FindPlane2(), CM_FloodArea_r(), CM_GeneratePatchCollide(), CM_InlineModel(), CM_LeafArea(), CM_LeafCluster(), CM_LoadMap(), CM_PatchCollideFromGrid(), CM_SetBorderInward(), CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadLeafSurfaces(), CMod_LoadNodes(), CMod_LoadPatches(), CMod_LoadPlanes(), CMod_LoadShaders(), CMod_LoadSubmodels(), Com_AddToGrowList(), Com_BeginParseSession(), Com_EndParseSession(), Com_Error_f(),