diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index e31d75c9..798c5fc1 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -2388,6 +2388,54 @@ ACTION MESSAGES ===================================================================== */ + +/* +============ +CL_ParseCommonDLLMessage + +parse a message which structure is enforced by DLL compatibility +it should always be the same regardless of protocol used +============ +*/ +qboolean CL_ParseCommonDLLMessage( sizebuf_t *msg, connprotocol_t proto, int svc_num, int startoffset ) +{ + int param1, param2; + + switch( svc_num ) + { + case svc_temp_entity: + CL_ParseTempEntity( msg, proto ); // need protocol because message header differs + cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - startoffset; + break; + case svc_intermission: + cl.intermission = 1; + break; + case svc_cdtrack: + param1 = MSG_ReadByte( msg ); + param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum + param2 = MSG_ReadByte( msg ); + param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum + S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false ); + break; + case svc_weaponanim: + param1 = MSG_ReadByte( msg ); // iAnim + param2 = MSG_ReadByte( msg ); // body + CL_WeaponAnim( param1, param2 ); + break; + case svc_roomtype: + param1 = MSG_ReadShort( msg ); + Cvar_SetValue( "room_type", param1 ); + break; + case svc_director: + CL_ParseDirector( msg ); + break; + default: + return false; + } + + return true; +} + /* ===================== CL_ParseServerMessage @@ -2398,7 +2446,7 @@ dispatch messages void CL_ParseServerMessage( sizebuf_t *msg ) { size_t bufStart, playerbytes; - int cmd, param1, param2; + int cmd; int old_background; const char *s; @@ -2423,6 +2471,9 @@ void CL_ParseServerMessage( sizebuf_t *msg ) // record command for debugging spew on parse problem CL_Parse_RecordCommand( cmd, bufStart ); + if( CL_ParseCommonDLLMessage( msg, PROTO_CURRENT, cmd, bufStart )) + continue; + // other commands switch( cmd ) { @@ -2550,10 +2601,6 @@ void CL_ParseServerMessage( sizebuf_t *msg ) case svc_spawnbaseline: CL_ParseBaseline( msg, PROTO_CURRENT ); break; - case svc_temp_entity: - CL_ParseTempEntity( msg, PROTO_CURRENT ); - cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart; - break; case svc_setpause: cl.paused = ( MSG_ReadOneBit( msg ) != 0 ); break; @@ -2563,37 +2610,18 @@ void CL_ParseServerMessage( sizebuf_t *msg ) case svc_centerprint: CL_CenterPrint( MSG_ReadString( msg ), 0.25f ); break; - case svc_intermission: - cl.intermission = 1; - break; case svc_finale: CL_ParseFinaleCutscene( msg, 2 ); break; - case svc_cdtrack: - param1 = MSG_ReadByte( msg ); - param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum - param2 = MSG_ReadByte( msg ); - param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum - S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false ); - break; case svc_restore: CL_ParseRestore( msg ); break; case svc_cutscene: CL_ParseFinaleCutscene( msg, 3 ); break; - case svc_weaponanim: - param1 = MSG_ReadByte( msg ); // iAnim - param2 = MSG_ReadByte( msg ); // body - CL_WeaponAnim( param1, param2 ); - break; case svc_bspdecal: CL_ParseStaticDecal( msg ); break; - case svc_roomtype: - param1 = MSG_ReadShort( msg ); - Cvar_SetValue( "room_type", param1 ); - break; case svc_addangle: CL_ParseAddAngle( msg ); break; @@ -2638,9 +2666,6 @@ void CL_ParseServerMessage( sizebuf_t *msg ) case svc_hltv: CL_ParseHLTV( msg ); break; - case svc_director: - CL_ParseDirector( msg ); - break; case svc_voiceinit: CL_ParseVoiceInit( msg ); break; diff --git a/engine/client/cl_parse_48.c b/engine/client/cl_parse_48.c index 05055a7b..cbee2ec6 100644 --- a/engine/client/cl_parse_48.c +++ b/engine/client/cl_parse_48.c @@ -137,12 +137,7 @@ static void CL_LegacyParseSoundPacket( sizebuf_t *msg, qboolean is_ambient ) if( FBitSet( flags, SND_SENTENCE )) { char sentenceName[32]; - - //if( FBitSet( flags, SND_SEQUENCE )) - //Q_snprintf( sentenceName, sizeof( sentenceName ), "!#%i", sound + MAX_SOUNDS ); - //else Q_snprintf( sentenceName, sizeof( sentenceName ), "!%i", sound ); - handle = S_RegisterSound( sentenceName ); } else handle = cl.sound_index[sound]; // see precached sound @@ -320,7 +315,7 @@ dispatch messages void CL_ParseLegacyServerMessage( sizebuf_t *msg ) { size_t bufStart, playerbytes; - int cmd, param1, param2; + int cmd; int old_background; const char *s; @@ -345,6 +340,9 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg ) // record command for debugging spew on parse problem CL_Parse_RecordCommand( cmd, bufStart ); + if( CL_ParseCommonDLLMessage( msg, PROTO_LEGACY, cmd, bufStart )) + continue; + // other commands switch( cmd ) { @@ -484,10 +482,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg ) case svc_spawnbaseline: CL_ParseBaseline( msg, PROTO_LEGACY ); break; - case svc_temp_entity: - CL_ParseTempEntity( msg, PROTO_LEGACY ); - cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart; - break; case svc_setpause: cl.paused = ( MSG_ReadOneBit( msg ) != 0 ); break; @@ -497,40 +491,21 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg ) case svc_centerprint: CL_CenterPrint( MSG_ReadString( msg ), 0.25f ); break; - case svc_intermission: - cl.intermission = 1; - break; case svc_legacy_modelindex: CL_LegacyPrecacheModel( msg ); break; case svc_legacy_soundindex: CL_LegacyPrecacheSound( msg ); break; - case svc_cdtrack: - param1 = MSG_ReadByte( msg ); - param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum - param2 = MSG_ReadByte( msg ); - param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum - S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false ); - break; case svc_restore: CL_ParseRestore( msg ); break; case svc_legacy_eventindex: CL_LegacyPrecacheEvent(msg); break; - case svc_weaponanim: - param1 = MSG_ReadByte( msg ); // iAnim - param2 = MSG_ReadByte( msg ); // body - CL_WeaponAnim( param1, param2 ); - break; case svc_bspdecal: CL_ParseStaticDecal( msg ); break; - case svc_roomtype: - param1 = MSG_ReadShort( msg ); - Cvar_SetValue( "room_type", param1 ); - break; case svc_addangle: CL_ParseAddAngle( msg ); break; @@ -590,9 +565,6 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg ) case svc_hltv: CL_ParseHLTV( msg ); break; - case svc_director: - CL_ParseDirector( msg ); - break; case svc_resourcelocation: CL_ParseResLocation( msg ); break; diff --git a/engine/client/cl_parse_gs.c b/engine/client/cl_parse_gs.c index efccdfb8..9730af3a 100644 --- a/engine/client/cl_parse_gs.c +++ b/engine/client/cl_parse_gs.c @@ -530,7 +530,7 @@ dispatch messages void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) { size_t bufStart, playerbytes; - int cmd, param1, param2; + int cmd; const char *s; // parse the message @@ -554,6 +554,9 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) // record command for debugging spew on parse problem CL_Parse_RecordCommand( cmd, bufStart ); + if( CL_ParseCommonDLLMessage( msg, PROTO_GOLDSRC, cmd, bufStart )) + continue; + // other commands switch( cmd ) { @@ -647,9 +650,6 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_spawnbaseline: CL_ParseBaseline( msg, PROTO_GOLDSRC ); break; - case svc_temp_entity: - CL_ParseTempEntity( msg, PROTO_GOLDSRC ); - cl.frames[cl.parsecountmod].graphdata.tentities += MSG_GetNumBytesRead( msg ) - bufStart; break; case svc_setpause: cl.paused = ( MSG_ReadOneBit( msg ) != 0 ); @@ -663,34 +663,15 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_goldsrc_spawnstaticsound: CL_ParseSpawnStaticSound( msg ); break; - case svc_intermission: - cl.intermission = 1; - break; case svc_finale: CL_ParseFinaleCutscene( msg, 2 ); break; - case svc_cdtrack: - param1 = MSG_ReadByte( msg ); - param1 = bound( 1, param1, MAX_CDTRACKS ); // tracknum - param2 = MSG_ReadByte( msg ); - param2 = bound( 1, param2, MAX_CDTRACKS ); // loopnum - S_StartBackgroundTrack( clgame.cdtracks[param1-1], clgame.cdtracks[param2-1], 0, false ); - break; case svc_restore: CL_ParseRestore( msg ); break; case svc_cutscene: CL_ParseFinaleCutscene( msg, 3 ); break; - case svc_weaponanim: - param1 = MSG_ReadByte( msg ); // iAnim - param2 = MSG_ReadByte( msg ); // body - CL_WeaponAnim( param1, param2 ); - break; - case svc_roomtype: - param1 = MSG_ReadShort( msg ); - Cvar_SetValue( "room_type", param1 ); - break; case svc_addangle: CL_ParseAddAngle( msg ); break; @@ -737,9 +718,6 @@ void CL_ParseGoldSrcServerMessage( sizebuf_t *msg ) case svc_hltv: CL_ParseHLTV( msg ); break; - case svc_director: - CL_ParseDirector( msg ); - break; case svc_voiceinit: CL_ParseVoiceInit( msg ); break; diff --git a/engine/client/client.h b/engine/client/client.h index 8bbf853a..4e97c6e6 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -890,6 +890,7 @@ 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 ); +qboolean CL_ParseCommonDLLMessage( sizebuf_t *msg, connprotocol_t proto, int svc_num, int startoffset ); void CL_ParseTempEntity( sizebuf_t *msg, connprotocol_t proto ); qboolean CL_DispatchUserMessage( const char *pszName, int iSize, void *pbuf ); qboolean CL_RequestMissingResources( void );