From f90c6585679eef5deed585bb0918641127b479ba Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 11 Oct 2024 19:22:49 +0300 Subject: [PATCH] engine: client: skip voice data for GoldSrc protocol to avoid svc_bad --- engine/client/cl_parse.c | 20 +++++++++++++++++--- engine/client/cl_parse_gs.c | 2 +- engine/client/client.h | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index a329ed70..f65bd468 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -1940,15 +1940,29 @@ CL_ParseVoiceData ================== */ -void CL_ParseVoiceData( sizebuf_t *msg ) +void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto ) { int size, idx, frames; byte received[8192]; idx = MSG_ReadByte( msg ) + 1; - frames = MSG_ReadByte( msg ); + if( proto == PROTO_GOLDSRC ) + { + size = MSG_ReadShort( msg ); + MSG_SeekToBit( msg, size << 3, SEEK_CUR ); // skip the entire buf, not supported yet +#if 0 // shall we notify client.dll if nothing can be heard? + // must notify through as both local player and normal client + if( idx == cl.playernum + 1 ) + Voice_StatusAck( &voice.local, VOICE_LOOPBACK_INDEX ); + + Voice_StatusAck( &voice.players_status[idx], idx ); +#endif + return; + } + + frames = MSG_ReadByte( msg ); size = MSG_ReadShort( msg ); size = Q_min( size, sizeof( received )); @@ -2632,7 +2646,7 @@ void CL_ParseServerMessage( sizebuf_t *msg ) CL_ParseVoiceInit( msg ); break; case svc_voicedata: - CL_ParseVoiceData( msg ); + CL_ParseVoiceData( msg, PROTO_CURRENT ); cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart; break; case svc_resourcelocation: diff --git a/engine/client/cl_parse_gs.c b/engine/client/cl_parse_gs.c index 675f7101..e782fdfc 100644 --- a/engine/client/cl_parse_gs.c +++ b/engine/client/cl_parse_gs.c @@ -730,7 +730,7 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) CL_ParseVoiceInit( msg ); break; case svc_voicedata: - CL_ParseVoiceData( msg ); + CL_ParseVoiceData( msg, PROTO_GOLDSRC ); cl.frames[cl.parsecountmod].graphdata.voicebytes += MSG_GetNumBytesRead( msg ) - bufStart; break; case svc_resourcelocation: diff --git a/engine/client/client.h b/engine/client/client.h index 5db23343..8bbf853a 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -886,7 +886,7 @@ void CL_ParseFileTransferFailed( sizebuf_t *msg ); void CL_ParseHLTV( sizebuf_t *msg ); void CL_ParseDirector( sizebuf_t *msg ); void CL_ParseVoiceInit( sizebuf_t *msg ); -void CL_ParseVoiceData( sizebuf_t *msg ); +void CL_ParseVoiceData( sizebuf_t *msg, connprotocol_t proto ); void CL_ParseResLocation( sizebuf_t *msg ); void CL_ParseCvarValue( sizebuf_t *msg, const qboolean ext, const connprotocol_t proto ); void CL_ParseServerMessage( sizebuf_t *msg );