summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
author/dev/humancontroller <devhc@example.com>2014-07-13 00:00:27 +0200
committer/dev/humancontroller <devhc@example.com>2017-03-09 13:51:08 +0100
commit7ba2937407eec4a6791c0d1b4b24d595bc25bcaf (patch)
tree22af4101be86719ab894f3a8cacc54efc282c294 /src/qcommon
parent6da44ba3d5497a30c1f5b13af38bc9fe991d06d2 (diff)
allow >127 ordinal characters in string transmission
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/msg.c69
1 files changed, 13 insertions, 56 deletions
diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c
index f7001d7b..6e0b88c4 100644
--- a/src/qcommon/msg.c
+++ b/src/qcommon/msg.c
@@ -308,56 +308,25 @@ void MSG_WriteFloat( msg_t *sb, float f ) {
MSG_WriteBits( sb, dat.i, 32 );
}
-void MSG_WriteString( msg_t *sb, const char *s ) {
- if ( !s ) {
- MSG_WriteData (sb, "", 1);
- } else {
- int l,i;
- char string[MAX_STRING_CHARS];
+static void MSG_WriteString2( msg_t *sb, const char *s, int maxsize )
+{
+ int size = strlen( s ) + 1;
- l = strlen( s );
- if ( l >= MAX_STRING_CHARS ) {
- Com_Printf( "MSG_WriteString: MAX_STRING_CHARS" );
- MSG_WriteData (sb, "", 1);
- return;
- }
- Q_strncpyz( string, s, sizeof( string ) );
+ if ( size > maxsize ) {
+ Com_Printf( "MSG_WriteString2: %i > %i\n", size, maxsize );
+ MSG_WriteData( sb, "", 1 );
+ return;
+ }
- // get rid of 0x80+ chars, because old clients don't like them
- for ( i = 0 ; i < l ; i++ ) {
- if ( ((byte *)string)[i] > 127 ) {
- string[i] = '.';
- }
- }
+ MSG_WriteData( sb, s, size );
+}
- MSG_WriteData (sb, string, l+1);
- }
+void MSG_WriteString( msg_t *sb, const char *s ) {
+ MSG_WriteString2( sb, s, MAX_STRING_CHARS );
}
void MSG_WriteBigString( msg_t *sb, const char *s ) {
- if ( !s ) {
- MSG_WriteData (sb, "", 1);
- } else {
- int l,i;
- char string[BIG_INFO_STRING];
-
- l = strlen( s );
- if ( l >= BIG_INFO_STRING ) {
- Com_Printf( "MSG_WriteString: BIG_INFO_STRING" );
- MSG_WriteData (sb, "", 1);
- return;
- }
- Q_strncpyz( string, s, sizeof( string ) );
-
- // get rid of 0x80+ chars, because old clients don't like them
- for ( i = 0 ; i < l ; i++ ) {
- if ( ((byte *)string)[i] > 127 ) {
- string[i] = '.';
- }
- }
-
- MSG_WriteData (sb, string, l+1);
- }
+ MSG_WriteString2( sb, s, BIG_INFO_STRING );
}
void MSG_WriteAngle( msg_t *sb, float f ) {
@@ -451,10 +420,6 @@ char *MSG_ReadString( msg_t *msg ) {
if ( c == -1 || c == 0 ) {
break;
}
- // don't allow higher ascii values
- if ( c > 127 ) {
- c = '.';
- }
string[l] = c;
l++;
@@ -475,10 +440,6 @@ char *MSG_ReadBigString( msg_t *msg ) {
if ( c == -1 || c == 0 ) {
break;
}
- // don't allow higher ascii values
- if ( c > 127 ) {
- c = '.';
- }
string[l] = c;
l++;
@@ -499,10 +460,6 @@ char *MSG_ReadStringLine( msg_t *msg ) {
if (c == -1 || c == 0 || c == '\n') {
break;
}
- // don't allow higher ascii values
- if ( c > 127 ) {
- c = '.';
- }
string[l] = c;
l++;