# HG changeset patch # User Kyle Sanderson # Date 1390019123 18000 # Node ID 1621324faee587724c2c91c7c9bf620c3c45f381 # Parent 0da12c0f8095dac378939ee2caeff77c0a5f7458 Add client checks to EmitSound SoundsHooks (bug 5873, r=psychonic) diff -r 0da12c0f8095 -r 1621324faee5 extensions/sdktools/vsound.cpp --- a/extensions/sdktools/vsound.cpp Fri Jan 17 23:21:16 2014 -0500 +++ b/extensions/sdktools/vsound.cpp Fri Jan 17 23:25:23 2014 -0500 @@ -338,6 +338,28 @@ } 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 @@ } 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