From 5acc7209b2fe87aa61df354fa4322857043f3ab8 Mon Sep 17 00:00:00 2001 From: Kyle Sanderson Date: Fri, 17 Jan 2014 23:25:23 -0500 Subject: [PATCH] Add client checks to EmitSound SoundsHooks (bug 5873, r=psychonic) --- extensions/sdktools/vsound.cpp | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/extensions/sdktools/vsound.cpp b/extensions/sdktools/vsound.cpp index 1753ef22..722f30be 100644 --- a/extensions/sdktools/vsound.cpp +++ b/extensions/sdktools/vsound.cpp @@ -338,6 +338,28 @@ void SoundHooks::OnEmitSound(IRecipientFilter &filter, int iEntIndex, int iChann } case Pl_Changed: { + /* Client validation */ + for (int i = 0; i < size; i++) + { + int client = players[i]; + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); + + if (!pPlayer) + { + pFunc->GetParentContext()->ThrowNativeError("Client index %d is invalid", client); + } else if (!pPlayer->IsInGame()) { + pFunc->GetParentContext()->ThrowNativeError("Client %d is not connected", client); + } else { + continue; + } + +#if SOURCE_ENGINE >= SE_PORTAL2 + RETURN_META_VALUE(MRES_IGNORED, -1 ); +#else + return; +#endif + } + CellRecipientFilter crf; crf.Initialize(players, size); #if SOURCE_ENGINE >= SE_PORTAL2 @@ -431,6 +453,28 @@ void SoundHooks::OnEmitSound2(IRecipientFilter &filter, int iEntIndex, int iChan } case Pl_Changed: { + /* Client validation */ + for (int i = 0; i < size; i++) + { + int client = players[i]; + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client); + + if (!pPlayer) + { + pFunc->GetParentContext()->ThrowNativeError("Client index %d is invalid", client); + } else if (!pPlayer->IsInGame()) { + pFunc->GetParentContext()->ThrowNativeError("Client %d is not connected", client); + } else { + continue; + } + +#if SOURCE_ENGINE >= SE_PORTAL2 + RETURN_META_VALUE(MRES_IGNORED, -1 ); +#else + return; +#endif + } + CellRecipientFilter crf; crf.Initialize(players, size); #if SOURCE_ENGINE >= SE_PORTAL2