DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
 
common.h File Reference
#include <stdarg.h>
#include <assert.h>
#include "qtypes.h"
#include "qdefs.h"
#include "strings.h"
+ Include dependency graph for common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sizebuf_t
 

Macros

#define ContainerOf(ptr, type, member)
 MSVC has a different name for several standard functions.
 

Functions

unsigned Com_BlockChecksum (void *buffer, int length)
 
void Com_BlockFullChecksum (void *buffer, int len, unsigned char *outbuf)
 
unsigned char COM_BlockSequenceCRCByteQW (unsigned char *base, int length, int sequence)
 
void Com_HexDumpToConsole (const unsigned char *data, int size)
 
void COM_Init_Commands (void)
 
unsigned short CRC_Block (const unsigned char *data, size_t size)
 
unsigned short CRC_Block_CaseInsensitive (const unsigned char *data, size_t size)
 
void SZ_Clear (sizebuf_t *buf)
 
unsigned char * SZ_GetSpace (sizebuf_t *buf, int length)
 
void SZ_HexDumpToConsole (const sizebuf_t *buf)
 
void SZ_Write (sizebuf_t *buf, const unsigned char *data, int length)
 

Byte order functions.

#define BigFloat(l)
 
#define BigLong(l)
 
#define BigShort(l)
 
float BuffBigFloat (const unsigned char *buffer)
 Extract a big endian 32bit float from the given buffer.
 
int BuffBigLong (const unsigned char *buffer)
 Extract a big endian 32bit int from the given buffer.
 
short BuffBigShort (const unsigned char *buffer)
 Extract a big endian 16bit short from the given buffer.
 
float BuffLittleFloat (const unsigned char *buffer)
 Extract a little endian 32bit float from the given buffer.
 
int BuffLittleLong (const unsigned char *buffer)
 Extract a little endian 32bit int from the given buffer.
 
short BuffLittleShort (const unsigned char *buffer)
 Extract a little endian 16bit short from the given buffer.
 
#define LittleFloat(l)
 
#define LittleLong(l)
 
#define LittleShort(l)
 
enum  protocolversion_t {
  PROTOCOL_UNKNOWN , PROTOCOL_DARKPLACES8 , PROTOCOL_DARKPLACES7 , PROTOCOL_DARKPLACES6 ,
  PROTOCOL_DARKPLACES5 , PROTOCOL_DARKPLACES4 , PROTOCOL_DARKPLACES3 , PROTOCOL_DARKPLACES2 ,
  PROTOCOL_DARKPLACES1 , PROTOCOL_QUAKEDP , PROTOCOL_NEHAHRAMOVIE , PROTOCOL_QUAKE ,
  PROTOCOL_QUAKEWORLD , PROTOCOL_NEHAHRABJP , PROTOCOL_NEHAHRABJP2 , PROTOCOL_NEHAHRABJP3
}
 
void StoreBigLong (unsigned char *buffer, unsigned int i)
 Encode a big endian 32bit int to the given buffer.
 
void StoreBigShort (unsigned char *buffer, unsigned short i)
 Encode a big endian 16bit int to the given buffer.
 
void StoreLittleLong (unsigned char *buffer, unsigned int i)
 Encode a little endian 32bit int to the given buffer.
 
void StoreLittleShort (unsigned char *buffer, unsigned short i)
 Encode a little endian 16bit int to the given buffer.
 

Message IO functions.

Handles byte ordering and avoids alignment errors

#define ARRAY_SIZE(a)
 
size_t base64_encode (unsigned char *buf, size_t buflen, size_t outbuflen)
 
struct cvar_s cmdline
 
float Com_CalcRoll (const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval)
 
void COM_Init (void)
 
typedef int(* COM_LineProcessorFunc) (void *passthrough, const char *line, size_t length, float width, qbool isContination)
 
qbool COM_ParseToken_Console (const char **datapointer)
 
qbool COM_ParseToken_QuakeC (const char **datapointer, qbool returnnewline)
 
qbool COM_ParseToken_Simple (const char **datapointer, qbool returnnewline, qbool parsebackslash, qbool parsecomments)
 
qbool COM_ParseToken_VM_Tokenize (const char **datapointer, qbool returnnewline)
 
int COM_ReadAndTokenizeLine (const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize, const char *commentprefix)
 
void COM_Shutdown (void)
 
int COM_StringBeginsWith (const char *s, const char *match)
 
size_t COM_StringDecolorize (const char *in, size_t size_in, char *out, size_t size_out, qbool escape_carets)
 
size_t COM_StringLengthNoColors (const char *s, size_t size_s, qbool *valid)
 
char com_token [MAX_INPUTLINE]
 
unsigned com_token_len
 
size_t COM_ToLowerString (const char *in, char *out, size_t size_out)
 Returns the number of bytes written to *out excluding the \0 terminator.
 
size_t COM_ToUpperString (const char *in, char *out, size_t size_out)
 Returns the number of bytes written to *out excluding the \0 terminator.
 
typedef float(* COM_WordWidthFunc_t) (void *passthrough, const char *w, size_t *length, float maxWidth)
 
int COM_Wordwrap (const char *string, size_t length, float continuationSize, float maxWidth, COM_WordWidthFunc_t wordWidth, void *passthroughCW, COM_LineProcessorFunc processLine, void *passthroughPL)
 
size_t dp__strlcat (char *dst, const char *src, size_t dsize, const char *func, unsigned line)
 Catenates a string, like strlcat() but with a better return: the number of bytes copied excluding the \0 terminator.
 
size_t dp__strlcpy (char *dst, const char *src, size_t dsize, const char *func, unsigned line)
 Copies a string, like strlcpy() but with a better return: the number of bytes copied excluding the \0 terminator.
 
#define DP_STATIC_ASSERT(expr, str)
 
char * dp_stpecpy (char *dst, char *end, const char *src)
 Chain-copies a string with truncation and efficiency (compared to strlcat()).
 
#define dp_strlcat(dst, src, dsize)
 
#define dp_strlcpy(dst, src, dsize)
 
char * dp_ustr2stp (char *dst, size_t dsize, const char *src, size_t slen)
 Copies a measured byte sequence (unterminated string) to a null-terminated string.
 
int dpsnprintf (char *buffer, size_t buffersize, const char *format,...) DP_FUNC_PRINTF(3)
 Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't big enough to contain the entire string.
 
int dpvsnprintf (char *buffer, size_t buffersize, const char *format, va_list args)
 Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't big enough to contain the entire string.
 
void FindFraction (double val, int *num, int *denom, int denomMax)
 
void MSG_BeginReading (sizebuf_t *sb)
 
void MSG_InitReadBuffer (sizebuf_t *buf, unsigned char *data, int size)
 
float MSG_ReadAngle (sizebuf_t *sb, protocolversion_t protocol)
 
float MSG_ReadAngle16i (sizebuf_t *sb)
 
float MSG_ReadAngle32f (sizebuf_t *sb)
 
float MSG_ReadAngle8i (sizebuf_t *sb)
 
float MSG_ReadBigFloat (sizebuf_t *sb)
 
int MSG_ReadBigLong (sizebuf_t *sb)
 
int MSG_ReadBigShort (sizebuf_t *sb)
 
#define MSG_ReadByte(sb)
 
#define MSG_ReadByte_opt(sb)
 Same as MSG_ReadByte but with no need to copy twice (first to int to check for -1) so each byte can be copied directly to a string[].
 
size_t MSG_ReadBytes (sizebuf_t *sb, size_t numbytes, unsigned char *out)
 
#define MSG_ReadChar(sb)
 
float MSG_ReadCoord (sizebuf_t *sb, protocolversion_t protocol)
 
float MSG_ReadCoord13i (sizebuf_t *sb)
 
float MSG_ReadCoord16i (sizebuf_t *sb)
 
float MSG_ReadCoord32f (sizebuf_t *sb)
 
#define MSG_ReadFloat   MSG_ReadLittleFloat
 
float MSG_ReadLittleFloat (sizebuf_t *sb)
 
int MSG_ReadLittleLong (sizebuf_t *sb)
 
int MSG_ReadLittleShort (sizebuf_t *sb)
 
#define MSG_ReadLong   MSG_ReadLittleLong
 
#define MSG_ReadShort   MSG_ReadLittleShort
 
char * MSG_ReadString (sizebuf_t *sb, char *string, size_t maxstring)
 
size_t MSG_ReadString_len (sizebuf_t *sb, char *string, size_t maxstring)
 Same as MSG_ReadString except it returns the number of bytes written to *string excluding the \0 terminator.
 
void MSG_ReadVector (sizebuf_t *sb, vec3_t v, protocolversion_t protocol)
 
void MSG_WriteAngle (sizebuf_t *sb, vec_t f, protocolversion_t protocol)
 
void MSG_WriteAngle16i (sizebuf_t *sb, vec_t f)
 
void MSG_WriteAngle32f (sizebuf_t *sb, vec_t f)
 
void MSG_WriteAngle8i (sizebuf_t *sb, vec_t f)
 
void MSG_WriteByte (sizebuf_t *sb, int c)
 
void MSG_WriteChar (sizebuf_t *sb, int c)
 
void MSG_WriteCoord (sizebuf_t *sb, vec_t f, protocolversion_t protocol)
 
void MSG_WriteCoord13i (sizebuf_t *sb, vec_t f)
 
void MSG_WriteCoord16i (sizebuf_t *sb, vec_t f)
 
void MSG_WriteCoord32f (sizebuf_t *sb, vec_t f)
 
void MSG_WriteFloat (sizebuf_t *sb, vec_t f)
 
void MSG_WriteLong (sizebuf_t *sb, int c)
 
void MSG_WriteShort (sizebuf_t *sb, int c)
 
void MSG_WriteString (sizebuf_t *sb, const char *s)
 
void MSG_WriteUnterminatedString (sizebuf_t *sb, const char *s)
 
void MSG_WriteVector (sizebuf_t *sb, const vec3_t v, protocolversion_t protocol)
 
struct cvar_s registered
 
#define snprintf   DP_STATIC_ASSERT(0, "snprintf is forbidden for portability reasons. Use dpsnprintf instead.")
 
#define sprintf   DP_STATIC_ASSERT(0, "sprintf is forbidden for security reasons. Use dpsnprintf instead.")
 
#define stpcpy   DP_STATIC_ASSERT(0, "stpcpy is forbidden for security reasons. Use dp_stpecpy or memcpy instead.")
 
#define strcat   DP_STATIC_ASSERT(0, "strcat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")
 
#define strcpy   DP_STATIC_ASSERT(0, "strcpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")
 
#define strlcat   DP_STATIC_ASSERT(0, "strlcat is forbidden for stability and correctness. See common.h and common.c comments.")
 
#define strlcpy   DP_STATIC_ASSERT(0, "strlcpy is forbidden for stability and correctness. See common.h and common.c comments.")
 
#define strncat   DP_STATIC_ASSERT(0, "strncat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")
 
#define strncpy   DP_STATIC_ASSERT(0, "strncpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")
 
enum  userdirmode_t {
  USERDIRMODE_NOHOME , USERDIRMODE_HOME , USERDIRMODE_MYGAMES , USERDIRMODE_SAVEDGAMES ,
  USERDIRMODE_COUNT
}
 
#define ustpcpy   DP_STATIC_ASSERT(0, "ustpcpy is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")
 
#define ustr2stp   DP_STATIC_ASSERT(0, "ustr2stp is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")
 
char * va (char *buf, size_t buflen, const char *format,...) DP_FUNC_PRINTF(3)
 
#define vsnprintf   DP_STATIC_ASSERT(0, "vsnprintf is forbidden for portability reasons. Use dpvsnprintf instead.")
 
char ** XPM_DecodeString (const char *in)
 

Macro Definition Documentation

◆ ARRAY_SIZE

#define ARRAY_SIZE ( a)
Value:
(sizeof(a) / sizeof((a)[0]))
ret a

Definition at line 318 of file common.h.

Referenced by Sys_SDL_HandleEvents().

◆ BigFloat

#define BigFloat ( l)
Value:
BuffBigFloat((unsigned char *)&(l))
float BuffBigFloat(const unsigned char *buffer)
Extract a big endian 32bit float from the given buffer.
Definition com_msg.c:37

Definition at line 93 of file common.h.

Referenced by Mod_DARKPLACESMODEL_Load(), and Mod_ZYMOTICMODEL_Load().

◆ BigLong

#define BigLong ( l)
Value:
BuffBigLong((unsigned char *)&(l))
int BuffBigLong(const unsigned char *buffer)
Extract a big endian 32bit int from the given buffer.
Definition com_msg.c:49

Definition at line 91 of file common.h.

Referenced by Mod_DARKPLACESMODEL_Load(), and Mod_ZYMOTICMODEL_Load().

◆ BigShort

#define BigShort ( l)
Value:
BuffBigShort((unsigned char *)&(l))
short BuffBigShort(const unsigned char *buffer)
Extract a big endian 16bit short from the given buffer.
Definition com_msg.c:54

Definition at line 89 of file common.h.

◆ ContainerOf

#define ContainerOf ( ptr,
type,
member )
Value:
((type *)((char *)(ptr) - offsetof(type, member)))
GLenum type
Definition glquake.h:656

MSVC has a different name for several standard functions.

Definition at line 46 of file common.h.

◆ DP_STATIC_ASSERT

#define DP_STATIC_ASSERT ( expr,
str )
Value:
_Static_assert(expr, str)

Definition at line 231 of file common.h.

◆ dp_strlcat

◆ dp_strlcpy

#define dp_strlcpy ( dst,
src,
dsize )
Value:
dp__strlcpy(dst, src, dsize, __func__, __LINE__)
size_t dp__strlcpy(char *dst, const char *src, size_t dsize, const char *func, unsigned line)
Copies a string, like strlcpy() but with a better return: the number of bytes copied excluding the \0...
Definition common.c:1406

Definition at line 303 of file common.h.

Referenced by _Mem_AllocPool(), _Mem_strdup(), CD_f(), CDAudio_StartPlaylist(), CL_AllocLightFlash(), CL_DisconnectEx(), CL_DownloadBegin_f(), CL_EstablishConnection(), CL_Fog_HeightTexture_f(), CL_FullInfo_f(), CL_FullServerinfo_f(), CL_IPLog_Add(), CL_Locs_FindLocationName(), CL_ParseEntityLump(), CL_ParseServerInfo(), CL_ParseServerMessage(), CL_Particles_LoadEffectInfo(), CL_Particles_ParseEffectInfo(), CL_PlayDemo(), CL_Rcon_f(), CL_Record_f(), CL_SetupWorldModel(), CL_Startdemos_f(), Cmd_Alias_f(), COM_InsertFlags(), COM_SetGameType(), CompressedImageCache_Add(), Con_CompleteCommandLine(), Con_DrawInput(), Crypto_ClientParsePacket(), Crypto_RetrieveHostKey(), Crypto_RetrieveLocalKey(), Crypto_ServerParsePacket_Internal(), Curl_Begin(), Curl_CommandWhenDone(), Curl_CommandWhenError(), Curl_EndDownload(), Curl_FindPackURL(), Curl_GetDownloadInfo(), Curl_RequireFile(), Draw_CachePic_Flags(), Draw_NewPic(), FindFont(), Font_LoadFile(), Font_LoadFont(), fontfilecache_LoadFile(), FS_AddFileToPack(), FS_AddGameDirectory(), FS_AddPack_Fullpath(), FS_ChooseUserDir(), FS_Init_Dir(), FS_ListGameDirs(), FS_LoadPackPAK(), FS_LoadPackPK3FromFD(), FS_LoadPackVirtual(), FS_Rescan(), FS_Search(), FS_SetGameDirs(), GetMapList(), GL_Draw_Init(), Host_Error(), Image_StripImageExtension(), IN_BestWeapon_Register(), InfoString_SetValue(), Key_History_Down(), Key_History_Find_Backwards(), Key_History_Find_Forwards(), Key_History_First(), Key_History_Get_foundCommand(), Key_History_Last(), Key_History_Up(), Key_Parse_CommonKeys(), LoadFont(), LoadFont_f(), loadimagepixelsbgra(), Log_Open(), M_Keys_Draw(), M_Menu_Setup_f(), M_ScanSaves(), Mod_BrushInit(), Mod_Decompile_f(), Mod_Decompile_OBJ(), Mod_FindName(), Mod_FrameGroupify_ParseGroups(), Mod_FrameGroupify_ParseGroups_Store(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_LoadCustomMaterial(), Mod_LoadQ3Shaders(), Mod_LoadSkinFiles(), Mod_LoadTextureFromQ3Shader(), Mod_MDL_LoadFrames(), Mod_Mesh_Create(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q1BSP_LoadLighting(), Mod_Q1BSP_LoadTextures(), Mod_Q1BSP_ParseWadsFromEntityLump(), Mod_Q2BSP_Load(), Mod_Q3BSP_Load(), Mod_Q3BSP_LoadEffects(), Mod_Q3BSP_LoadEntities(), Mod_UnloadModel(), ModList_RebuildList(), NetConn_BuildStatusResponse(), NetConn_ClientFrame(), NetConn_ClientParsePacket(), NetConn_ConnectionEstablished(), NetConn_ServerParsePacket(), Nicks_CompleteCountPossible(), Nicks_CutMatchesAlphaNumeric(), Nicks_CutMatchesNoSpaces(), OpenVideo(), PRVM_Breakpoint_f(), PRVM_ED_ParseEdict(), PRVM_ED_ParseGlobals(), PRVM_EdictWatchpoint_f(), PRVM_GlobalWatchpoint_f(), PRVM_ShortStackTrace(), PRVM_UglyValueString(), PRVM_ValueString(), QW_CL_CheckOrDownloadFile(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_ProcessUserInfo(), QW_CL_ServerInfo(), QW_CL_SetInfo(), QW_CL_UpdateUserInfo(), R_BuildFogHeightTexture(), R_Envmap_f(), R_GetCubemap(), R_InitParticleTexture(), R_LoadQWSkin(), R_LoadTextureDDSFile(), R_LoadTextureRenderBuffer(), R_Mesh_CreateMeshBuffer(), R_RTLight_Update(), R_SetSkyBox(), R_SetupTexture(), R_Shadow_EditLights_CopyInfo_f(), R_Shadow_EditLights_Edit_f(), R_Shadow_EditLights_Reload_f(), R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(), R_Shadow_UpdateWorldLight(), R_SkinFrame_Find(), S_FindName(), S_Play_Common(), Sbar_ShowFPS(), Sbar_SortFrags(), SCR_CenterPrint(), SCR_Centerprint_f(), SCR_DrawScreen(), SCR_InfoBar_f(), SCR_PushLoadingScreen(), SCR_ScreenShot_f(), SHOWLMP_decodeshow(), SV_ConnectClient(), SV_Download_f(), SV_Loadgame_f(), SV_ModelIndex(), SV_Name(), SV_Name_f(), SV_ParticleEffectIndex(), SV_Playermodel_f(), SV_Playerskin_f(), SV_Prepare_CSQC(), SV_Savegame_f(), SV_SoundIndex(), SV_SpawnServer(), SV_StartDemoRecording(), SV_Status_f(), SV_UpdateToReliableMessages(), SV_WriteClientdataToMessage(), Sys_HandleCrash(), Sys_LoadDependency(), Sys_SDL_GetClipboardData(), VM_altstr_ins(), VM_altstr_set(), VM_bufstr_find(), VM_CL_getplayerkey(), VM_CL_getstats(), VM_CL_lightstyle(), VM_CL_R_PolygonBegin(), VM_infoadd(), VM_loadfont(), VM_M_setserverlistmaskstring(), VM_matchpattern(), VM_SV_lightstyle(), VM_SV_UpdateCustomStats(), VM_tokenize(), VM_tokenize_console(), VM_tokenizebyseparator(), VM_uri_get(), World_SetSize(), and XPM_DecodeString().

◆ LittleFloat

#define LittleFloat ( l)
Value:
BuffLittleFloat((unsigned char *)&(l))
float BuffLittleFloat(const unsigned char *buffer)
Extract a little endian 32bit float from the given buffer.
Definition com_msg.c:59

Definition at line 94 of file common.h.

Referenced by CL_ReadDemoMessage(), CL_WriteDemoMessage(), Mod_IDP0_Load(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_MDL_LoadFrames(), Mod_PSKMODEL_Load(), Mod_Q3BSP_LoadFaces(), Mod_Q3BSP_LoadModels(), Mod_Q3BSP_LoadPlanes(), Mod_Q3BSP_LoadVertices(), Mod_Sprite_SharedSetup(), and SV_WriteDemoMessage().

◆ LittleLong

◆ LittleShort

#define LittleShort ( l)
Value:
BuffLittleShort((unsigned char *)&(l))
short BuffLittleShort(const unsigned char *buffer)
Extract a little endian 16bit short from the given buffer.
Definition com_msg.c:76

Definition at line 90 of file common.h.

Referenced by LoadPCX_BGRA(), LoadPCX_QWSkin(), Mod_IDP2_Load(), Mod_IDP3_Load(), Mod_INTERQUAKEMODEL_Load(), Mod_PSKMODEL_Load(), NetConn_SendUnreliableMessage(), PK3_GetEndOfCentralDir(), and PRVM_Prog_Load().

◆ MSG_ReadByte

◆ MSG_ReadByte_opt

#define MSG_ReadByte_opt ( sb)
Value:
((sb)->readcount >= (sb)->cursize ? ((sb)->badread = true, '\0') : (unsigned char)(sb)->data[(sb)->readcount++])

Same as MSG_ReadByte but with no need to copy twice (first to int to check for -1) so each byte can be copied directly to a string[].

Definition at line 190 of file common.h.

Referenced by MSG_ReadBytes(), MSG_ReadString(), and MSG_ReadString_len().

◆ MSG_ReadChar

#define MSG_ReadChar ( sb)
Value:
((sb)->readcount >= (sb)->cursize ? ((sb)->badread = true, -1) : (signed char)(sb)->data[(sb)->readcount++])

Definition at line 187 of file common.h.

Referenced by CL_ParseClientdata(), CL_ParseParticleEffect(), CL_ParseStartSoundPacket(), CL_ParseTempEntity(), and VM_CL_ReadChar().

◆ MSG_ReadFloat

◆ MSG_ReadLong

◆ MSG_ReadShort

◆ snprintf

#define snprintf   DP_STATIC_ASSERT(0, "snprintf is forbidden for portability reasons. Use dpsnprintf instead.")

Definition at line 238 of file common.h.

Referenced by dpvsnprintf().

◆ sprintf

#define sprintf   DP_STATIC_ASSERT(0, "sprintf is forbidden for security reasons. Use dpsnprintf instead.")

Definition at line 269 of file common.h.

Referenced by main().

◆ stpcpy

#define stpcpy   DP_STATIC_ASSERT(0, "stpcpy is forbidden for security reasons. Use dp_stpecpy or memcpy instead.")

Definition at line 263 of file common.h.

◆ strcat

#define strcat   DP_STATIC_ASSERT(0, "strcat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")

Definition at line 255 of file common.h.

Referenced by float().

◆ strcpy

#define strcpy   DP_STATIC_ASSERT(0, "strcpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")

Definition at line 259 of file common.h.

◆ strlcat

#define strlcat   DP_STATIC_ASSERT(0, "strlcat is forbidden for stability and correctness. See common.h and common.c comments.")

Definition at line 274 of file common.h.

Referenced by Mod_Q1BSP_LoadMapBrushes().

◆ strlcpy

#define strlcpy   DP_STATIC_ASSERT(0, "strlcpy is forbidden for stability and correctness. See common.h and common.c comments.")

Definition at line 272 of file common.h.

Referenced by Mod_Q1BSP_LoadMapBrushes().

◆ strncat

#define strncat   DP_STATIC_ASSERT(0, "strncat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")

Definition at line 257 of file common.h.

◆ strncpy

#define strncpy   DP_STATIC_ASSERT(0, "strncpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")

Definition at line 261 of file common.h.

◆ ustpcpy

#define ustpcpy   DP_STATIC_ASSERT(0, "ustpcpy is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")

Definition at line 265 of file common.h.

◆ ustr2stp

#define ustr2stp   DP_STATIC_ASSERT(0, "ustr2stp is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")

Definition at line 267 of file common.h.

◆ vsnprintf

#define vsnprintf   DP_STATIC_ASSERT(0, "vsnprintf is forbidden for portability reasons. Use dpvsnprintf instead.")

Definition at line 240 of file common.h.

Referenced by dpvsnprintf().

Typedef Documentation

◆ COM_LineProcessorFunc

typedef int(* COM_LineProcessorFunc) (void *passthrough, const char *line, size_t length, float width, qbool isContination)

Definition at line 208 of file common.h.

◆ COM_WordWidthFunc_t

typedef float(* COM_WordWidthFunc_t) (void *passthrough, const char *w, size_t *length, float maxWidth)

Definition at line 207 of file common.h.

Enumeration Type Documentation

◆ protocolversion_t

Enumerator
PROTOCOL_UNKNOWN 
PROTOCOL_DARKPLACES8 

added parting messages. WIP

PROTOCOL_DARKPLACES7 

added QuakeWorld-style movement protocol to allow more consistent prediction

PROTOCOL_DARKPLACES6 

various changes

PROTOCOL_DARKPLACES5 

uses EntityFrame5 entity snapshot encoder/decoder which is based on a Tribes networking article at http://www.garagegames.com/articles/networking1/

PROTOCOL_DARKPLACES4 

various changes

PROTOCOL_DARKPLACES3 

uses EntityFrame4 entity snapshot encoder/decoder which is broken, this attempted to do partial snapshot updates on a QuakeWorld-like protocol, but it is broken and impossible to fix

PROTOCOL_DARKPLACES2 

various changes

PROTOCOL_DARKPLACES1 

uses EntityFrame entity snapshot encoder/decoder which is a QuakeWorld-like entity snapshot delta compression method

PROTOCOL_QUAKEDP 

darkplaces extended quake protocol (used by TomazQuake and others), backwards compatible as long as no extended features are used

PROTOCOL_NEHAHRAMOVIE 

Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but only ever used by neh_gl.exe), this is potentially backwards compatible with quake protocol as long as no extended features are used (but in actuality the neh_gl.exe which wrote this protocol ALWAYS wrote the extended information)

PROTOCOL_QUAKE 

quake (aka netquake/normalquake/nq) protocol

PROTOCOL_QUAKEWORLD 

quakeworld protocol

PROTOCOL_NEHAHRABJP 

same as QUAKEDP but with 16bit modelindex

PROTOCOL_NEHAHRABJP2 

same as NEHAHRABJP but with 16bit soundindex

PROTOCOL_NEHAHRABJP3 

same as NEHAHRABJP2 but with some changes

Definition at line 131 of file common.h.

132{
149}
@ PROTOCOL_DARKPLACES2
various changes
Definition common.h:140
@ PROTOCOL_DARKPLACES4
various changes
Definition common.h:138
@ PROTOCOL_NEHAHRABJP2
same as NEHAHRABJP but with 16bit soundindex
Definition common.h:147
@ PROTOCOL_DARKPLACES3
uses EntityFrame4 entity snapshot encoder/decoder which is broken, this attempted to do partial snaps...
Definition common.h:139
@ PROTOCOL_NEHAHRABJP
same as QUAKEDP but with 16bit modelindex
Definition common.h:146
@ PROTOCOL_DARKPLACES5
uses EntityFrame5 entity snapshot encoder/decoder which is based on a Tribes networking article at ht...
Definition common.h:137
@ PROTOCOL_DARKPLACES7
added QuakeWorld-style movement protocol to allow more consistent prediction
Definition common.h:135
@ PROTOCOL_QUAKEDP
darkplaces extended quake protocol (used by TomazQuake and others), backwards compatible as long as n...
Definition common.h:142
@ PROTOCOL_UNKNOWN
Definition common.h:133
@ PROTOCOL_DARKPLACES6
various changes
Definition common.h:136
@ PROTOCOL_QUAKE
quake (aka netquake/normalquake/nq) protocol
Definition common.h:144
@ PROTOCOL_DARKPLACES8
added parting messages. WIP
Definition common.h:134
@ PROTOCOL_NEHAHRABJP3
same as NEHAHRABJP2 but with some changes
Definition common.h:148
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
Definition common.h:143
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
Definition common.h:145
@ PROTOCOL_DARKPLACES1
uses EntityFrame entity snapshot encoder/decoder which is a QuakeWorld-like entity snapshot delta com...
Definition common.h:141

◆ userdirmode_t

Enumerator
USERDIRMODE_NOHOME 
USERDIRMODE_HOME 
USERDIRMODE_MYGAMES 
USERDIRMODE_SAVEDGAMES 
USERDIRMODE_COUNT 

Definition at line 282 of file common.h.

283{
284 USERDIRMODE_NOHOME, // basedir only
285 USERDIRMODE_HOME, // Windows basedir, general POSIX (~/.)
286 USERDIRMODE_MYGAMES, // pre-Vista (My Documents/My Games/), general POSIX (~/.)
287 USERDIRMODE_SAVEDGAMES, // Vista (%USERPROFILE%/Saved Games/), OSX (~/Library/Application Support/), Linux (~/.config)
289}
@ USERDIRMODE_SAVEDGAMES
Definition common.h:287
@ USERDIRMODE_NOHOME
Definition common.h:284
@ USERDIRMODE_COUNT
Definition common.h:288
@ USERDIRMODE_MYGAMES
Definition common.h:286
@ USERDIRMODE_HOME
Definition common.h:285

Function Documentation

◆ base64_encode()

size_t base64_encode ( unsigned char * buf,
size_t buflen,
size_t outbuflen )

Definition at line 1502 of file common.c.

1503{
1504 size_t blocks, i;
1505 // expand the out-buffer
1506 blocks = (buflen + 2) / 3;
1507 if(blocks*4 > outbuflen)
1508 return 0;
1509 for(i = blocks; i > 0; )
1510 {
1511 --i;
1512 base64_3to4(buf + 3*i, buf + 4*i, (int)(buflen - 3*i));
1513 }
1514 return blocks * 4;
1515}
static void base64_3to4(const unsigned char *in, unsigned char *out, int bytes)
Definition common.c:1487
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition glquake.h:657
int i

References base64_3to4(), buf, and i.

Referenced by Crypto_KeyGen_f(), and VM_uri_get().

◆ BuffBigFloat()

float BuffBigFloat ( const unsigned char * buffer)

Extract a big endian 32bit float from the given buffer.

Definition at line 37 of file com_msg.c.

38{
39 union
40 {
41 float f;
42 unsigned int i;
43 }
44 u;
45 u.i = ((unsigned)buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
46 return u.f;
47}
GLuint buffer
Definition glquake.h:630
float f

References buffer, f, and i.

◆ BuffBigLong()

int BuffBigLong ( const unsigned char * buffer)

Extract a big endian 32bit int from the given buffer.

Definition at line 49 of file com_msg.c.

50{
51 return ((unsigned)buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
52}

References buffer.

Referenced by Crypto_DecryptPacket(), Crypto_EncryptPacket(), NetConn_ClientParsePacket(), NetConn_ReceivedMessage(), NetConn_ServerParsePacket(), PK3_BuildFileList(), PK3_GetEndOfCentralDir(), and PK3_GetTrueFileOffset().

◆ BuffBigShort()

short BuffBigShort ( const unsigned char * buffer)

Extract a big endian 16bit short from the given buffer.

Definition at line 54 of file com_msg.c.

55{
56 return (buffer[0] << 8) | buffer[1];
57}

References buffer.

◆ BuffLittleFloat()

float BuffLittleFloat ( const unsigned char * buffer)

Extract a little endian 32bit float from the given buffer.

Definition at line 59 of file com_msg.c.

60{
61 union
62 {
63 float f;
64 unsigned int i;
65 }
66 u;
67 u.i = ((unsigned)buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
68 return u.f;
69}

References buffer, f, and i.

◆ BuffLittleLong()

int BuffLittleLong ( const unsigned char * buffer)

Extract a little endian 32bit int from the given buffer.

Definition at line 71 of file com_msg.c.

72{
73 return ((unsigned)buffer[3] << 24) | (buffer[2] << 16) | (buffer[1] << 8) | buffer[0];
74}

References buffer.

Referenced by Crypto_ClientParsePacket(), GetLittleLong(), GetMapList(), Mod_Q1BSP_LoadFaces(), PK3_BuildFileList(), and R_LoadTextureDDSFile().

◆ BuffLittleShort()

short BuffLittleShort ( const unsigned char * buffer)

Extract a little endian 16bit short from the given buffer.

Definition at line 76 of file com_msg.c.

77{
78 return (buffer[1] << 8) | buffer[0];
79}

References buffer.

Referenced by GetLittleShort(), Mod_Q1BSP_LoadFaces(), Mod_VBSP_LoadFaces(), PK3_BuildFileList(), and PK3_GetTrueFileOffset().

◆ Com_BlockChecksum()

unsigned Com_BlockChecksum ( void * buffer,
int length )

Definition at line 198 of file mdfour.c.

199{
200 int digest[4];
201 unsigned val;
202
203 mdfour ( (unsigned char *) digest, (unsigned char *) buffer, length );
204
205 val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];
206
207 return val;
208}
GLenum GLuint GLenum GLsizei length
Definition glquake.h:657
void mdfour(unsigned char *out, const unsigned char *in, int n)
Definition mdfour.c:182

References buffer, length, and mdfour().

Referenced by Mod_Q1BSP_Load(), Mod_Q2BSP_Load(), and Mod_Q3BSP_Load().

◆ Com_BlockFullChecksum()

void Com_BlockFullChecksum ( void * buffer,
int len,
unsigned char * outbuf )

Definition at line 210 of file mdfour.c.

211{
212 mdfour ( outbuf, (unsigned char *) buffer, len );
213}

References buffer, and mdfour().

◆ COM_BlockSequenceCRCByteQW()

unsigned char COM_BlockSequenceCRCByteQW ( unsigned char * base,
int length,
int sequence )

Definition at line 132 of file com_crc16.c.

133{
134 const unsigned char *p;
135 unsigned char chkb[60 + 4];
136
137 p = chktbl + (sequence % (sizeof(chktbl) - 8));
138
139 if (length > 60)
140 length = 60;
141 memcpy(chkb, base, length);
142
143 chkb[length] = (sequence & 0xff) ^ p[0];
144 chkb[length+1] = p[1];
145 chkb[length+2] = ((sequence>>8) & 0xff) ^ p[2];
146 chkb[length+3] = p[3];
147
148 return CRC_Block(chkb, length + 4) & 0xff;
149}
unsigned short CRC_Block(const unsigned char *data, size_t size)
Definition com_crc16.c:75
static const u8 chktbl[1024+4]
Definition com_crc16.c:92

References chktbl, CRC_Block(), and length.

Referenced by CL_SendMove().

◆ Com_CalcRoll()

float Com_CalcRoll ( const vec3_t angles,
const vec3_t velocity,
const vec_t angleval,
const vec_t velocityval )

Definition at line 890 of file common.c.

891{
893 float sign;
894 float side;
895
897 side = DotProduct (velocity, right);
898 sign = side < 0 ? -1 : 1;
899 side = fabs(side);
900
901 if (side < velocityval)
902 side = side * angleval / velocityval;
903 else
904 side = angleval;
905
906 return side*sign;
907
908}
vector velocity
vector angles
void AngleVectors(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
Definition mathlib.c:444
#define DotProduct(a, b)
Definition mathlib.h:98
float fabs(float f)
vec_t vec3_t[3]
Definition qtypes.h:71
static vec3_t forward
Definition sv_user.c:305
static vec3_t right
Definition sv_user.c:305
static vec3_t up
Definition sv_user.c:305

References angles, AngleVectors(), DotProduct, fabs(), forward, right, up, and velocity.

Referenced by EntityStateQW_ReadPlayerUpdate(), SV_PlayerPhysics(), and V_CalcRefdefUsing().

◆ Com_HexDumpToConsole()

void Com_HexDumpToConsole ( const unsigned char * data,
int size )

Definition at line 82 of file common.c.

83{
84 int i, j, n;
85 char text[1024];
86 char *cur, *flushpointer;
87 const unsigned char *d;
88 cur = text;
89 flushpointer = text + 512;
90 for (i = 0;i < size;)
91 {
92 n = 16;
93 if (n > size - i)
94 n = size - i;
95 d = data + i;
96 // print offset
97 *cur++ = hexchar[(i >> 12) & 15];
98 *cur++ = hexchar[(i >> 8) & 15];
99 *cur++ = hexchar[(i >> 4) & 15];
100 *cur++ = hexchar[(i >> 0) & 15];
101 *cur++ = ':';
102 // print hex
103 for (j = 0;j < 16;j++)
104 {
105 if (j < n)
106 {
107 *cur++ = hexchar[(d[j] >> 4) & 15];
108 *cur++ = hexchar[(d[j] >> 0) & 15];
109 }
110 else
111 {
112 *cur++ = ' ';
113 *cur++ = ' ';
114 }
115 if ((j & 3) == 3)
116 *cur++ = ' ';
117 }
118 // print text
119 for (j = 0;j < 16;j++)
120 {
121 if (j < n)
122 {
123 // color change prefix character has to be treated specially
124 if (d[j] == STRING_COLOR_TAG)
125 {
126 *cur++ = STRING_COLOR_TAG;
127 *cur++ = STRING_COLOR_TAG;
128 }
129 else if (d[j] >= (unsigned char) ' ')
130 *cur++ = d[j];
131 else
132 *cur++ = '.';
133 }
134 else
135 *cur++ = ' ';
136 }
137 *cur++ = '\n';
138 i += n;
139 if (cur >= flushpointer || i >= size)
140 {
141 *cur++ = 0;
142 Con_Print(text);
143 cur = text;
144 }
145 }
146}
static const char * hexchar
Definition common.c:81
void Con_Print(const char *msg)
Prints to all appropriate console targets, and adds timestamps.
Definition console.c:1504
vector size
#define STRING_COLOR_TAG
Definition draw.h:140
#define n(x, y)
GLsizeiptr const GLvoid * data
Definition glquake.h:639

References Con_Print(), data, hexchar, i, n, size, and STRING_COLOR_TAG.

Referenced by Crypto_DecryptPacket(), Crypto_EncryptPacket(), Crypto_KeyGen_Finished(), NetConn_ClientParsePacket(), NetConn_Read(), NetConn_ServerParsePacket(), NetConn_Write(), SV_ReadClientMessage(), and SZ_HexDumpToConsole().

◆ COM_Init()

void COM_Init ( void )

◆ COM_Init_Commands()

void COM_Init_Commands ( void )

Definition at line 917 of file common.c.

918{
919 int i, j, n;
920 char com_cmdline[MAX_INPUTLINE];
921
925 Cvar_RegisterVirtual(&cl_playermodel, "_cl_playermodel");
927 Cvar_RegisterVirtual(&cl_playerskin, "_cl_playerskin");
928
929 // reconstitute the command line for the cmdline externally visible cvar
930 n = 0;
931 for (j = 0;(j < MAX_NUM_ARGVS) && (j < sys.argc);j++)
932 {
933 i = 0;
934 if (strstr(sys.argv[j], " "))
935 {
936 // arg contains whitespace, store quotes around it
937 // This condition checks whether we can allow to put
938 // in two quote characters.
939 if (n >= ((int)sizeof(com_cmdline) - 2))
940 break;
941 com_cmdline[n++] = '\"';
942 // This condition checks whether we can allow one
943 // more character and a quote character.
944 while ((n < ((int)sizeof(com_cmdline) - 2)) && sys.argv[j][i])
945 // FIXME: Doesn't quote special characters.
946 com_cmdline[n++] = sys.argv[j][i++];
947 com_cmdline[n++] = '\"';
948 }
949 else
950 {
951 // This condition checks whether we can allow one
952 // more character.
953 while ((n < ((int)sizeof(com_cmdline) - 1)) && sys.argv[j][i])
954 com_cmdline[n++] = sys.argv[j][i++];
955 }
956 if (n < ((int)sizeof(com_cmdline) - 1))
957 com_cmdline[n++] = ' ';
958 else
959 break;
960 }
961 com_cmdline[n] = 0;
962 Cvar_SetQuick(&cmdline, com_cmdline);
963}
cvar_t cl_playerskin
Definition common.c:37
cvar_t cl_playermodel
Definition common.c:36
cvar_t registered
Definition common.c:32
cvar_t cmdline
Definition common.c:33
void Cvar_SetQuick(cvar_t *var, const char *value)
Definition cvar.c:436
void Cvar_RegisterVariable(cvar_t *variable)
registers a cvar that already has the name, string, and optionally the archive elements set.
Definition cvar.c:599
void Cvar_RegisterVirtual(cvar_t *variable, const char *name)
Definition cvar.c:513
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
Definition qdefs.h:94
#define MAX_NUM_ARGVS
Definition qdefs.h:24
int argc
Definition sys.h:146
const char ** argv
Definition sys.h:147
sys_t sys
Definition sys_shared.c:42

References sys_t::argc, sys_t::argv, cl_playermodel, cl_playerskin, cmdline, Cvar_RegisterVariable(), Cvar_RegisterVirtual(), Cvar_SetQuick(), i, MAX_INPUTLINE, MAX_NUM_ARGVS, n, registered, and sys.

Referenced by Host_Init().

◆ COM_ParseToken_Console()

qbool COM_ParseToken_Console ( const char ** datapointer)

Definition at line 819 of file common.c.

820{
821 int len;
822 const char *data = *datapointer;
823
824 com_token_len = len = 0;
825 com_token[0] = '\0';
826
827 if (!data)
828 {
829 *datapointer = NULL;
830 return false;
831 }
832
833// skip whitespace
834skipwhite:
835 for (;ISWHITESPACE(*data);data++)
836 {
837 if (*data == 0)
838 {
839 // end of file
840 *datapointer = NULL;
841 return false;
842 }
843 }
844
845 if (*data == '/' && data[1] == '/')
846 {
847 // comment
848 while (*data && *data != '\n' && *data != '\r')
849 data++;
850 goto skipwhite;
851 }
852 else if (*data == '\"')
853 {
854 // quoted string
855 for (data++;*data && *data != '\"';data++)
856 {
857 // allow escaped " and \ case
858 if (*data == '\\' && (data[1] == '\"' || data[1] == '\\'))
859 data++;
860 if (len < (int)sizeof(com_token) - 1)
861 com_token[len++] = *data;
862 }
863 com_token[len] = '\0';
864 com_token_len = len;
865 if (*data == '\"')
866 data++;
867 *datapointer = data;
868 }
869 else
870 {
871 // regular word
872 for (;!ISWHITESPACE(*data);data++)
873 if (len < (int)sizeof(com_token) - 1)
874 com_token[len++] = *data;
875 com_token[len] = '\0';
876 com_token_len = len;
877 *datapointer = data;
878 }
879
880 return true;
881}
unsigned com_token_len
Definition common.c:40
char com_token[MAX_INPUTLINE]
Definition common.c:39
#define ISWHITESPACE(ch)
Definition qdefs.h:184
#define NULL
Definition qtypes.h:12

References com_token, com_token_len, data, ISWHITESPACE, and NULL.

Referenced by CDAudio_StartPlaylist(), Cmd_GetDirectCvarValue(), Cmd_TokenizeString(), COM_InsertFlags(), Log_DestBuffer_Flush_NoLock(), Memory_Init_Commands(), PRVM_ED_ParseEdict(), RCon_Authenticate(), and VM_tokenize_console().

◆ COM_ParseToken_QuakeC()

qbool COM_ParseToken_QuakeC ( const char ** datapointer,
qbool returnnewline )

Definition at line 581 of file common.c.

582{
583 int len;
584 int c;
585 const char *data = *datapointer;
586
587 com_token_len = len = 0;
588 com_token[0] = '\0';
589
590 if (!data)
591 {
592 *datapointer = NULL;
593 return false;
594 }
595
596// skip whitespace
597skipwhite:
598 // line endings:
599 // UNIX: \n
600 // Mac: \r
601 // Windows: \r\n
602 for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
603 {
604 if (*data == 0)
605 {
606 // end of file
607 *datapointer = NULL;
608 return false;
609 }
610 }
611
612 // handle Windows line ending
613 if (data[0] == '\r' && data[1] == '\n')
614 data++;
615
616 if (data[0] == '/' && data[1] == '/')
617 {
618 // comment
619 while (*data && *data != '\n' && *data != '\r')
620 data++;
621 goto skipwhite;
622 }
623 else if (data[0] == '/' && data[1] == '*')
624 {
625 // comment
626 data++;
627 while (*data && (data[0] != '*' || data[1] != '/'))
628 data++;
629 if (*data)
630 data++;
631 if (*data)
632 data++;
633 goto skipwhite;
634 }
635 else if (*data == '\"' || *data == '\'')
636 {
637 // quoted string
638 char quote = *data;
639 for (data++;*data && *data != quote;data++)
640 {
641 c = *data;
642 if (*data == '\\')
643 {
644 data++;
645 c = *data;
646 if (c == 'n')
647 c = '\n';
648 else if (c == 't')
649 c = '\t';
650 }
651 if (len < (int)sizeof(com_token) - 1)
652 com_token[len++] = c;
653 }
654 com_token[len] = '\0';
655 com_token_len = len;
656 if (*data == quote)
657 data++;
658 *datapointer = data;
659 return true;
660 }
661 else if (*data == '\r')
662 {
663 // translate Mac line ending to UNIX
664 com_token[len++] = '\n';data++;
665 com_token[len] = '\0';
666 com_token_len = len;
667 *datapointer = data;
668 return true;
669 }
670 else if (*data == '\n' || *data == '{' || *data == '}' || *data == ')' || *data == '(' || *data == ']' || *data == '[' || *data == ':' || *data == ',' || *data == ';')
671 {
672 // single character
673 com_token[len++] = *data++;
674 com_token[len] = '\0';
675 com_token_len = len;
676 *datapointer = data;
677 return true;
678 }
679 else
680 {
681 // regular word
682 for (;!ISWHITESPACE(*data) && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
683 if (len < (int)sizeof(com_token) - 1)
684 com_token[len++] = *data;
685 com_token[len] = '\0';
686 com_token_len = len;
687 *datapointer = data;
688 return true;
689 }
690}

References com_token, com_token_len, data, ISWHITESPACE, and NULL.

Referenced by LoadSubtitles(), Mod_LoadQ3Shaders(), Mod_LoadSkinFiles(), and XPM_DecodeString().

◆ COM_ParseToken_Simple()

qbool COM_ParseToken_Simple ( const char ** datapointer,
qbool returnnewline,
qbool parsebackslash,
qbool parsecomments )

Definition at line 463 of file common.c.

464{
465 int len;
466 int c;
467 const char *data = *datapointer;
468
469 com_token_len = len = 0;
470 com_token[0] = '\0';
471
472 if (!data)
473 {
474 *datapointer = NULL;
475 return false;
476 }
477
478// skip whitespace
479skipwhite:
480 // line endings:
481 // UNIX: \n
482 // Mac: \r
483 // Windows: \r\n
484 for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
485 {
486 if (*data == 0)
487 {
488 // end of file
489 *datapointer = NULL;
490 return false;
491 }
492 }
493
494 // handle Windows line ending
495 if (data[0] == '\r' && data[1] == '\n')
496 data++;
497
498 if (parsecomments && data[0] == '/' && data[1] == '/')
499 {
500 // comment
501 while (*data && *data != '\n' && *data != '\r')
502 data++;
503 goto skipwhite;
504 }
505 else if (parsecomments && data[0] == '/' && data[1] == '*')
506 {
507 // comment
508 data++;
509 while (*data && (data[0] != '*' || data[1] != '/'))
510 data++;
511 if (*data)
512 data++;
513 if (*data)
514 data++;
515 goto skipwhite;
516 }
517 else if (*data == '\"')
518 {
519 // quoted string
520 for (data++;*data && *data != '\"';data++)
521 {
522 c = *data;
523 if (*data == '\\' && parsebackslash)
524 {
525 data++;
526 c = *data;
527 if (c == 'n')
528 c = '\n';
529 else if (c == 't')
530 c = '\t';
531 }
532 if (len < (int)sizeof(com_token) - 1)
533 com_token[len++] = c;
534 }
535 com_token[len] = '\0';
536 com_token_len = len;
537 if (*data == '\"')
538 data++;
539 *datapointer = data;
540 return true;
541 }
542 else if (*data == '\r')
543 {
544 // translate Mac line ending to UNIX
545 com_token[len++] = '\n';data++;
546 com_token[len] = '\0';
547 com_token_len = len;
548 *datapointer = data;
549 return true;
550 }
551 else if (*data == '\n')
552 {
553 // single character
554 com_token[len++] = *data++;
555 com_token[len] = '\0';
556 com_token_len = len;
557 *datapointer = data;
558 return true;
559 }
560 else
561 {
562 // regular word
563 for (;!ISWHITESPACE(*data);data++)
564 if (len < (int)sizeof(com_token) - 1)
565 com_token[len++] = *data;
566 com_token[len] = '\0';
567 com_token_len = len;
568 *datapointer = data;
569 return true;
570 }
571}

References com_token, com_token_len, data, ISWHITESPACE, and NULL.

Referenced by CL_ParseEntityLump(), CL_Particles_ParseEffectInfo(), Con_CompleteCommandLine(), Curl_SendRequirements(), GetMapList(), LoadFont(), M_ScanSaves(), Mod_FrameGroupify_ParseGroups(), Mod_Q1BSP_LoadMapBrushes(), Mod_Q1BSP_ParseWadsFromEntityLump(), Mod_Q3BSP_LoadEntities(), PRVM_ED_LoadFromFile(), PRVM_ED_ParseEdict(), PRVM_ED_ParseGlobals(), R_InitParticleTexture(), R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(), SV_Kick_f(), SV_Loadgame_f(), SV_ParticleEffectIndex(), and VM_parseentitydata().

◆ COM_ParseToken_VM_Tokenize()

qbool COM_ParseToken_VM_Tokenize ( const char ** datapointer,
qbool returnnewline )

Definition at line 700 of file common.c.

701{
702 int len;
703 int c;
704 const char *data = *datapointer;
705
706 com_token_len = len = 0;
707 com_token[0] = '\0';
708
709 if (!data)
710 {
711 *datapointer = NULL;
712 return false;
713 }
714
715// skip whitespace
716skipwhite:
717 // line endings:
718 // UNIX: \n
719 // Mac: \r
720 // Windows: \r\n
721 for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
722 {
723 if (*data == 0)
724 {
725 // end of file
726 *datapointer = NULL;
727 return false;
728 }
729 }
730
731 // handle Windows line ending
732 if (data[0] == '\r' && data[1] == '\n')
733 data++;
734
735 if (data[0] == '/' && data[1] == '/')
736 {
737 // comment
738 while (*data && *data != '\n' && *data != '\r')
739 data++;
740 goto skipwhite;
741 }
742 else if (data[0] == '/' && data[1] == '*')
743 {
744 // comment
745 data++;
746 while (*data && (data[0] != '*' || data[1] != '/'))
747 data++;
748 if (*data)
749 data++;
750 if (*data)
751 data++;
752 goto skipwhite;
753 }
754 else if (*data == '\"' || *data == '\'')
755 {
756 char quote = *data;
757 // quoted string
758 for (data++;*data && *data != quote;data++)
759 {
760 c = *data;
761 if (*data == '\\')
762 {
763 data++;
764 c = *data;
765 if (c == 'n')
766 c = '\n';
767 else if (c == 't')
768 c = '\t';
769 }
770 if (len < (int)sizeof(com_token) - 1)
771 com_token[len++] = c;
772 }
773 com_token[len] = '\0';
774 com_token_len = len;
775 if (*data == quote)
776 data++;
777 *datapointer = data;
778 return true;
779 }
780 else if (*data == '\r')
781 {
782 // translate Mac line ending to UNIX
783 com_token[len++] = '\n';data++;
784 com_token[len] = '\0';
785 com_token_len = len;
786 *datapointer = data;
787 return true;
788 }
789 else if (*data == '\n' || *data == '{' || *data == '}' || *data == ')' || *data == '(' || *data == ']' || *data == '[' || *data == ':' || *data == ',' || *data == ';')
790 {
791 // single character
792 com_token[len++] = *data++;
793 com_token[len] = '\0';
794 com_token_len = len;
795 *datapointer = data;
796 return true;
797 }
798 else
799 {
800 // regular word
801 for (;!ISWHITESPACE(*data) && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
802 if (len < (int)sizeof(com_token) - 1)
803 com_token[len++] = *data;
804 com_token[len] = '\0';
805 com_token_len = len;
806 *datapointer = data;
807 return true;
808 }
809}

References com_token, com_token_len, data, ISWHITESPACE, and NULL.

Referenced by VM_loadfont(), and VM_tokenize().

◆ COM_ReadAndTokenizeLine()

int COM_ReadAndTokenizeLine ( const char ** text,
char ** argv,
int maxargc,
char * tokenbuf,
int tokenbufsize,
const char * commentprefix )

Definition at line 1131 of file common.c.

1132{
1133 int argc, commentprefixlength;
1134 char *tokenbufend;
1135 const char *l;
1136 argc = 0;
1137 tokenbufend = tokenbuf + tokenbufsize;
1138 l = *text;
1139 commentprefixlength = 0;
1140 if (commentprefix)
1141 commentprefixlength = (int)strlen(commentprefix);
1142 while (*l && *l != '\n' && *l != '\r')
1143 {
1144 if (!ISWHITESPACE(*l))
1145 {
1146 if (commentprefixlength && !strncmp(l, commentprefix, commentprefixlength))
1147 {
1148 while (*l && *l != '\n' && *l != '\r')
1149 l++;
1150 break;
1151 }
1152 if (argc >= maxargc)
1153 return -1;
1154 argv[argc++] = tokenbuf;
1155 if (*l == '"')
1156 {
1157 l++;
1158 while (*l && *l != '"')
1159 {
1160 if (tokenbuf >= tokenbufend)
1161 return -1;
1162 *tokenbuf++ = *l++;
1163 }
1164 if (*l == '"')
1165 l++;
1166 }
1167 else
1168 {
1169 while (!ISWHITESPACE(*l))
1170 {
1171 if (tokenbuf >= tokenbufend)
1172 return -1;
1173 *tokenbuf++ = *l++;
1174 }
1175 }
1176 if (tokenbuf >= tokenbufend)
1177 return -1;
1178 *tokenbuf++ = 0;
1179 }
1180 else
1181 l++;
1182 }
1183 // line endings:
1184 // UNIX: \n
1185 // Mac: \r
1186 // Windows: \r\n
1187 if (*l == '\r')
1188 l++;
1189 if (*l == '\n')
1190 l++;
1191 *text = l;
1192 return argc;
1193}
static int(ZEXPORT *qz_inflate)(z_stream *strm
float strlen(string s)
string argv(float n)

References argv(), int(), ISWHITESPACE, and strlen().

◆ COM_Shutdown()

void COM_Shutdown ( void )

◆ COM_StringBeginsWith()

int COM_StringBeginsWith ( const char * s,
const char * match )

Definition at line 1123 of file common.c.

1124{
1125 for (;*s && *match;s++, match++)
1126 if (*s != *match)
1127 return false;
1128 return true;
1129}

◆ COM_StringDecolorize()

size_t COM_StringDecolorize ( const char * in,
size_t size_in,
char * out,
size_t size_out,
qbool escape_carets )

Definition at line 1286 of file common.c.

1287{
1288#define APPEND(ch) do { if(--size_out) { *out++ = (ch); } else { *out++ = 0; return 0; } } while(0)
1289
1290 const char *out_start = out;
1291 const char *end = size_in ? (in + size_in) : NULL;
1292
1293 if(size_out < 1)
1294 return 0;
1295 for(;;)
1296 {
1297 switch((in == end) ? 0 : *in)
1298 {
1299 case 0:
1300 *out = '\0';
1301 return out - out_start;
1302 case STRING_COLOR_TAG:
1303 ++in;
1304 switch((in == end) ? 0 : *in)
1305 {
1307 if (in+1 != end && isxdigit(in[1]) &&
1308 in+2 != end && isxdigit(in[2]) &&
1309 in+3 != end && isxdigit(in[3]) )
1310 {
1311 in+=3;
1312 break;
1313 }
1315 if(escape_carets)
1318 break;
1319 case 0: // ends with unfinished color code!
1321 // finish the code by appending another caret when escaping
1322 if(escape_carets)
1324 *out = '\0';
1325 return out - out_start;
1326 case STRING_COLOR_TAG: // escaped ^
1328 // append a ^ twice when escaping
1329 if(escape_carets)
1331 break;
1332 case '0': case '1': case '2': case '3': case '4':
1333 case '5': case '6': case '7': case '8': case '9': // color code
1334 break;
1335 default: // not a color code
1337 APPEND(*in);
1338 break;
1339 }
1340 break;
1341 default:
1342 APPEND(*in);
1343 break;
1344 }
1345 ++in;
1346 }
1347 // never get here
1348#undef APPEND
1349}
#define APPEND(ch)
#define STRING_COLOR_RGB_TAG_CHAR
Definition draw.h:143

References APPEND, NULL, STRING_COLOR_RGB_TAG_CHAR, and STRING_COLOR_TAG.

Referenced by VM_strdecolorize(), and VM_uncolorstring().

◆ COM_StringLengthNoColors()

size_t COM_StringLengthNoColors ( const char * s,
size_t size_s,
qbool * valid )

Definition at line 1212 of file common.c.

1213{
1214 const char *end = size_s ? (s + size_s) : NULL;
1215 size_t len = 0;
1216 for(;;)
1217 {
1218 switch((s == end) ? 0 : *s)
1219 {
1220 case 0:
1221 if(valid)
1222 *valid = true;
1223 return len;
1224 case STRING_COLOR_TAG:
1225 ++s;
1226 switch((s == end) ? 0 : *s)
1227 {
1229 if (s+1 != end && isxdigit(s[1]) &&
1230 s+2 != end && isxdigit(s[2]) &&
1231 s+3 != end && isxdigit(s[3]) )
1232 {
1233 s+=3;
1234 break;
1235 }
1236 ++len; // STRING_COLOR_TAG
1237 ++len; // STRING_COLOR_RGB_TAG_CHAR
1238 break;
1239 case 0: // ends with unfinished color code!
1240 ++len;
1241 if(valid)
1242 *valid = false;
1243 return len;
1244 case STRING_COLOR_TAG: // escaped ^
1245 ++len;
1246 break;
1247 case '0': case '1': case '2': case '3': case '4':
1248 case '5': case '6': case '7': case '8': case '9': // color code
1249 break;
1250 default: // not a color code
1251 ++len; // STRING_COLOR_TAG
1252 ++len; // the character
1253 break;
1254 }
1255 break;
1256 default:
1257 ++len;
1258 break;
1259 }
1260 ++s;
1261 }
1262 // never get here
1263}

◆ COM_ToLowerString()

size_t COM_ToLowerString ( const char * in,
char * out,
size_t size_out )

Returns the number of bytes written to *out excluding the \0 terminator.

Definition at line 1051 of file common.c.

1052{
1053 const char *out_start = out;
1054
1055 if (size_out == 0)
1056 return 0;
1057
1059 {
1060 *out = 0;
1061 while(*in && size_out > 1)
1062 {
1063 int n;
1064 Uchar ch = u8_getchar_utf8_enabled(in, &in);
1065 ch = u8_tolower(ch);
1066 n = u8_fromchar(ch, out, size_out);
1067 out += n; // before the break so the return is correct
1068 if(n <= 0)
1069 break;
1070 size_out -= n;
1071 }
1072 return out - out_start;
1073 }
1074
1075 while (*in && size_out > 1)
1076 {
1077 if (*in >= 'A' && *in <= 'Z')
1078 *out++ = *in++ + 'a' - 'A';
1079 else
1080 *out++ = *in++;
1081 size_out--;
1082 }
1083 *out = '\0';
1084 return out - out_start;
1085}
int integer
Definition cvar.h:73
Uchar u8_tolower(Uchar ch)
Definition utf8lib.c:2120
cvar_t utf8_enable
Definition utf8lib.c:11
int u8_fromchar(Uchar w, char *to, size_t maxlen)
Encode a wide-character into utf-8.
Definition utf8lib.c:628
Uchar u8_getchar_utf8_enabled(const char *_s, const char **_end)
Fetch a character from an utf-8 encoded string.
Definition utf8lib.c:592
int32_t Uchar
Definition utf8lib.h:35

References cvar_t::integer, n, u8_fromchar(), u8_getchar_utf8_enabled(), u8_tolower(), and utf8_enable.

Referenced by COM_InitGameType(), and VM_strtolower().

◆ COM_ToUpperString()

size_t COM_ToUpperString ( const char * in,
char * out,
size_t size_out )

Returns the number of bytes written to *out excluding the \0 terminator.

Definition at line 1087 of file common.c.

1088{
1089 const char *out_start = out;
1090
1091 if (size_out == 0)
1092 return 0;
1093
1095 {
1096 *out = 0;
1097 while(*in && size_out > 1)
1098 {
1099 int n;
1100 Uchar ch = u8_getchar_utf8_enabled(in, &in);
1101 ch = u8_toupper(ch);
1102 n = u8_fromchar(ch, out, size_out);
1103 out += n; // before the break so the return is correct
1104 if(n <= 0)
1105 break;
1106 size_out -= n;
1107 }
1108 return out - out_start;
1109 }
1110
1111 while (*in && size_out > 1)
1112 {
1113 if (*in >= 'a' && *in <= 'z')
1114 *out++ = *in++ + 'A' - 'a';
1115 else
1116 *out++ = *in++;
1117 size_out--;
1118 }
1119 *out = '\0';
1120 return out - out_start;
1121}
Uchar u8_toupper(Uchar ch)
Definition utf8lib.c:1066

References cvar_t::integer, n, u8_fromchar(), u8_getchar_utf8_enabled(), u8_toupper(), and utf8_enable.

Referenced by VM_strtoupper().

◆ COM_Wordwrap()

int COM_Wordwrap ( const char * string,
size_t length,
float continuationSize,
float maxWidth,
COM_WordWidthFunc_t wordWidth,
void * passthroughCW,
COM_LineProcessorFunc processLine,
void * passthroughPL )

Definition at line 174 of file common.c.

175{
176 // Logic is as follows:
177 //
178 // For each word or whitespace:
179 // Newline found? Output current line, advance to next line. This is not a continuation. Continue.
180 // Space found? Always add it to the current line, no matter if it fits.
181 // Word found? Check if current line + current word fits.
182 // If it fits, append it. Continue.
183 // If it doesn't fit, output current line, advance to next line. Append the word. This is a continuation. Continue.
184
185 qbool isContinuation = false;
186 float spaceWidth;
187 const char *startOfLine = string;
188 const char *cursor = string;
189 const char *end = string + length;
190 float spaceUsedInLine = 0;
191 float spaceUsedForWord;
192 int result = 0;
193 size_t wordLen;
194 size_t dummy;
195
196 dummy = 0;
197 wordWidth(passthroughCW, NULL, &dummy, -1);
198 dummy = 1;
199 spaceWidth = wordWidth(passthroughCW, " ", &dummy, -1);
200
201 for(;;)
202 {
203 char ch = (cursor < end) ? *cursor : 0;
204 switch(ch)
205 {
206 case 0: // end of string
207 result += processLine(passthroughPL, startOfLine, cursor - startOfLine, spaceUsedInLine, isContinuation);
208 goto out;
209 case '\n': // end of line
210 result += processLine(passthroughPL, startOfLine, cursor - startOfLine, spaceUsedInLine, isContinuation);
211 isContinuation = false;
212 ++cursor;
213 startOfLine = cursor;
214 break;
215 case ' ': // space
216 ++cursor;
217 spaceUsedInLine += spaceWidth;
218 break;
219 default: // word
220 wordLen = 1;
221 while(cursor + wordLen < end)
222 {
223 switch(cursor[wordLen])
224 {
225 case 0:
226 case '\n':
227 case ' ':
228 goto out_inner;
229 default:
230 ++wordLen;
231 break;
232 }
233 }
234 out_inner:
235 spaceUsedForWord = wordWidth(passthroughCW, cursor, &wordLen, maxWidth - continuationWidth); // this may have reduced wordLen when it won't fit - but this is GOOD. TODO fix words that do fit in a non-continuation line
236 if(wordLen < 1) // cannot happen according to current spec of wordWidth
237 {
238 wordLen = 1;
239 spaceUsedForWord = maxWidth + 1; // too high, forces it in a line of itself
240 }
241 if(spaceUsedInLine + spaceUsedForWord <= maxWidth || cursor == startOfLine)
242 {
243 // we can simply append it
244 cursor += wordLen;
245 spaceUsedInLine += spaceUsedForWord;
246 }
247 else
248 {
249 // output current line
250 result += processLine(passthroughPL, startOfLine, cursor - startOfLine, spaceUsedInLine, isContinuation);
251 isContinuation = true;
252 startOfLine = cursor;
253 cursor += wordLen;
254 spaceUsedInLine = continuationWidth + spaceUsedForWord;
255 }
256 }
257 }
258 out:
259
260 return result;
261
262/*
263 qbool isContinuation = false;
264 float currentWordSpace = 0;
265 const char *currentWord = 0;
266 float minReserve = 0;
267
268 float spaceUsedInLine = 0;
269 const char *currentLine = 0;
270 const char *currentLineEnd = 0;
271 float currentLineFinalWhitespace = 0;
272 const char *p;
273
274 int result = 0;
275 minReserve = charWidth(passthroughCW, 0);
276 minReserve += charWidth(passthroughCW, ' ');
277
278 if(maxWidth < continuationWidth + minReserve)
279 maxWidth = continuationWidth + minReserve;
280
281 charWidth(passthroughCW, 0);
282
283 for(p = string; p < string + length; ++p)
284 {
285 char c = *p;
286 float w = charWidth(passthroughCW, c);
287
288 if(!currentWord)
289 {
290 currentWord = p;
291 currentWordSpace = 0;
292 }
293
294 if(!currentLine)
295 {
296 currentLine = p;
297 spaceUsedInLine = isContinuation ? continuationWidth : 0;
298 currentLineEnd = 0;
299 }
300
301 if(c == ' ')
302 {
303 // 1. I can add the word AND a space - then just append it.
304 if(spaceUsedInLine + currentWordSpace + w <= maxWidth)
305 {
306 currentLineEnd = p; // note: space not included here
307 currentLineFinalWhitespace = w;
308 spaceUsedInLine += currentWordSpace + w;
309 }
310 // 2. I can just add the word - then append it, output current line and go to next one.
311 else if(spaceUsedInLine + currentWordSpace <= maxWidth)
312 {
313 result += processLine(passthroughPL, currentLine, p - currentLine, spaceUsedInLine + currentWordSpace, isContinuation);
314 currentLine = 0;
315 isContinuation = true;
316 }
317 // 3. Otherwise, output current line and go to next one, where I can add the word.
318 else if(continuationWidth + currentWordSpace + w <= maxWidth)
319 {
320 if(currentLineEnd)
321 result += processLine(passthroughPL, currentLine, currentLineEnd - currentLine, spaceUsedInLine - currentLineFinalWhitespace, isContinuation);
322 currentLine = currentWord;
323 spaceUsedInLine = continuationWidth + currentWordSpace + w;
324 currentLineEnd = p;
325 currentLineFinalWhitespace = w;
326 isContinuation = true;
327 }
328 // 4. We can't even do that? Then output both current and next word as new lines.
329 else
330 {
331 if(currentLineEnd)
332 {
333 result += processLine(passthroughPL, currentLine, currentLineEnd - currentLine, spaceUsedInLine - currentLineFinalWhitespace, isContinuation);
334 isContinuation = true;
335 }
336 result += processLine(passthroughPL, currentWord, p - currentWord, currentWordSpace, isContinuation);
337 currentLine = 0;
338 isContinuation = true;
339 }
340 currentWord = 0;
341 }
342 else if(c == '\n')
343 {
344 // 1. I can add the word - then do it.
345 if(spaceUsedInLine + currentWordSpace <= maxWidth)
346 {
347 result += processLine(passthroughPL, currentLine, p - currentLine, spaceUsedInLine + currentWordSpace, isContinuation);
348 }
349 // 2. Otherwise, output current line, next one and make tabula rasa.
350 else
351 {
352 if(currentLineEnd)
353 {
354 processLine(passthroughPL, currentLine, currentLineEnd - currentLine, spaceUsedInLine - currentLineFinalWhitespace, isContinuation);
355 isContinuation = true;
356 }
357 result += processLine(passthroughPL, currentWord, p - currentWord, currentWordSpace, isContinuation);
358 }
359 currentWord = 0;
360 currentLine = 0;
361 isContinuation = false;
362 }
363 else
364 {
365 currentWordSpace += w;
366 if(
367 spaceUsedInLine + currentWordSpace > maxWidth // can't join this line...
368 &&
369 continuationWidth + currentWordSpace > maxWidth // can't join any other line...
370 )
371 {
372 // this word cannot join ANY line...
373 // so output the current line...
374 if(currentLineEnd)
375 {
376 result += processLine(passthroughPL, currentLine, currentLineEnd - currentLine, spaceUsedInLine - currentLineFinalWhitespace, isContinuation);
377 isContinuation = true;
378 }
379
380 // then this word's beginning...
381 if(isContinuation)
382 {
383 // it may not fit, but we know we have to split it into maxWidth - continuationWidth pieces
384 float pieceWidth = maxWidth - continuationWidth;
385 const char *pos = currentWord;
386 currentWordSpace = 0;
387
388 // reset the char width function to a state where no kerning occurs (start of word)
389 charWidth(passthroughCW, ' ');
390 while(pos <= p)
391 {
392 float w = charWidth(passthroughCW, *pos);
393 if(currentWordSpace + w > pieceWidth) // this piece won't fit any more
394 {
395 // print everything until it
396 result += processLine(passthroughPL, currentWord, pos - currentWord, currentWordSpace, true);
397 // go to here
398 currentWord = pos;
399 currentWordSpace = 0;
400 }
401 currentWordSpace += w;
402 ++pos;
403 }
404 // now we have a currentWord that fits... set up its next line
405 // currentWordSpace has been set
406 // currentWord has been set
407 spaceUsedInLine = continuationWidth;
408 currentLine = currentWord;
409 currentLineEnd = 0;
410 isContinuation = true;
411 }
412 else
413 {
414 // we have a guarantee that it will fix (see if clause)
415 result += processLine(passthroughPL, currentWord, p - currentWord, currentWordSpace - w, isContinuation);
416
417 // and use the rest of this word as new start of a line
418 currentWordSpace = w;
419 currentWord = p;
420 spaceUsedInLine = continuationWidth;
421 currentLine = p;
422 currentLineEnd = 0;
423 isContinuation = true;
424 }
425 }
426 }
427 }
428
429 if(!currentWord)
430 {
431 currentWord = p;
432 currentWordSpace = 0;
433 }
434
435 if(currentLine) // Same procedure as \n
436 {
437 // Can I append the current word?
438 if(spaceUsedInLine + currentWordSpace <= maxWidth)
439 result += processLine(passthroughPL, currentLine, p - currentLine, spaceUsedInLine + currentWordSpace, isContinuation);
440 else
441 {
442 if(currentLineEnd)
443 {
444 result += processLine(passthroughPL, currentLine, currentLineEnd - currentLine, spaceUsedInLine - currentLineFinalWhitespace, isContinuation);
445 isContinuation = true;
446 }
447 result += processLine(passthroughPL, currentWord, p - currentWord, currentWordSpace, isContinuation);
448 }
449 }
450
451 return result;
452*/
453}
GLsizei const GLchar ** string
Definition glquake.h:728
bool qbool
Definition qtypes.h:9

References length, NULL, and string.

Referenced by CL_DrawVideo(), Con_DrawConsoleLine(), Con_DrawNotifyRect(), and Con_LineHeight().

◆ CRC_Block()

◆ CRC_Block_CaseInsensitive()

unsigned short CRC_Block_CaseInsensitive ( const unsigned char * data,
size_t size )

Definition at line 83 of file com_crc16.c.

84{
85 unsigned short crc = CRC_INIT_VALUE;
86 while (size--)
87 crc = (crc << 8) ^ crctable[(crc >> 8) ^ (tolower(*data++))];
88 return crc ^ CRC_XOR_VALUE;
89}

References CRC_INIT_VALUE, CRC_XOR_VALUE, crctable, data, and size.

Referenced by Mod_LookupQ3Shader(), Q3Shader_AddToHash(), and VM_crc16().

◆ dp__strlcat()

size_t dp__strlcat ( char * dst,
const char * src,
size_t dsize,
const char * func,
unsigned line )

Catenates a string, like strlcat() but with a better return: the number of bytes copied excluding the \0 terminator.

Truncates and warns on overflow or unterminated source, whereas strlcat() truncates silently and overreads (possibly segfaulting). Guarantees \0 termination. Inefficient like any strcat(), please use memcpy(), dp_stpecpy() or dp_strlcpy() instead.

Definition at line 1423 of file common.c.

1424{
1425 size_t offset;
1426 char *p = (char *)memchr(dst, '\0', dsize);
1427
1428 if (!p)
1429 p = dst;
1430 offset = p - dst;
1431 return dp__strlcpy(p, src, dsize - offset, func, line) + offset;
1432}
size_t dp__strlcpy(char *dst, const char *src, size_t dsize, const char *func, unsigned line)
Copies a string, like strlcpy() but with a better return: the number of bytes copied excluding the \0...
Definition common.c:1406
GLuint GLuint GLintptr offset
Definition glquake.h:632

References dp__strlcpy(), offset, and src.

◆ dp__strlcpy()

size_t dp__strlcpy ( char * dst,
const char * src,
size_t dsize,
const char * func,
unsigned line )

Copies a string, like strlcpy() but with a better return: the number of bytes copied excluding the \0 terminator.

Truncates and warns on overflow or unterminated source, whereas strlcpy() truncates silently and overreads (possibly segfaulting). Guarantees \0 termination. See also: dp_stpecpy() and dp_ustr2stp().

Definition at line 1406 of file common.c.

1407{
1408 char *p = (char *)memccpy(dst, src, '\0', dsize);
1409
1410 if (p)
1411 return (p - 1) - dst;
1412 dst[dsize - 1] = '\0';
1413 Con_Printf(CON_WARN "%s:%u: src string unterminated or truncated to %lu bytes: \"%s\"\n", func, line, (unsigned long)dsize - 1, dst);
1414 return dsize - 1;
1415}
void Con_Printf(const char *fmt,...)
Prints to all appropriate console targets.
Definition console.c:1514
#define CON_WARN
Definition console.h:101

References Con_Printf(), CON_WARN, and src.

Referenced by dp__strlcat().

◆ dp_stpecpy()

char * dp_stpecpy ( char * dst,
char * end,
const char * src )

Chain-copies a string with truncation and efficiency (compared to strlcat()).

The destination ends at an absolute pointer instead of a relative offset and a pointer to the \0 terminator is returned on success. Truncates, warns, and returns the end pointer on overflow or unterminated source. Guarantees \0 termination. end = dst + sizeof(src[])

Definition at line 1373 of file common.c.

1374{
1375 char *p = (char *)memccpy(dst, src, '\0', end - dst);
1376
1377 if (p)
1378 return p - 1;
1379 end[-1] = '\0';
1380 Con_Printf(CON_WARN "%s: src string unterminated or truncated to %lu bytes: \"%s\"\n", __func__, (unsigned long)(dst == end ? 0 : (end - dst) - 1), dst);
1381 return end;
1382}

References Con_Printf(), CON_WARN, and src.

Referenced by PRVM_ShortStackTrace().

◆ dp_ustr2stp()

char * dp_ustr2stp ( char * dst,
size_t dsize,
const char * src,
size_t slen )

Copies a measured byte sequence (unterminated string) to a null-terminated string.

Returns a pointer to the \0 terminator. Guarantees \0 termination. Compared to ustr2stp(): truncates and warns on overflow.

Definition at line 1388 of file common.c.

1389{
1390 if (slen >= dsize)
1391 {
1392 slen = dsize - 1;
1393 Con_Printf(CON_WARN "%s: src string truncated to %lu bytes: \"%.*s\"\n", __func__, (unsigned long)slen, (int)slen, src);
1394 }
1395 memcpy(dst, src, slen);
1396 dst[slen] = '\0';
1397 return &dst[slen];
1398}

References Con_Printf(), CON_WARN, and src.

Referenced by Cbuf_LinkString(), Con_CompleteCommandLine(), ConBuffer_GetLine(), FS_Search(), and RCon_Authenticate().

◆ dpsnprintf()

int dpsnprintf ( char * buffer,
size_t buffersize,
const char * format,
... )
extern

Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't big enough to contain the entire string.

Buffer is ALWAYS null-terminated.

Definition at line 997 of file common.c.

998{
999 va_list args;
1000 int result;
1001
1002 va_start (args, format);
1003 result = dpvsnprintf (buffer, buffersize, format, args);
1004 va_end (args);
1005
1006 return result;
1007}
int dpvsnprintf(char *buffer, size_t buffersize, const char *format, va_list args)
Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't ...
Definition common.c:1010
GLint GLint GLint GLsizei GLsizei GLenum format
Definition glquake.h:649

References buffer, dpvsnprintf(), and format.

Referenced by adddirentry(), CDAudio_Play(), CDAudio_Play_byName(), CL_BeginDownloads(), CL_DisconnectEx(), CL_ForwardToServer(), CL_ForwardToServer_f(), CL_InitCommands(), CL_Locs_FindLocationName(), CL_Locs_Reload_f(), CL_Locs_Save_f(), CL_NextDemo(), CL_ParseServerInfo(), CL_ParseServerMessage(), CL_Particles_LoadEffectInfo(), CL_PlayVideo_f(), CL_Rcon_f(), CL_ReadPointFile_f(), CL_Record_f(), CL_SetSignonStage_WithMsg(), CL_StopDownload(), CleanURL(), Cmd_GetCvarValue(), Con_CompleteCommandLine(), Con_MsgCmdMode(), Crypto_BuildIdString(), Crypto_ClientError(), Crypto_ClientParsePacket(), Crypto_ServerError(), Curl_Begin(), Curl_Curl_f(), Curl_GetDownloadInfo(), Curl_SendRequirement(), Cvar_SetValue(), Cvar_SetValueQuick(), Font_LoadMap(), FS_AddPack(), FS_AddPack_Fullpath(), FS_ChooseUserDir(), FS_FileType(), FS_FindFile(), FS_Init_Dir(), FS_OpenReadFile(), FS_OpenRealFile(), GetMapList(), GL_CheckExtension(), GL_Draw_Init(), gl_main_newmap(), Host_InitSession(), Host_UpdateVersion(), Image_FixTransparentPixels_f(), Image_GetStockPicSize(), InfoString_SetValue(), LHNETADDRESS_GetInterfaceName(), LHNETADDRESS_Resolve(), LHNETADDRESS_ToString(), LibAvW_OpenVideo(), listdirectory(), LoadFont(), loadimagepixelsbgra(), LoadSubtitles(), Log_Timestamp(), M_DrawSlider(), M_Keys_Key(), M_LanConfig_Key(), M_Menu_LanConfig_f(), M_ScanSaves(), Mod_Decompile_f(), Mod_Decompile_OBJ(), Mod_Decompile_SMD(), Mod_FrameGroupify_ParseGroups_Store(), Mod_IDP0_Load(), Mod_IDS2_Load(), Mod_LoadQ3Shaders(), Mod_LoadTextureFromQ3Shader(), Mod_OBJ_Load(), Mod_PSKMODEL_Load(), Mod_Q1BSP_Load(), Mod_Q1BSP_LoadTextures(), Mod_Q1BSP_ParseWadsFromEntityLump(), Mod_Q2BSP_Load(), Mod_Q2BSP_LoadBrushes(), Mod_Q2BSP_LoadTexinfo(), Mod_Q3BSP_Load(), Mod_Sprite_SharedSetup(), NetConn_BuildStatusResponse(), NetConn_ClientFrame(), NetConn_ClientParsePacket(), NetConn_ServerParsePacket(), OpenVideo(), PRVM_ED_ParseEdict(), PRVM_ED_Print(), PRVM_Fields_f(), PRVM_GlobalString(), PRVM_GlobalStringNoContents(), PRVM_PrintStatement(), PRVM_Prog_Load(), PRVM_ShortStackTrace(), PRVM_UglyValueString(), PRVM_ValueString(), PRVM_Watchpoint(), R_Envmap_f(), R_InitShaderModeInfo(), R_LoadCubemap(), R_LoadQWSkin(), R_LoadSkyBox(), R_Shadow_EditLights_DrawSelectedLightProperties(), R_Shadow_LoadLightsFile(), R_Shadow_LoadWorldLights(), R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(), R_Shadow_SaveWorldLights(), R_TimeReport(), R_TimeReport_EndFrame(), S_LoadSound(), Sbar_DrawFace(), Sbar_DrawFrags(), Sbar_DrawInventory(), Sbar_DrawNum(), Sbar_DrawXNum(), Sbar_ShowFPS(), Sbar_SoloScoreboard(), SCR_DrawCurlDownload(), SCR_DrawNetGraph_DrawGraph(), SCR_DrawQWDownload(), SCR_DrawScreen(), SCR_ScreenShot_f(), SV_Ent_Create_f(), SV_ParticleEffectIndex(), SV_Pings_f(), SV_Savegame_to(), SV_Say(), SV_SendServerinfo(), SV_SpawnServer(), SV_Tell_f(), Sys_FindInPATH(), u8_strpad(), u8_strpad_colorcodes(), VM_CL_getplayerkey(), VM_etos(), VM_ftos(), VM_M_crypto_getencryptlevel(), VM_sprintf(), VM_strpad(), and VM_vtos().

◆ dpvsnprintf()

int dpvsnprintf ( char * buffer,
size_t buffersize,
const char * format,
va_list args )
extern

Returns the number of printed characters, excluding the final '\0' or returns -1 if the buffer isn't big enough to contain the entire string.

Buffer is ALWAYS null-terminated.

Definition at line 1010 of file common.c.

1011{
1012 int result;
1013
1014#if _MSC_VER >= 1400
1015 result = _vsnprintf_s (buffer, buffersize, _TRUNCATE, format, args);
1016#else
1017 result = vsnprintf (buffer, buffersize, format, args);
1018#endif
1019 if (result < 0 || (size_t)result >= buffersize)
1020 {
1021 // _vsnprintf_s returns -1 on error and on truncation (indistinguishable),
1022 // vsnprintf returns negative on error and the desired strlen on truncation.
1023 buffer[buffersize - 1] = '\0'; // should be unnecessary, but just in case
1024 // Basic stdout only: we could be inside Con_Printf, Sys_Printf calls dpvsnprintf,
1025 // Windows console doesn't support colours.
1026 if (result < 0)
1027 Sys_Print("dpvsnprintf: output error!\n", 27);
1028 else
1029 {
1030 char msg[MAX_INPUTLINE];
1031#if _MSC_VER >= 1400
1032 result = _snprintf_s(msg, sizeof(msg), _TRUNCATE, "dpvsnprintf: truncated to %lu bytes: \"%s\"\n", (unsigned long)buffersize - 1, buffer);
1033#else
1034 result = snprintf(msg, sizeof(msg), "dpvsnprintf: truncated to %lu bytes: \"%s\"\n", (unsigned long)buffersize - 1, buffer);
1035#endif
1036 if (result > 0)
1037 {
1038 msg[sizeof(msg) - 1] = '\n'; // may have been lost in truncation
1039 Sys_Print(msg, min((size_t)result, sizeof(msg) - 1));
1040 }
1041 }
1042 return -1;
1043 }
1044
1045 return result;
1046}
#define vsnprintf
Definition common.h:240
#define snprintf
Definition common.h:238
#define min(A, B)
Definition mathlib.h:37
void Sys_Print(const char *text, size_t textlen)
(may) output text to terminal which launched program is POSIX async-signal-safe textlen excludes any ...
Definition sys_shared.c:615

References buffer, format, MAX_INPUTLINE, min, snprintf, Sys_Print(), and vsnprintf.

Referenced by CL_DisconnectEx(), Con_CenterPrintf(), Con_DPrintf(), Con_MaskPrintf(), Con_Printf(), dpsnprintf(), FS_VPrintf(), Host_Error(), MVM_error_cmd(), SV_BroadcastPrintf(), SV_ClientCommands(), SV_ClientPrintf(), SV_DropClient(), Sys_Error(), Sys_Printf(), va(), and VM_Warning().

◆ FindFraction()

void FindFraction ( double val,
int * num,
int * denom,
int denomMax )

Definition at line 1436 of file common.c.

1437{
1438 int i;
1439 double bestdiff;
1440 // initialize
1441 bestdiff = fabs(val);
1442 *num = 0;
1443 *denom = 1;
1444
1445 for(i = 1; i <= denomMax; ++i)
1446 {
1447 int inum = (int) floor(0.5 + val * i);
1448 double diff = fabs(val - inum / (double)i);
1449 if(diff < bestdiff)
1450 {
1451 bestdiff = diff;
1452 *num = inum;
1453 *denom = i;
1454 }
1455 }
1456}
float floor(float f)

References fabs(), floor(), i, and int().

Referenced by SCR_CaptureVideo_Avi_BeginVideo(), and SCR_CaptureVideo_Ogg_BeginVideo().

◆ MSG_BeginReading()

void MSG_BeginReading ( sizebuf_t * sb)

◆ MSG_InitReadBuffer()

void MSG_InitReadBuffer ( sizebuf_t * buf,
unsigned char * data,
int size )

Definition at line 249 of file com_msg.c.

250{
251 memset(buf, 0, sizeof(*buf));
252 buf->data = data;
253 buf->maxsize = buf->cursize = size;
255}
void MSG_BeginReading(sizebuf_t *sb)
Definition com_msg.c:257

References buf, data, MSG_BeginReading(), and size.

Referenced by Mod_Q1BSP_Load(), Mod_Q1BSP_LoadTextures(), Mod_Q2BSP_Load(), Mod_VBSP_Load(), and W_GetTextureBGRA().

◆ MSG_ReadAngle()

float MSG_ReadAngle ( sizebuf_t * sb,
protocolversion_t protocol )

Definition at line 424 of file com_msg.c.

425{
426 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_DARKPLACES1 || protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4 || protocol == PROTOCOL_QUAKEWORLD)
427 return MSG_ReadAngle8i (sb);
428 else
429 return MSG_ReadAngle16i (sb);
430}
float MSG_ReadAngle8i(sizebuf_t *sb)
Definition com_msg.c:409
float MSG_ReadAngle16i(sizebuf_t *sb)
Definition com_msg.c:414

References MSG_ReadAngle16i(), MSG_ReadAngle8i(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by CL_ParseBaseline(), CL_ParseServerMessage(), EntityFrameQuake_ReadEntity(), and VM_CL_ReadAngle().

◆ MSG_ReadAngle16i()

float MSG_ReadAngle16i ( sizebuf_t * sb)

Definition at line 414 of file com_msg.c.

415{
416 return (signed short)MSG_ReadShort (sb) * (360.0/65536.0);
417}
#define MSG_ReadShort
Definition common.h:191

References MSG_ReadShort.

Referenced by CL_ParseClientdata(), EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadPlayerUpdate(), MSG_ReadAngle(), and SV_ReadClientMove().

◆ MSG_ReadAngle32f()

float MSG_ReadAngle32f ( sizebuf_t * sb)

Definition at line 419 of file com_msg.c.

420{
421 return MSG_ReadFloat (sb);
422}
#define MSG_ReadFloat
Definition common.h:193

References MSG_ReadFloat.

Referenced by SV_ReadClientMove().

◆ MSG_ReadAngle8i()

float MSG_ReadAngle8i ( sizebuf_t * sb)

Definition at line 409 of file com_msg.c.

410{
411 return (signed char) MSG_ReadByte (sb) * (360.0/256.0);
412}
#define MSG_ReadByte(sb)
Definition common.h:188

References MSG_ReadByte.

Referenced by EntityState5_ReadUpdate(), EntityState_ReadFields(), EntityStateQW_ReadEntityUpdate(), MSG_ReadAngle(), and SV_ReadClientMove().

◆ MSG_ReadBigFloat()

float MSG_ReadBigFloat ( sizebuf_t * sb)

Definition at line 324 of file com_msg.c.

325{
326 union
327 {
328 float f;
329 int l;
330 } dat;
331 if (sb->readcount+4 > sb->cursize)
332 {
333 sb->badread = true;
334 return -1;
335 }
336 sb->readcount += 4;
337 dat.l = ((unsigned)sb->data[sb->readcount-4]<<24) | (sb->data[sb->readcount-3]<<16) | (sb->data[sb->readcount-2]<<8) | sb->data[sb->readcount-1];
338 return dat.f;
339}
unsigned char * data
Definition common.h:52
int cursize
Definition common.h:54

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, f, and sizebuf_t::readcount.

◆ MSG_ReadBigLong()

int MSG_ReadBigLong ( sizebuf_t * sb)

Definition at line 296 of file com_msg.c.

297{
298 if (sb->readcount+4 > sb->cursize)
299 {
300 sb->badread = true;
301 return -1;
302 }
303 sb->readcount += 4;
304 return ((unsigned)sb->data[sb->readcount-4]<<24) + (sb->data[sb->readcount-3]<<16) + (sb->data[sb->readcount-2]<<8) + sb->data[sb->readcount-1];
305}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, and sizebuf_t::readcount.

◆ MSG_ReadBigShort()

int MSG_ReadBigShort ( sizebuf_t * sb)

Definition at line 274 of file com_msg.c.

275{
276 if (sb->readcount+2 > sb->cursize)
277 {
278 sb->badread = true;
279 return -1;
280 }
281 sb->readcount += 2;
282 return (short)((sb->data[sb->readcount-2]<<8) + sb->data[sb->readcount-1]);
283}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, and sizebuf_t::readcount.

◆ MSG_ReadBytes()

size_t MSG_ReadBytes ( sizebuf_t * sb,
size_t numbytes,
unsigned char * out )

Definition at line 364 of file com_msg.c.

365{
366 size_t l = 0;
367
368 // when numbytes have been read sb->readcount won't be advanced any further
369 while (l < numbytes && !sb->badread)
370 out[l++] = MSG_ReadByte_opt(sb);
371 return l;
372}
#define MSG_ReadByte_opt(sb)
Same as MSG_ReadByte but with no need to copy twice (first to int to check for -1) so each byte can b...
Definition common.h:190

References MSG_ReadByte_opt.

Referenced by CL_ParseDownload(), Mod_Q1BSP_LoadEntities(), Mod_Q1BSP_LoadVisibility(), Mod_Q2BSP_LoadLighting(), Mod_Q2BSP_LoadTexinfo(), Mod_VBSP_LoadEntities(), QW_CL_ParseDownload(), VM_CL_ReadPicture(), and W_ConvertWAD3TextureBGRA().

◆ MSG_ReadCoord()

float MSG_ReadCoord ( sizebuf_t * sb,
protocolversion_t protocol )

Definition at line 389 of file com_msg.c.

390{
391 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_QUAKEWORLD)
392 return MSG_ReadCoord13i(sb);
393 else if (protocol == PROTOCOL_DARKPLACES1)
394 return MSG_ReadCoord32f(sb);
395 else if (protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4)
396 return MSG_ReadCoord16i(sb);
397 else
398 return MSG_ReadCoord32f(sb);
399}
float MSG_ReadCoord32f(sizebuf_t *sb)
Definition com_msg.c:384
float MSG_ReadCoord13i(sizebuf_t *sb)
Definition com_msg.c:374
float MSG_ReadCoord16i(sizebuf_t *sb)
Definition com_msg.c:379

References MSG_ReadCoord13i(), MSG_ReadCoord16i(), MSG_ReadCoord32f(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by CL_ParseBaseline(), CL_ParseServerMessage(), CL_ParseTempEntity(), EntityFrameQuake_ReadEntity(), MSG_ReadVector(), and VM_CL_ReadCoord().

◆ MSG_ReadCoord13i()

float MSG_ReadCoord13i ( sizebuf_t * sb)

Definition at line 374 of file com_msg.c.

375{
376 return MSG_ReadLittleShort(sb) * (1.0/8.0);
377}
int MSG_ReadLittleShort(sizebuf_t *sb)
Definition com_msg.c:263

References MSG_ReadLittleShort().

Referenced by EntityState5_ReadUpdate(), EntityStateQW_ReadEntityUpdate(), and MSG_ReadCoord().

◆ MSG_ReadCoord16i()

float MSG_ReadCoord16i ( sizebuf_t * sb)

Definition at line 379 of file com_msg.c.

380{
381 return (signed short) MSG_ReadLittleShort(sb);
382}

References MSG_ReadLittleShort().

Referenced by CL_ParseClientdata(), EntityState_ReadFields(), MSG_ReadCoord(), and SV_ReadClientMove().

◆ MSG_ReadCoord32f()

float MSG_ReadCoord32f ( sizebuf_t * sb)

Definition at line 384 of file com_msg.c.

385{
386 return MSG_ReadLittleFloat(sb);
387}
float MSG_ReadLittleFloat(sizebuf_t *sb)
Definition com_msg.c:307

References MSG_ReadLittleFloat().

Referenced by CL_ParseClientdata(), EntityState5_ReadUpdate(), EntityState_ReadFields(), and MSG_ReadCoord().

◆ MSG_ReadLittleFloat()

float MSG_ReadLittleFloat ( sizebuf_t * sb)

Definition at line 307 of file com_msg.c.

308{
309 union
310 {
311 float f;
312 int l;
313 } dat;
314 if (sb->readcount+4 > sb->cursize)
315 {
316 sb->badread = true;
317 return -1;
318 }
319 sb->readcount += 4;
320 dat.l = sb->data[sb->readcount-4] | (sb->data[sb->readcount-3]<<8) | (sb->data[sb->readcount-2]<<16) | ((unsigned)sb->data[sb->readcount-1]<<24);
321 return dat.f;
322}

References sizebuf_t::badread, sizebuf_t::cursize, sizebuf_t::data, f, and sizebuf_t::readcount.

Referenced by Mod_BSP_LoadSubmodels(), Mod_Q1BSP_LoadLeafs(), Mod_Q1BSP_LoadNodes(), Mod_Q1BSP_LoadPlanes(), Mod_Q1BSP_LoadTexinfo(), Mod_Q1BSP_LoadVertexes(), Mod_Q2BSP_LoadTexinfo(), Mod_VBSP_LoadPlanes(), Mod_VBSP_LoadTexinfo(), Mod_VBSP_LoadVertexes(), and MSG_ReadCoord32f().

◆ MSG_ReadLittleLong()

◆ MSG_ReadLittleShort()

◆ MSG_ReadString()

char * MSG_ReadString ( sizebuf_t * sb,
char * string,
size_t maxstring )

Definition at line 341 of file com_msg.c.

342{
343 size_t l = 0;
344
345 // read string into sbfer, but only store as many characters as will fit
346 // if dest buffer is full sb->readcount will still be advanced to end of message string
347 while ((string[l] = MSG_ReadByte_opt(sb)) != '\0')
348 if (l < maxstring)
349 ++l;
350 return string;
351}

References MSG_ReadByte_opt, and string.

Referenced by CL_ParseServerInfo(), CL_ParseServerMessage(), CL_ParseTempEntity(), NetConn_ClientParsePacket(), NetConn_ServerParsePacket(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_ServerInfo(), QW_CL_SetInfo(), QW_CL_UpdateUserInfo(), SHOWLMP_decodehide(), SHOWLMP_decodeshow(), and SV_ReadClientMessage().

◆ MSG_ReadString_len()

size_t MSG_ReadString_len ( sizebuf_t * sb,
char * string,
size_t maxstring )

Same as MSG_ReadString except it returns the number of bytes written to *string excluding the \0 terminator.

Definition at line 352 of file com_msg.c.

353{
354 size_t l = 0;
355
356 // read string into sbfer, but only store as many characters as will fit
357 // if dest buffer is full sb->readcount will still be advanced to end of message string
358 while ((string[l] = MSG_ReadByte_opt(sb)) != '\0')
359 if (l < maxstring)
360 ++l;
361 return l;
362}

References MSG_ReadByte_opt.

Referenced by CL_ParseServerMessage(), SV_ReadClientMessage(), VM_CL_ReadPicture(), and VM_CL_ReadString().

◆ MSG_ReadVector()

void MSG_ReadVector ( sizebuf_t * sb,
vec3_t v,
protocolversion_t protocol )

Definition at line 401 of file com_msg.c.

402{
403 v[0] = MSG_ReadCoord(sb, protocol);
404 v[1] = MSG_ReadCoord(sb, protocol);
405 v[2] = MSG_ReadCoord(sb, protocol);
406}
float MSG_ReadCoord(sizebuf_t *sb, protocolversion_t protocol)
Definition com_msg.c:389
const GLdouble * v
Definition glquake.h:762

References MSG_ReadCoord(), and v.

Referenced by CL_ParseBeam(), CL_ParseEffect(), CL_ParseEffect2(), CL_ParseParticleEffect(), CL_ParsePointParticles(), CL_ParsePointParticles1(), CL_ParseServerMessage(), CL_ParseStartSoundPacket(), CL_ParseStaticSound(), CL_ParseTempEntity(), CL_ParseTrailParticles(), EntityStateQW_ReadPlayerUpdate(), and V_ParseDamage().

◆ MSG_WriteAngle()

◆ MSG_WriteAngle16i()

void MSG_WriteAngle16i ( sizebuf_t * sb,
vec_t f )

Definition at line 227 of file com_msg.c.

228{
229 MSG_WriteShort (sb, (int)Q_rint(f*(65536.0/360.0)) & 65535);
230}
void MSG_WriteShort(sizebuf_t *sb, int c)
Definition com_msg.c:138
#define Q_rint(x)
Definition mathlib.h:69

References f, MSG_WriteShort(), and Q_rint.

Referenced by CL_SendMove(), EntityState5_WriteUpdate(), EntityState_WriteFields(), MSG_WriteAngle(), QW_MSG_WriteDeltaUsercmd(), and SV_WriteClientdataToMessage().

◆ MSG_WriteAngle32f()

void MSG_WriteAngle32f ( sizebuf_t * sb,
vec_t f )

Definition at line 232 of file com_msg.c.

233{
234 MSG_WriteFloat (sb, f);
235}
void MSG_WriteFloat(sizebuf_t *sb, float f)
Definition com_msg.c:158

References f, and MSG_WriteFloat().

Referenced by CL_SendMove().

◆ MSG_WriteAngle8i()

void MSG_WriteAngle8i ( sizebuf_t * sb,
vec_t f )

Definition at line 222 of file com_msg.c.

223{
224 MSG_WriteByte (sb, (int)Q_rint(f*(256.0/360.0)) & 255);
225}
void MSG_WriteByte(sizebuf_t *sb, int c)
Definition com_msg.c:130

References f, MSG_WriteByte(), and Q_rint.

Referenced by CL_SendMove(), EntityState5_WriteUpdate(), EntityState_WriteFields(), and MSG_WriteAngle().

◆ MSG_WriteByte()

void MSG_WriteByte ( sizebuf_t * sb,
int c )

Definition at line 130 of file com_msg.c.

131{
132 unsigned char *buf;
133
134 buf = SZ_GetSpace (sb, 1);
135 buf[0] = c;
136}
unsigned char * SZ_GetSpace(sizebuf_t *buf, int length)
Definition common.c:49

References buf, and SZ_GetSpace().

Referenced by CL_DisconnectEx(), CL_ForwardToServer(), CL_ParseServerInfo(), CL_PQRcon_f(), CL_SendMove(), CL_SendPlayerInfo(), CL_SetInfo(), CL_SignonReply(), CL_Stop_f(), Cvar_SetQuick_Internal(), EntityFrame4_WriteFrame(), EntityFrame5_WriteFrame(), EntityFrame_WriteFrame(), EntityFrameCSQC_WriteFrame(), EntityFrameQuake_WriteFrame(), EntityState5_WriteUpdate(), EntityState_WriteExtendBits(), EntityState_WriteFields(), MakeDownloadPacket(), MSG_WriteAngle8i(), NetConn_ClientFrame(), NetConn_ServerParsePacket(), Protocol_WriteStatsReliable(), QW_CL_CheckOrDownloadFile(), QW_CL_NextUpload_f(), QW_CL_ParseDownload(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_RequestNextDownload(), QW_MSG_WriteDeltaUsercmd(), Sbar_DeathmatchOverlay(), SV_BroadcastPrint(), SV_ClientCommands(), SV_ClientPrint(), SV_Color_f(), SV_CreateBaseline(), SV_DropClient(), SV_ModelIndex(), SV_Name(), SV_Pause_f(), SV_Pings_f(), SV_PreSpawn_f(), SV_SendClientDatagram(), SV_SendServerinfo(), SV_SoundIndex(), SV_Spawn_f(), SV_SpawnServer(), SV_StartEffect(), SV_StartParticle(), SV_StartPointSound(), SV_StartSound(), SV_StopDemoRecording(), SV_UpdateToReliableMessages(), SV_WriteClientdataToMessage(), SV_WriteNetnameIntoDemo(), VM_M_WriteByte(), VM_SV_ambientsound(), VM_SV_makestatic(), VM_SV_pointparticles(), VM_SV_setcolor(), VM_SV_setpause(), VM_SV_te_beam(), VM_SV_te_blood(), VM_SV_te_bloodshower(), VM_SV_te_customflash(), VM_SV_te_explosion(), VM_SV_te_explosion2(), VM_SV_te_explosionquad(), VM_SV_te_explosionrgb(), VM_SV_te_flamejet(), VM_SV_te_gunshot(), VM_SV_te_gunshotquad(), VM_SV_te_knightspike(), VM_SV_te_lavasplash(), VM_SV_te_lightning1(), VM_SV_te_lightning2(), VM_SV_te_lightning3(), VM_SV_te_particlecube(), VM_SV_te_particlerain(), VM_SV_te_particlesnow(), VM_SV_te_plasmaburn(), VM_SV_te_smallflash(), VM_SV_te_spark(), VM_SV_te_spike(), VM_SV_te_spikequad(), VM_SV_te_superspike(), VM_SV_te_superspikequad(), VM_SV_te_tarexplosion(), VM_SV_te_teleport(), VM_SV_te_wizspike(), VM_SV_trailparticles(), and VM_SV_WriteByte().

◆ MSG_WriteChar()

◆ MSG_WriteCoord()

void MSG_WriteCoord ( sizebuf_t * sb,
vec_t f,
protocolversion_t protocol )

Definition at line 202 of file com_msg.c.

203{
204 if (protocol == PROTOCOL_QUAKE || protocol == PROTOCOL_QUAKEDP || protocol == PROTOCOL_NEHAHRAMOVIE || protocol == PROTOCOL_NEHAHRABJP || protocol == PROTOCOL_NEHAHRABJP2 || protocol == PROTOCOL_NEHAHRABJP3 || protocol == PROTOCOL_QUAKEWORLD)
205 MSG_WriteCoord13i (sb, f);
206 else if (protocol == PROTOCOL_DARKPLACES1)
207 MSG_WriteCoord32f (sb, f);
208 else if (protocol == PROTOCOL_DARKPLACES2 || protocol == PROTOCOL_DARKPLACES3 || protocol == PROTOCOL_DARKPLACES4)
209 MSG_WriteCoord16i (sb, f);
210 else
211 MSG_WriteCoord32f (sb, f);
212}
void MSG_WriteCoord32f(sizebuf_t *sb, float f)
Definition com_msg.c:197
void MSG_WriteCoord13i(sizebuf_t *sb, float f)
Definition com_msg.c:187
void MSG_WriteCoord16i(sizebuf_t *sb, float f)
Definition com_msg.c:192

References f, MSG_WriteCoord13i(), MSG_WriteCoord16i(), MSG_WriteCoord32f(), PROTOCOL_DARKPLACES1, PROTOCOL_DARKPLACES2, PROTOCOL_DARKPLACES3, PROTOCOL_DARKPLACES4, PROTOCOL_NEHAHRABJP, PROTOCOL_NEHAHRABJP2, PROTOCOL_NEHAHRABJP3, PROTOCOL_NEHAHRAMOVIE, PROTOCOL_QUAKE, PROTOCOL_QUAKEDP, and PROTOCOL_QUAKEWORLD.

Referenced by EntityFrameQuake_WriteFrame(), MSG_WriteVector(), SV_CreateBaseline(), SV_StartEffect(), SV_StartParticle(), SV_StartPointSound(), SV_StartSound(), SV_WriteClientdataToMessage(), VM_M_WriteCoord(), VM_SV_makestatic(), VM_SV_te_beam(), VM_SV_te_blood(), VM_SV_te_bloodshower(), VM_SV_te_customflash(), VM_SV_te_explosion(), VM_SV_te_explosion2(), VM_SV_te_explosionquad(), VM_SV_te_explosionrgb(), VM_SV_te_flamejet(), VM_SV_te_gunshot(), VM_SV_te_gunshotquad(), VM_SV_te_knightspike(), VM_SV_te_lavasplash(), VM_SV_te_lightning1(), VM_SV_te_lightning2(), VM_SV_te_lightning3(), VM_SV_te_particlecube(), VM_SV_te_particlerain(), VM_SV_te_particlesnow(), VM_SV_te_plasmaburn(), VM_SV_te_smallflash(), VM_SV_te_spark(), VM_SV_te_spike(), VM_SV_te_spikequad(), VM_SV_te_superspike(), VM_SV_te_superspikequad(), VM_SV_te_tarexplosion(), VM_SV_te_teleport(), VM_SV_te_wizspike(), and VM_SV_WriteCoord().

◆ MSG_WriteCoord13i()

void MSG_WriteCoord13i ( sizebuf_t * sb,
vec_t f )

Definition at line 187 of file com_msg.c.

188{
189 MSG_WriteShort (sb, Q_rint(f*8));
190}

References f, MSG_WriteShort(), and Q_rint.

Referenced by EntityState5_WriteUpdate(), and MSG_WriteCoord().

◆ MSG_WriteCoord16i()

void MSG_WriteCoord16i ( sizebuf_t * sb,
vec_t f )

Definition at line 192 of file com_msg.c.

193{
194 MSG_WriteShort (sb, Q_rint(f));
195}

References f, MSG_WriteShort(), and Q_rint.

Referenced by CL_SendMove(), EntityState_WriteFields(), MSG_WriteCoord(), and SV_WriteClientdataToMessage().

◆ MSG_WriteCoord32f()

void MSG_WriteCoord32f ( sizebuf_t * sb,
vec_t f )

Definition at line 197 of file com_msg.c.

198{
199 MSG_WriteFloat (sb, f);
200}

References f, and MSG_WriteFloat().

Referenced by EntityState5_WriteUpdate(), EntityState_WriteFields(), MSG_WriteCoord(), and SV_WriteClientdataToMessage().

◆ MSG_WriteFloat()

void MSG_WriteFloat ( sizebuf_t * sb,
vec_t f )

Definition at line 158 of file com_msg.c.

159{
160 union
161 {
162 float f;
163 int l;
164 } dat;
165
166
167 dat.f = f;
168 dat.l = LittleLong (dat.l);
169
170 SZ_Write (sb, (unsigned char *)&dat.l, 4);
171}
void SZ_Write(sizebuf_t *buf, const unsigned char *data, int length)
Definition common.c:72
#define LittleLong(l)
Definition common.h:92

References f, LittleLong, and SZ_Write().

Referenced by CL_SendMove(), EntityFrame_WriteFrame(), EntityFrameQuake_WriteFrame(), MSG_WriteAngle32f(), MSG_WriteCoord32f(), SV_SendClientDatagram(), and SV_Spawn_f().

◆ MSG_WriteLong()

◆ MSG_WriteShort()

◆ MSG_WriteString()

◆ MSG_WriteUnterminatedString()

void MSG_WriteUnterminatedString ( sizebuf_t * sb,
const char * s )

Definition at line 181 of file com_msg.c.

182{
183 if (s && *s)
184 SZ_Write (sb, (unsigned char *)s, (int)strlen(s));
185}

References strlen(), and SZ_Write().

Referenced by NetConn_ServerParsePacket(), SCR_CaptureVideo_RIFF_IndexEntry(), SCR_CaptureVideo_RIFF_WriteFourCC(), SV_Pings_f(), SV_WriteNetnameIntoDemo(), and VM_SV_WriteUnterminatedString().

◆ MSG_WriteVector()

void MSG_WriteVector ( sizebuf_t * sb,
const vec3_t v,
protocolversion_t protocol )

Definition at line 214 of file com_msg.c.

215{
216 MSG_WriteCoord (sb, v[0], protocol);
217 MSG_WriteCoord (sb, v[1], protocol);
218 MSG_WriteCoord (sb, v[2], protocol);
219}
void MSG_WriteCoord(sizebuf_t *sb, float f, protocolversion_t protocol)
Definition com_msg.c:202

References MSG_WriteCoord(), and v.

Referenced by VM_SV_ambientsound(), VM_SV_pointparticles(), and VM_SV_trailparticles().

◆ StoreBigLong()

void StoreBigLong ( unsigned char * buffer,
unsigned int i )

Encode a big endian 32bit int to the given buffer.

Definition at line 81 of file com_msg.c.

82{
83 buffer[0] = (i >> 24) & 0xFF;
84 buffer[1] = (i >> 16) & 0xFF;
85 buffer[2] = (i >> 8) & 0xFF;
86 buffer[3] = i & 0xFF;
87}

References buffer, and i.

Referenced by CL_PQRcon_f(), Con_Rcon_Redirect_Flush(), NetConn_ClientFrame(), NetConn_ReceivedMessage(), NetConn_SendUnreliableMessage(), and NetConn_ServerParsePacket().

◆ StoreBigShort()

void StoreBigShort ( unsigned char * buffer,
unsigned short i )

Encode a big endian 16bit int to the given buffer.

Definition at line 89 of file com_msg.c.

90{
91 buffer[0] = (i >> 8) & 0xFF;
92 buffer[1] = i & 0xFF;
93}

References buffer, and i.

◆ StoreLittleLong()

void StoreLittleLong ( unsigned char * buffer,
unsigned int i )

Encode a little endian 32bit int to the given buffer.

Definition at line 95 of file com_msg.c.

96{
97 buffer[0] = i & 0xFF;
98 buffer[1] = (i >> 8) & 0xFF;
99 buffer[2] = (i >> 16) & 0xFF;
100 buffer[3] = (i >> 24) & 0xFF;
101}

References buffer, and i.

Referenced by NetConn_SendUnreliableMessage(), and R_SaveTextureDDSFile().

◆ StoreLittleShort()

void StoreLittleShort ( unsigned char * buffer,
unsigned short i )

Encode a little endian 16bit int to the given buffer.

Definition at line 103 of file com_msg.c.

104{
105 buffer[0] = i & 0xFF;
106 buffer[1] = (i >> 8) & 0xFF;
107}

References buffer, and i.

◆ SZ_Clear()

◆ SZ_GetSpace()

unsigned char * SZ_GetSpace ( sizebuf_t * buf,
int length )

Definition at line 49 of file common.c.

50{
51 unsigned char *data;
52
53 if (buf->cursize + length > buf->maxsize)
54 {
55 if (!buf->allowoverflow)
56 Host_Error ("SZ_GetSpace: overflow without allowoverflow set");
57
58 if (length > buf->maxsize)
59 Host_Error ("SZ_GetSpace: %i is > full buffer size", length);
60
61 buf->overflowed = true;
62 Con_Print("SZ_GetSpace: overflow\n");
63 SZ_Clear (buf);
64 }
65
66 data = buf->data + buf->cursize;
67 buf->cursize += length;
68
69 return data;
70}
void SZ_Clear(sizebuf_t *buf)
Definition common.c:44
void Host_Error(const char *error,...)
Definition host.c:85

References buf, Con_Print(), data, Host_Error(), length, and SZ_Clear().

Referenced by MSG_WriteByte(), MSG_WriteChar(), MSG_WriteLong(), MSG_WriteShort(), and SZ_Write().

◆ SZ_HexDumpToConsole()

void SZ_HexDumpToConsole ( const sizebuf_t * buf)

Definition at line 148 of file common.c.

149{
150 Com_HexDumpToConsole(buf->data, buf->cursize);
151}
void Com_HexDumpToConsole(const unsigned char *data, int size)
Definition common.c:82

References buf, and Com_HexDumpToConsole().

Referenced by CL_Parse_DumpPacket(), and NetConn_SendUnreliableMessage().

◆ SZ_Write()

◆ va()

char * va ( char * buf,
size_t buflen,
const char * format,
... )

Definition at line 972 of file common.c.

973{
974 va_list argptr;
975
976 va_start (argptr, format);
977 dpvsnprintf (buf, buflen, format,argptr);
978 va_end (argptr);
979
980 return buf;
981}

References buf, dpvsnprintf(), and format.

Referenced by CheckPendingDownloads(), CL_BeginDownloads(), CL_Bottomcolor_c(), CL_Color_c(), CL_FinishTimeDemo(), CL_LinkNetworkEntity(), CL_ParseServerInfo(), CL_SendCvar_f(), CL_SendPlayerInfo(), CL_SetInfo(), CL_Topcolor_c(), CL_VM_Init(), Cmd_Apropos_f(), Cmd_GetDirectCvarValue(), CompressedImageCache_Add(), CompressedImageCache_Find(), Con_CompleteCommandLine(), Crypto_BuildIdString(), Crypto_ClientParsePacket(), Crypto_KeyGen_f(), Crypto_KeyGen_Finished(), Crypto_LoadFile(), Crypto_LoadKeys(), Crypto_SavePubKeyTextFile(), Crypto_ServerParsePacket_Internal(), Cvar_List_f(), Font_LoadFont(), FS_AddGameHierarchy(), FS_CheckGameDir(), FS_ChooseUserDir(), FS_Init_Dir(), FS_ListGameDirs(), FS_Rescan(), FS_SysCheckGameDir(), gl_draw_start(), Host_Init(), Host_LockSession(), Key_Event(), Key_History_f(), Key_History_Find_All(), Key_History_Find_Backwards(), Key_History_Find_Forwards(), Key_Message(), LightCubemapNumToName(), loadimagepixelsbgra(), M_Demo_Key(), M_Draw(), M_GameOptions_Draw(), M_GameOptions_Key(), M_Help_Draw(), M_LanConfig_Draw(), M_LanConfig_Key(), M_Load_Key(), M_Main_Draw(), M_MultiPlayer_Draw(), M_Save_Key(), M_ServerList_Draw(), M_ServerList_Key(), M_Setup_Draw(), M_Setup_Key(), M_SinglePlayer_Draw(), M_Transfusion_Episode_Draw(), M_Transfusion_Skill_Draw(), M_Video_Draw(), MakeDownloadPacket(), Mod_Decompile_f(), Mod_GenerateLightmaps_CreateLightmaps(), Mod_INTERQUAKEMODEL_Load(), Mod_LoadModel(), Mod_LoadSkinFiles(), Mod_Q1BSP_LoadFaces(), Mod_Q1BSP_LoadTextures(), Mod_Q3BSP_LoadLightmaps(), Mod_VBSP_LoadFaces(), PRVM_Breakpoint(), PRVM_Crash(), PRVM_ED_CallSpawnFunction(), PRVM_ED_Write(), PRVM_ED_WriteGlobals(), PRVM_IsEdictRelevant(), PRVM_Prog_Load(), PRVM_ShortStackTrace(), PRVM_WhereAmI(), QW_CL_CheckOrDownloadFile(), QW_CL_ParseModelList(), QW_CL_ParseSoundList(), QW_CL_RequestNextDownload(), R_LoadSkyBox(), R_RenderTarget_Get(), R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(), R_SkinFrame_GenerateTexturesFromQPixels(), R_SkinFrame_LoadExternal_SkinFrame(), R_SkinFrame_LoadInternal8bit(), R_SkinFrame_LoadInternalBGRA(), RCon_Authenticate(), Sbar_DeathmatchOverlay(), Sbar_Draw(), Sbar_DrawCharacter(), Sbar_DrawWeapon(), Sbar_PrintScoreboardItem(), Sbar_SoloScoreboard(), sbar_start(), SCR_CaptureVideo_Avi_BeginVideo(), SCR_CaptureVideo_Ogg_BeginVideo(), SCR_DrawLoadingScreen(), SCR_DrawNetGraph(), SCR_ScreenShot_f(), SND_Spatialize_WithSfx(), SV_Kick_f(), SV_SaveEntFile_f(), SV_SendServerinfo(), SV_SpawnServer(), SV_TimingReport(), VID_Mode(), VID_Restart_f(), VM_buf_loadfile(), VM_changelevel(), VM_findkeysforcommand(), VM_fopen(), and VM_sprintf().

◆ XPM_DecodeString()

char ** XPM_DecodeString ( const char * in)

Definition at line 1459 of file common.c.

1460{
1461 static char *tokens[257];
1462 static char lines[257][512];
1463 size_t line = 0;
1464
1465 // skip until "{" token
1466 while(COM_ParseToken_QuakeC(&in, false) && strcmp(com_token, "{"));
1467
1468 // now, read in succession: string, comma-or-}
1469 while(COM_ParseToken_QuakeC(&in, false))
1470 {
1471 tokens[line] = lines[line];
1472 dp_strlcpy(lines[line++], com_token, sizeof(lines[0]));
1473 if(!COM_ParseToken_QuakeC(&in, false))
1474 return NULL;
1475 if(!strcmp(com_token, "}"))
1476 break;
1477 if(strcmp(com_token, ","))
1478 return NULL;
1479 if(line >= sizeof(tokens) / sizeof(tokens[0]))
1480 return NULL;
1481 }
1482
1483 return tokens;
1484}
qbool COM_ParseToken_QuakeC(const char **datapointer, qbool returnnewline)
Definition common.c:581
#define dp_strlcpy(dst, src, dsize)
Definition common.h:303
static int tokens[VM_TEMPSTRING_MAXSIZE/2]
Definition prvm_cmds.c:2659

References COM_ParseToken_QuakeC(), com_token, dp_strlcpy, NULL, and tokens.

Variable Documentation

◆ cmdline

struct cvar_s cmdline
extern

Definition at line 33 of file common.c.

33{CF_CLIENT | CF_SERVER | CF_READONLY, "cmdline","0", "contains commandline the engine was launched with"};
#define CF_READONLY
cvar cannot be changed from the console or the command buffer, and is considered CF_PERSISTENT
Definition cmd.h:54
#define CF_SERVER
cvar/command that only the server can change/execute
Definition cmd.h:49
#define CF_CLIENT
cvar/command that only the client can change/execute
Definition cmd.h:48

Referenced by CL_FinishTimeDemo(), COM_Init_Commands(), and COM_InitGameType().

◆ com_token

◆ com_token_len

◆ registered

struct cvar_s registered
extern

Definition at line 32 of file common.c.

32{CF_CLIENT | CF_SERVER | CF_READONLY, "registered","0", "indicates if this is running registered quake (whether gfx/pop.lmp was found)"};

Referenced by COM_Init_Commands(), FS_Rescan(), and M_Menu_GameOptions_f().