From 1bd59096fde50965102c658f9ceeb9852d51f5cb Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 15 Oct 2024 06:10:25 +0300 Subject: [PATCH] engine: client: implement miscellaneous, often unused, GoldSrc protocol messages --- engine/client/cl_parse_gs.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/engine/client/cl_parse_gs.c b/engine/client/cl_parse_gs.c index 732e5028..6d935c82 100644 --- a/engine/client/cl_parse_gs.c +++ b/engine/client/cl_parse_gs.c @@ -452,7 +452,9 @@ static void CL_ParseSoundPacketGS( sizebuf_t *msg ) chan = MSG_ReadUBitLong( msg, 3 ); entnum = MSG_ReadUBitLong( msg, MAX_GOLDSRC_ENTITY_BITS ); - sound = MSG_ReadUBitLong( msg, FBitSet( flags, SND_LEGACY_LARGE_INDEX ) ? 16 : 8 ); + if( FBitSet( flags, SND_LEGACY_LARGE_INDEX )) + sound = MSG_ReadWord( msg ); + else sound = MSG_ReadByte( msg ); MSG_ReadGSBitVec3Coord( msg, pos ); if( FBitSet( flags, SND_PITCH )) @@ -519,7 +521,7 @@ dispatch messages void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) { size_t bufStart, playerbytes; - int cmd; + int cmd, param1; const char *s; // parse the message @@ -553,6 +555,10 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) Host_Error( "svc_bad\n" ); break; case svc_nop: + case svc_spawnstatic: + case svc_goldsrc_damage: + case svc_goldsrc_killedmonster: + case svc_goldsrc_foundsecret: // this does nothing break; case svc_disconnect: @@ -568,6 +574,11 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) MSG_EndBitWriting( msg ); cl.frames[cl.parsecountmod].graphdata.event += MSG_GetNumBytesRead( msg ) - bufStart; break; + case svc_goldsrc_version: + param1 = MSG_ReadLong( msg ); + if( param1 != PROTOCOL_GOLDSRC_VERSION ) + Host_Error( "Server use invalid protocol (%i should be %i)\n", param1, PROTOCOL_GOLDSRC_VERSION ); + break; case svc_setview: CL_ParseViewEntity( msg ); break; @@ -618,6 +629,11 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) MSG_EndBitWriting( msg ); cl.frames[cl.parsecountmod].graphdata.client += MSG_GetNumBytesRead( msg ) - bufStart; break; + case svc_goldsrc_stopsound: + param1 = MSG_ReadWord( msg ); + S_StopSound( param1 >> 3, param1 & 7, NULL ); + cl.frames[cl.parsecountmod].graphdata.sound += MSG_GetNumBytesRead( msg ) - bufStart; + break; case svc_pings: MSG_StartBitWriting( msg ); CL_UpdateUserPings( msg ); @@ -626,9 +642,6 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_particle: CL_ParseParticles( msg, PROTO_GOLDSRC ); break; - case svc_spawnstatic: - // no-op - break; case svc_event_reliable: MSG_StartBitWriting( msg ); CL_ParseReliableEvent( msg, PROTO_GOLDSRC ); @@ -661,6 +674,11 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_cutscene: CL_ParseFinaleCutscene( msg, 3 ); break; + case svc_goldsrc_decalname: + param1 = MSG_ReadByte( msg ); + s = MSG_ReadString( msg ); + Q_strncpy( host.draw_decals[param1], s, sizeof( host.draw_decals[param1] )); + break; case svc_addangle: CL_ParseAddAngle( msg ); break; @@ -717,15 +735,15 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_resourcelocation: CL_ParseResLocation( msg ); break; + case svc_goldsrc_sendextrainfo: + CL_ParseExtraInfo( msg ); + break; case svc_goldsrc_timescale: // we can set sys_timescale to anything we want but in GoldSrc it's locked for // HLTV and demoplayback. Do we really want to have it then if both are out of scope? Con_Reportf( S_ERROR "%s: svc_goldsrc_timescale: implement me!\n", __func__ ); MSG_ReadFloat( msg ); break; - case svc_goldsrc_sendextrainfo: - CL_ParseExtraInfo( msg ); - break; case svc_goldsrc_sendcvarvalue: CL_ParseCvarValue( msg, false, PROTO_GOLDSRC ); break;