summaryrefslogtreecommitdiff
path: root/src/qcommon/msg.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2009-10-13 17:17:27 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:49 +0000
commit6efd4cef3cfcc44d6727cb0e54da26fbb74a7533 (patch)
treefdb5ee764999ac868d00c54cefb8c290f1735fd6 /src/qcommon/msg.c
parentfafe107646105e680e2bd4a82d9330dffaf69c9a (diff)
* Merge ioq3-r1666
Diffstat (limited to 'src/qcommon/msg.c')
-rw-r--r--src/qcommon/msg.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c
index 3d3355ec..9893a65a 100644
--- a/src/qcommon/msg.c
+++ b/src/qcommon/msg.c
@@ -312,9 +312,9 @@ void MSG_WriteString( msg_t *sb, const char *s ) {
}
Q_strncpyz( string, s, sizeof( string ) );
- // get rid of 0xff chars, because old clients don't like them
+ // get rid of 0x80+ and '%' chars, because old clients don't like them
for ( i = 0 ; i < l ; i++ ) {
- if ( ((byte *)string)[i] > 127 ) {
+ if ( ((byte *)string)[i] > 127 || string[i] == '%' ) {
string[i] = '.';
}
}
@@ -338,9 +338,9 @@ void MSG_WriteBigString( msg_t *sb, const char *s ) {
}
Q_strncpyz( string, s, sizeof( string ) );
- // get rid of 0xff chars, because old clients don't like them
+ // get rid of 0x80+ and '%' chars, because old clients don't like them
for ( i = 0 ; i < l ; i++ ) {
- if ( ((byte *)string)[i] > 127 ) {
+ if ( ((byte *)string)[i] > 127 || string[i] == '%' ) {
string[i] = '.';
}
}
@@ -514,6 +514,21 @@ void MSG_ReadData( msg_t *msg, void *data, int len ) {
}
}
+// a string hasher which gives the same hash value even if the
+// string is later modified via the legacy MSG read/write code
+int MSG_HashKey(const char *string, int maxlen) {
+ int hash, i;
+
+ hash = 0;
+ for (i = 0; i < maxlen && string[i] != '\0'; i++) {
+ if (string[i] & 0x80 || string[i] == '%')
+ hash += '.' * (119 + i);
+ else
+ hash += string[i] * (119 + i);
+ }
+ hash = (hash ^ (hash >> 10) ^ (hash >> 20));
+ return hash;
+}
/*
=============================================================================