[quake3-commits] r1661 - in trunk/code: client qcommon server
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Oct 12 13:17:17 EDT 2009
Author: thilo
Date: 2009-10-12 13:17:15 -0400 (Mon, 12 Oct 2009)
New Revision: 1661
Modified:
trunk/code/client/cl_input.c
trunk/code/qcommon/common.c
trunk/code/qcommon/msg.c
trunk/code/qcommon/qcommon.h
trunk/code/server/sv_client.c
Log:
Fix netcode inconsistency, thanks to /dev/humancontroller for the patch, see http://bugzilla.icculus.org/show_bug.cgi?id=4060
Modified: trunk/code/client/cl_input.c
===================================================================
--- trunk/code/client/cl_input.c 2009-10-12 16:20:01 UTC (rev 1660)
+++ trunk/code/client/cl_input.c 2009-10-12 17:17:15 UTC (rev 1661)
@@ -863,7 +863,7 @@
// also use the message acknowledge
key ^= clc.serverMessageSequence;
// also use the last acknowledged server command in the key
- key ^= Com_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
+ key ^= MSG_HashKey(clc.serverCommands[ clc.serverCommandSequence & (MAX_RELIABLE_COMMANDS-1) ], 32);
// write all the commands, including the predicted command
for ( i = 0 ; i < count ; i++ ) {
Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c 2009-10-12 16:20:01 UTC (rev 1660)
+++ trunk/code/qcommon/common.c 2009-10-12 17:17:15 UTC (rev 1661)
@@ -673,22 +673,6 @@
}
/*
-============
-Com_HashKey
-============
-*/
-int Com_HashKey(char *string, int maxlen) {
- int register hash, i;
-
- hash = 0;
- for (i = 0; i < maxlen && string[i] != '\0'; i++) {
- hash += string[i] * (119 + i);
- }
- hash = (hash ^ (hash >> 10) ^ (hash >> 20));
- return hash;
-}
-
-/*
================
Com_RealTime
================
Modified: trunk/code/qcommon/msg.c
===================================================================
--- trunk/code/qcommon/msg.c 2009-10-12 16:20:01 UTC (rev 1660)
+++ trunk/code/qcommon/msg.c 2009-10-12 17:17:15 UTC (rev 1661)
@@ -311,9 +311,9 @@
}
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] = '.';
}
}
@@ -337,9 +337,9 @@
}
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] = '.';
}
}
@@ -525,7 +525,22 @@
}
}
+// 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;
+}
+
/*
=============================================================================
Modified: trunk/code/qcommon/qcommon.h
===================================================================
--- trunk/code/qcommon/qcommon.h 2009-10-12 16:20:01 UTC (rev 1660)
+++ trunk/code/qcommon/qcommon.h 2009-10-12 17:17:15 UTC (rev 1661)
@@ -76,6 +76,7 @@
void MSG_WriteString (msg_t *sb, const char *s);
void MSG_WriteBigString (msg_t *sb, const char *s);
void MSG_WriteAngle16 (msg_t *sb, float f);
+int MSG_HashKey(const char *string, int maxlen);
void MSG_BeginReading (msg_t *sb);
void MSG_BeginReadingOOB(msg_t *sb);
@@ -799,7 +800,6 @@
int Com_Milliseconds( void ); // will be journaled properly
unsigned Com_BlockChecksum( const void *buffer, int length );
char *Com_MD5File(const char *filename, int length, const char *prefix, int prefix_len);
-int Com_HashKey(char *string, int maxlen);
int Com_Filter(char *filter, char *name, int casesensitive);
int Com_FilterPath(char *filter, char *name, int casesensitive);
int Com_RealTime(qtime_t *qtime);
Modified: trunk/code/server/sv_client.c
===================================================================
--- trunk/code/server/sv_client.c 2009-10-12 16:20:01 UTC (rev 1660)
+++ trunk/code/server/sv_client.c 2009-10-12 17:17:15 UTC (rev 1661)
@@ -1605,7 +1605,7 @@
// also use the message acknowledge
key ^= cl->messageAcknowledge;
// also use the last acknowledged server command in the key
- key ^= Com_HashKey(cl->reliableCommands[ cl->reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ], 32);
+ key ^= MSG_HashKey(cl->reliableCommands[ cl->reliableAcknowledge & (MAX_RELIABLE_COMMANDS-1) ], 32);
Com_Memset( &nullcmd, 0, sizeof(nullcmd) );
oldcmd = &nullcmd;
More information about the quake3-commits
mailing list