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/q_msg.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'source/q_msg.c') diff --git a/source/q_msg.c b/source/q_msg.c index f34bec9..1611dbc 100644 --- a/source/q_msg.c +++ b/source/q_msg.c @@ -146,7 +146,6 @@ MSG_WriteString */ void MSG_WriteString( const char *string ) { int length; - int c; if( !string ) { MSG_WriteByte( 0 ); @@ -154,21 +153,13 @@ void MSG_WriteString( const char *string ) { } length = strlen( string ); - if( length > MAX_NET_STRING - 1 ) { + if( length >= MAX_NET_STRING ) { Com_WPrintf( "MSG_WriteString: overflow: %d chars", length ); MSG_WriteByte( 0 ); return; } - while( *string ) { - c = *string++; - if( c == '\xFF' ) { - c = '.'; - } - MSG_WriteByte( c ); - } - - MSG_WriteByte( 0 ); + MSG_WriteData( string, length + 1 ); } /* @@ -443,10 +434,6 @@ void MSG_WriteDir( const vec3_t dir ) { MSG_WriteByte( best ); } -void MSG_WriteData( const void *data, int length ) { - memcpy( SZ_GetSpace( &msg_write, length ), data, length ); -} - /* values transmitted over network are discrete, so * we use special macros to check for delta conditions */ @@ -1396,6 +1383,7 @@ void MSG_FlushTo( sizebuf_t *dest ) { SZ_Clear( &msg_write ); } +// NOTE: does not NUL-terminate the string void MSG_Printf( const char *fmt, ... ) { char buffer[MAX_STRING_CHARS]; va_list argptr; -- cgit v1.2.3