From d95d025a1bbfcdd43f1d13e1aedceed53c28d7cf Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Sun, 7 Oct 2007 21:08:14 +0000 Subject: Use MSG_WriteData instead of MSG_WriteString when possible. Dropped check for \xff byte inside MSG_WriteString, clients nowadays should not use 3.20 anyway. --- source/sv_send.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'source/sv_send.c') diff --git a/source/sv_send.c b/source/sv_send.c index 02369a2..1e981a3 100644 --- a/source/sv_send.c +++ b/source/sv_send.c @@ -117,17 +117,18 @@ NOT archived in MVD stream. void SV_ClientPrintf( client_t *client, int level, const char *fmt, ... ) { va_list argptr; char string[MAX_STRING_CHARS]; + int length; if( level < client->messagelevel ) return; va_start( argptr, fmt ); - Q_vsnprintf( string, sizeof( string ), fmt, argptr ); + length = Q_vsnprintf( string, sizeof( string ), fmt, argptr ); va_end( argptr ); MSG_WriteByte( svc_print ); MSG_WriteByte( level ); - MSG_WriteString( string ); + MSG_WriteData( string, length + 1 ); SV_ClientAddMessage( client, MSG_RELIABLE|MSG_CLEAR ); } @@ -144,15 +145,15 @@ void SV_BroadcastPrintf( int level, const char *fmt, ... ) { va_list argptr; char string[MAX_STRING_CHARS]; client_t *client; - int i; + int i, length; va_start( argptr, fmt ); - Q_vsnprintf( string, sizeof( string ), fmt, argptr ); + length = Q_vsnprintf( string, sizeof( string ), fmt, argptr ); va_end( argptr ); MSG_WriteByte( svc_print ); MSG_WriteByte( level ); - MSG_WriteString( string ); + MSG_WriteData( string, length + 1 ); // echo to console if( dedicated->integer ) { @@ -176,13 +177,14 @@ void SV_BroadcastPrintf( int level, const char *fmt, ... ) { void SV_ClientCommand( client_t *client, const char *fmt, ... ) { va_list argptr; char string[MAX_STRING_CHARS]; + int length; va_start( argptr, fmt ); - Q_vsnprintf( string, sizeof( string ), fmt, argptr ); + length = Q_vsnprintf( string, sizeof( string ), fmt, argptr ); va_end( argptr ); MSG_WriteByte( svc_stufftext ); - MSG_WriteString( string ); + MSG_WriteData( string, length + 1 ); SV_ClientAddMessage( client, MSG_RELIABLE|MSG_CLEAR ); } @@ -199,13 +201,14 @@ void SV_BroadcastCommand( const char *fmt, ... ) { va_list argptr; char string[MAX_STRING_CHARS]; client_t *client; + int length; va_start( argptr, fmt ); - Q_vsnprintf( string, sizeof( string ), fmt, argptr ); + length = Q_vsnprintf( string, sizeof( string ), fmt, argptr ); va_end( argptr ); MSG_WriteByte( svc_stufftext ); - MSG_WriteString( string ); + MSG_WriteData( string, length + 1 ); FOR_EACH_CLIENT( client ) { SV_ClientAddMessage( client, MSG_RELIABLE ); -- cgit v1.2.3