summaryrefslogtreecommitdiff
path: root/src/client/cl_parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/cl_parse.c')
-rw-r--r--src/client/cl_parse.c57
1 files changed, 48 insertions, 9 deletions
diff --git a/src/client/cl_parse.c b/src/client/cl_parse.c
index 5e481f92..a4810411 100644
--- a/src/client/cl_parse.c
+++ b/src/client/cl_parse.c
@@ -73,7 +73,7 @@ void CL_DeltaEntity (msg_t *msg, clSnapshot_t *frame, int newnum, entityState_t
if ( unchanged ) {
*state = *old;
} else {
- MSG_ReadDeltaEntity( msg, old, state, newnum );
+ MSG_ReadDeltaEntity( clc.netchan.alternateProtocol, msg, old, state, newnum );
}
if ( state->number == (MAX_GENTITIES-1) ) {
@@ -274,10 +274,18 @@ void CL_ParseSnapshot( msg_t *msg ) {
// read playerinfo
SHOWNET( msg, "playerstate" );
- if ( old ) {
- MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
+ if ( clc.netchan.alternateProtocol == 2 ) {
+ if ( old ) {
+ MSG_ReadDeltaAlternatePlayerstate( msg, &old->alternatePs, &newSnap.alternatePs );
+ } else {
+ MSG_ReadDeltaAlternatePlayerstate( msg, NULL, &newSnap.alternatePs );
+ }
} else {
- MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
+ if ( old ) {
+ MSG_ReadDeltaPlayerstate( msg, &old->ps, &newSnap.ps );
+ } else {
+ MSG_ReadDeltaPlayerstate( msg, NULL, &newSnap.ps );
+ }
}
// read packet entities
@@ -309,7 +317,7 @@ void CL_ParseSnapshot( msg_t *msg ) {
// calculate ping time
for ( i = 0 ; i < PACKET_BACKUP ; i++ ) {
packetNum = ( clc.netchan.outgoingSequence - 1 - i ) & PACKET_MASK;
- if ( cl.snap.ps.commandTime >= cl.outPackets[ packetNum ].p_serverTime ) {
+ if ( ( clc.netchan.alternateProtocol == 2 ? cl.snap.alternatePs.commandTime : cl.snap.ps.commandTime ) >= cl.outPackets[ packetNum ].p_serverTime ) {
cl.snap.ping = cls.realtime - cl.outPackets[ packetNum ].p_realtime;
break;
}
@@ -355,8 +363,13 @@ void CL_SystemInfoChanged( void ) {
cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );
#ifdef USE_VOIP
- s = Info_ValueForKey( systemInfo, "sv_voipProtocol" );
- clc.voipEnabled = !Q_stricmp(s, "opus");
+ if( clc.netchan.alternateProtocol == 0 ) {
+ s = Info_ValueForKey( systemInfo, "sv_voipProtocol" );
+ clc.voipEnabled = !Q_stricmp(s, "opus");
+ } else {
+ s = Info_ValueForKey( systemInfo, "sv_voip" );
+ clc.voipEnabled = !!atoi(s);
+ }
#endif
// don't set any vars when playing a demo
@@ -502,7 +515,7 @@ void CL_ParseGamestate( msg_t *msg ) {
}
Com_Memset (&nullstate, 0, sizeof(nullstate));
es = &cl.entityBaselines[ newnum ];
- MSG_ReadDeltaEntity( msg, &nullstate, es, newnum );
+ MSG_ReadDeltaEntity( clc.netchan.alternateProtocol, msg, &nullstate, es, newnum );
} else {
Com_Error( ERR_DROP, "CL_ParseGamestate: bad command byte" );
}
@@ -698,7 +711,9 @@ void CL_ParseVoip ( msg_t *msg, qboolean ignoreData ) {
const int sequence = MSG_ReadLong(msg);
const int frames = MSG_ReadByte(msg);
const int packetsize = MSG_ReadShort(msg);
- const int flags = MSG_ReadBits(msg, VOIP_FLAGCNT);
+ int flags = VOIP_DIRECT;
+ if (clc.netchan.alternateProtocol == 0)
+ flags = MSG_ReadBits(msg, VOIP_FLAGCNT);
unsigned char encoded[4000];
int numSamples;
int seqdiff;
@@ -874,6 +889,30 @@ void CL_ParseServerMessage( msg_t *msg ) {
cmd = MSG_ReadByte( msg );
+ if ( clc.netchan.alternateProtocol != 0 )
+ {
+ // 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_voipSpeex ) {
+ 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_voipOpus ) {
+ cmd = svc_voipSpeex;
+ } else if ( cmd == svc_voipOpus + 1 ) {
+ cmd = svc_voipOpus;
+ } else if ( cmd == svc_voipSpeex ) {
+ cmd = svc_voipOpus + 1;
+ }
+ }
+
if (cmd == svc_EOF) {
SHOWNET( msg, "END OF MESSAGE" );
break;