engine: common: net_buffer: add MSG_WriteStringf wrapper

This commit is contained in:
Alibek Omarov 2023-03-13 05:12:46 +03:00
parent fb6e310eab
commit fb2ba6a6e2
2 changed files with 13 additions and 0 deletions

View File

@ -452,6 +452,18 @@ qboolean MSG_WriteString( sizebuf_t *sb, const char *pStr )
return !sb->bOverflow;
}
qboolean MSG_WriteStringf( sizebuf_t *sb, const char *format, ... )
{
va_list va;
char buf[MAX_VA_STRING];
va_start( va, format );
Q_vsnprintf( buf, sizeof( buf ), format, va );
va_end( va );
return MSG_WriteString( sb, buf );
}
int MSG_ReadOneBit( sizebuf_t *sb )
{
if( !MSG_Overflow( sb, 1 ))

View File

@ -102,6 +102,7 @@ void MSG_WriteVec3Coord( sizebuf_t *sb, const float *fa );
void MSG_WriteVec3Angles( sizebuf_t *sb, const float *fa );
qboolean MSG_WriteBytes( sizebuf_t *sb, const void *pBuf, int nBytes ); // same as MSG_WriteData
qboolean MSG_WriteString( sizebuf_t *sb, const char *pStr ); // returns false if it overflows the buffer.
qboolean MSG_WriteStringf( sizebuf_t *sb, const char *format, ... ) _format( 2 );
// helper functions
_inline int MSG_GetNumBytesWritten( sizebuf_t *sb ) { return BitByte( sb->iCurBit ); }