32# define strcasecmp _stricmp
33# define strncasecmp _strnicmp
39#if defined(__APPLE__) && defined(__MACH__)
46#define ContainerOf(ptr, type, member) ((type *)((char *)(ptr) - offsetof(type, member)))
48typedef struct sizebuf_s
89#define BigShort(l) BuffBigShort((unsigned char *)&(l))
90#define LittleShort(l) BuffLittleShort((unsigned char *)&(l))
91#define BigLong(l) BuffBigLong((unsigned char *)&(l))
92#define LittleLong(l) BuffLittleLong((unsigned char *)&(l))
93#define BigFloat(l) BuffBigFloat((unsigned char *)&(l))
94#define LittleFloat(l) BuffLittleFloat((unsigned char *)&(l))
131typedef enum protocolversion_e
187#define MSG_ReadChar(sb) ((sb)->readcount >= (sb)->cursize ? ((sb)->badread = true, -1) : (signed char)(sb)->data[(sb)->readcount++])
188#define MSG_ReadByte(sb) ((sb)->readcount >= (sb)->cursize ? ((sb)->badread = true, -1) : (unsigned char)(sb)->data[(sb)->readcount++])
190#define MSG_ReadByte_opt(sb) ((sb)->readcount >= (sb)->cursize ? ((sb)->badread = true, '\0') : (unsigned char)(sb)->data[(sb)->readcount++])
191#define MSG_ReadShort MSG_ReadLittleShort
192#define MSG_ReadLong MSG_ReadLittleLong
193#define MSG_ReadFloat MSG_ReadLittleFloat
231#define DP_STATIC_ASSERT(expr, str) _Static_assert(expr, str)
233#define DP_STATIC_ASSERT(expr, str) static_assert(expr, str)
238#define snprintf DP_STATIC_ASSERT(0, "snprintf is forbidden for portability reasons. Use dpsnprintf instead.")
240#define vsnprintf DP_STATIC_ASSERT(0, "vsnprintf is forbidden for portability reasons. Use dpvsnprintf instead.")
255#define strcat DP_STATIC_ASSERT(0, "strcat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")
257#define strncat DP_STATIC_ASSERT(0, "strncat is forbidden for security reasons. Use dp_strlcat or memcpy instead.")
259#define strcpy DP_STATIC_ASSERT(0, "strcpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")
261#define strncpy DP_STATIC_ASSERT(0, "strncpy is forbidden for security reasons. Use dp_strlcpy or memcpy instead.")
263#define stpcpy DP_STATIC_ASSERT(0, "stpcpy is forbidden for security reasons. Use dp_stpecpy or memcpy instead.")
265#define ustpcpy DP_STATIC_ASSERT(0, "ustpcpy is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")
267#define ustr2stp DP_STATIC_ASSERT(0, "ustr2stp is forbidden for security reasons. Use dp_ustr2stp or memcpy instead.")
269#define sprintf DP_STATIC_ASSERT(0, "sprintf is forbidden for security reasons. Use dpsnprintf instead.")
272#define strlcpy DP_STATIC_ASSERT(0, "strlcpy is forbidden for stability and correctness. See common.h and common.c comments.")
274#define strlcat DP_STATIC_ASSERT(0, "strlcat is forbidden for stability and correctness. See common.h and common.c comments.")
282typedef enum userdirmode_e
297int COM_ReadAndTokenizeLine(
const char **text,
char **
argv,
int maxargc,
char *tokenbuf,
int tokenbufsize,
const char *commentprefix);
303#define dp_strlcpy(dst, src, dsize) dp__strlcpy(dst, src, dsize, __func__, __LINE__)
304#define dp_strlcat(dst, src, dsize) dp__strlcat(dst, src, dsize, __func__, __LINE__)
305size_t dp__strlcpy(
char *dst,
const char *
src,
size_t dsize,
const char *func,
unsigned line);
306size_t dp__strlcat(
char *dst,
const char *
src,
size_t dsize,
const char *func,
unsigned line);
308char *
dp_ustr2stp(
char *dst,
size_t dsize,
const char *
src,
size_t slen);
311void FindFraction(
double val,
int *num,
int *denom,
int denomMax);
318#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
void MSG_BeginReading(sizebuf_t *sb)
int MSG_ReadBigShort(sizebuf_t *sb)
char * MSG_ReadString(sizebuf_t *sb, char *string, size_t maxstring)
void SZ_Clear(sizebuf_t *buf)
void StoreBigShort(unsigned char *buffer, unsigned short i)
Encode a big endian 16bit int to the given buffer.
char * va(char *buf, size_t buflen, const char *format,...) DP_FUNC_PRINTF(3)
void MSG_WriteCoord(sizebuf_t *sb, vec_t f, protocolversion_t protocol)
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 ...
float BuffLittleFloat(const unsigned char *buffer)
Extract a little endian 32bit float from the given buffer.
float MSG_ReadAngle(sizebuf_t *sb, protocolversion_t protocol)
void MSG_WriteShort(sizebuf_t *sb, int c)
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.
void MSG_ReadVector(sizebuf_t *sb, vec3_t v, protocolversion_t protocol)
void MSG_WriteFloat(sizebuf_t *sb, vec_t f)
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...
int COM_StringBeginsWith(const char *s, const char *match)
void Com_BlockFullChecksum(void *buffer, int len, unsigned char *outbuf)
unsigned char * SZ_GetSpace(sizebuf_t *buf, int length)
unsigned Com_BlockChecksum(void *buffer, int length)
float MSG_ReadAngle32f(sizebuf_t *sb)
@ PROTOCOL_DARKPLACES2
various changes
@ PROTOCOL_DARKPLACES4
various changes
@ PROTOCOL_NEHAHRABJP2
same as NEHAHRABJP but with 16bit soundindex
@ PROTOCOL_DARKPLACES3
uses EntityFrame4 entity snapshot encoder/decoder which is broken, this attempted to do partial snaps...
@ PROTOCOL_NEHAHRABJP
same as QUAKEDP but with 16bit modelindex
@ PROTOCOL_DARKPLACES5
uses EntityFrame5 entity snapshot encoder/decoder which is based on a Tribes networking article at ht...
@ PROTOCOL_DARKPLACES7
added QuakeWorld-style movement protocol to allow more consistent prediction
@ PROTOCOL_QUAKEDP
darkplaces extended quake protocol (used by TomazQuake and others), backwards compatible as long as n...
@ PROTOCOL_DARKPLACES6
various changes
@ PROTOCOL_QUAKE
quake (aka netquake/normalquake/nq) protocol
@ PROTOCOL_DARKPLACES8
added parting messages. WIP
@ PROTOCOL_NEHAHRABJP3
same as NEHAHRABJP2 but with some changes
@ PROTOCOL_NEHAHRAMOVIE
Nehahra movie protocol, a big nasty hack dating back to early days of the Quake Standards Group (but ...
@ PROTOCOL_QUAKEWORLD
quakeworld protocol
@ PROTOCOL_DARKPLACES1
uses EntityFrame entity snapshot encoder/decoder which is a QuakeWorld-like entity snapshot delta com...
void MSG_WriteString(sizebuf_t *sb, const char *s)
char com_token[MAX_INPUTLINE]
float MSG_ReadCoord32f(sizebuf_t *sb)
void StoreLittleShort(unsigned char *buffer, unsigned short i)
Encode a little endian 16bit int to the given buffer.
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 ...
float MSG_ReadLittleFloat(sizebuf_t *sb)
size_t MSG_ReadBytes(sizebuf_t *sb, size_t numbytes, unsigned char *out)
qbool COM_ParseToken_QuakeC(const char **datapointer, qbool returnnewline)
short BuffLittleShort(const unsigned char *buffer)
Extract a little endian 16bit short from the given buffer.
void MSG_WriteLong(sizebuf_t *sb, int c)
char * dp_stpecpy(char *dst, char *end, const char *src)
Chain-copies a string with truncation and efficiency (compared to strlcat()).
int MSG_ReadBigLong(sizebuf_t *sb)
void MSG_InitReadBuffer(sizebuf_t *buf, unsigned char *data, int size)
int(* COM_LineProcessorFunc)(void *passthrough, const char *line, size_t length, float width, qbool isContination)
float(* COM_WordWidthFunc_t)(void *passthrough, const char *w, size_t *length, float maxWidth)
char ** XPM_DecodeString(const char *in)
float MSG_ReadCoord13i(sizebuf_t *sb)
float MSG_ReadAngle8i(sizebuf_t *sb)
size_t COM_StringDecolorize(const char *in, size_t size_in, char *out, size_t size_out, qbool escape_carets)
float MSG_ReadAngle16i(sizebuf_t *sb)
void MSG_WriteAngle8i(sizebuf_t *sb, vec_t f)
qbool COM_ParseToken_VM_Tokenize(const char **datapointer, qbool returnnewline)
qbool COM_ParseToken_Console(const char **datapointer)
void MSG_WriteByte(sizebuf_t *sb, int c)
void MSG_WriteAngle32f(sizebuf_t *sb, vec_t f)
void MSG_WriteVector(sizebuf_t *sb, const vec3_t v, protocolversion_t protocol)
void MSG_WriteCoord32f(sizebuf_t *sb, vec_t f)
float Com_CalcRoll(const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval)
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.
float BuffBigFloat(const unsigned char *buffer)
Extract a big endian 32bit float from the given buffer.
float MSG_ReadBigFloat(sizebuf_t *sb)
int BuffLittleLong(const unsigned char *buffer)
Extract a little endian 32bit int from the given buffer.
float MSG_ReadCoord(sizebuf_t *sb, protocolversion_t protocol)
void MSG_WriteUnterminatedString(sizebuf_t *sb, const char *s)
void Com_HexDumpToConsole(const unsigned char *data, int size)
int MSG_ReadLittleLong(sizebuf_t *sb)
void SZ_HexDumpToConsole(const sizebuf_t *buf)
void MSG_WriteCoord16i(sizebuf_t *sb, vec_t f)
int COM_Wordwrap(const char *string, size_t length, float continuationSize, float maxWidth, COM_WordWidthFunc_t wordWidth, void *passthroughCW, COM_LineProcessorFunc processLine, void *passthroughPL)
void FindFraction(double val, int *num, int *denom, int denomMax)
float MSG_ReadCoord16i(sizebuf_t *sb)
int MSG_ReadLittleShort(sizebuf_t *sb)
void MSG_WriteAngle(sizebuf_t *sb, vec_t f, protocolversion_t protocol)
short BuffBigShort(const unsigned char *buffer)
Extract a big endian 16bit short from the given buffer.
void MSG_WriteCoord13i(sizebuf_t *sb, vec_t f)
unsigned short CRC_Block(const unsigned char *data, size_t size)
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 term...
unsigned short CRC_Block_CaseInsensitive(const unsigned char *data, size_t size)
void StoreLittleLong(unsigned char *buffer, unsigned int i)
Encode a little endian 32bit int to the given buffer.
void MSG_WriteChar(sizebuf_t *sb, int c)
size_t COM_StringLengthNoColors(const char *s, size_t size_s, qbool *valid)
void StoreBigLong(unsigned char *buffer, unsigned int i)
Encode a big endian 32bit int to the given buffer.
qbool COM_ParseToken_Simple(const char **datapointer, qbool returnnewline, qbool parsebackslash, qbool parsecomments)
int BuffBigLong(const unsigned char *buffer)
Extract a big endian 32bit int from the given buffer.
unsigned char COM_BlockSequenceCRCByteQW(unsigned char *base, int length, int sequence)
void COM_Init_Commands(void)
int COM_ReadAndTokenizeLine(const char **text, char **argv, int maxargc, char *tokenbuf, int tokenbufsize, const char *commentprefix)
void SZ_Write(sizebuf_t *buf, const unsigned char *data, int length)
void MSG_WriteAngle16i(sizebuf_t *sb, vec_t f)
size_t base64_encode(unsigned char *buf, size_t buflen, size_t outbuflen)
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 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...
static int(ZEXPORT *qz_inflate)(z_stream *strm
GLubyte GLubyte GLubyte GLubyte w
GLenum GLuint GLenum GLsizei length
GLint GLint GLint GLsizei GLsizei GLenum format
GLsizeiptr const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
#define MAX_INPUTLINE
maximum size of console commandline, QuakeC strings, and many other text processing buffers
#define DP_FUNC_PRINTF(n)
qbool overflowed
set to true if the buffer size failed
qbool allowoverflow
if false, do a Sys_Error