From a4f6e2f577d878e4d7b6e27f9e86af3d462f8f77 Mon Sep 17 00:00:00 2001 From: icculus Date: Tue, 3 Jun 2008 02:32:52 +0000 Subject: Changed the protocol for VoIP packets to support legacy clients. Previously, a legacy client wouldn't get a VoIP packet, but if they did, they'd panic and disconnect. Now they ignore them and continue on. This also gives us the framework to add other features legacy clients can ignore. Oh, this also has the benefit of allowing us to store incoming VoIP for playback in recorded demos. They'll play the chatter on VoIP clients, and be ignored on legacy ones. Huge win. git-svn-id: svn://svn.icculus.org/quake3/trunk@1361 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/client/cl_parse.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'code/client/cl_parse.c') diff --git a/code/client/cl_parse.c b/code/client/cl_parse.c index d80d7d2..294e46e 100644 --- a/code/client/cl_parse.c +++ b/code/client/cl_parse.c @@ -34,10 +34,8 @@ char *svc_strings[256] = { "svc_download", "svc_snapshot", "svc_EOF", - -#if USE_VOIP - "svc_voip" -#endif + "svc_extension", + "svc_voip", }; void SHOWNET( msg_t *msg, char *s) { @@ -854,13 +852,26 @@ void CL_ParseServerMessage( msg_t *msg ) { cmd = MSG_ReadByte( msg ); - if ( cmd == svc_EOF) { + // See if this is an extension command after the EOF, which means we + // got data that a legacy client should ignore. + if ((cmd == svc_EOF) && (MSG_LookaheadByte( msg ) == svc_extension)) { + SHOWNET( msg, "EXTENSION" ); + MSG_ReadByte( msg ); // throw the svc_extension byte away. + cmd = MSG_ReadByte( msg ); // something legacy clients can't do! + // sometimes you get a svc_extension at end of stream...dangling + // bits in the huffman decoder giving a bogus value? + if (cmd == -1) { + cmd = svc_EOF; + } + } + + if (cmd == svc_EOF) { SHOWNET( msg, "END OF MESSAGE" ); break; } if ( cl_shownet->integer >= 2 ) { - if ( !svc_strings[cmd] ) { + if ( (cmd < 0) || (!svc_strings[cmd]) ) { Com_Printf( "%3i:BAD CMD %i\n", msg->readcount-1, cmd ); } else { SHOWNET( msg, svc_strings[cmd] ); @@ -886,11 +897,11 @@ void CL_ParseServerMessage( msg_t *msg ) { case svc_download: CL_ParseDownload( msg ); break; -#if USE_VOIP case svc_voip: +#if USE_VOIP CL_ParseVoip( msg ); - break; #endif + break; } } } -- cgit v1.2.3