Add client checks to EmitSound SoundsHooks (
bug 5873, r=psychonic)
1.1 --- a/extensions/sdktools/vsound.cpp Fri Jan 17 23:21:16 2014 -0500
1.2 +++ b/extensions/sdktools/vsound.cpp Fri Jan 17 23:25:23 2014 -0500
1.3 @@ -338,6 +338,28 @@
1.4 }
1.5 case Pl_Changed:
1.6 {
1.7 + /* Client validation */
1.8 + for (int i = 0; i < size; i++)
1.9 + {
1.10 + int client = players[i];
1.11 + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
1.12 +
1.13 + if (!pPlayer)
1.14 + {
1.15 + pFunc->GetParentContext()->ThrowNativeError("Client index %d is invalid", client);
1.16 + } else if (!pPlayer->IsInGame()) {
1.17 + pFunc->GetParentContext()->ThrowNativeError("Client %d is not connected", client);
1.18 + } else {
1.19 + continue;
1.20 + }
1.21 +
1.22 +#if SOURCE_ENGINE >= SE_PORTAL2
1.23 + RETURN_META_VALUE(MRES_IGNORED, -1 );
1.24 +#else
1.25 + return;
1.26 +#endif
1.27 + }
1.28 +
1.29 CellRecipientFilter crf;
1.30 crf.Initialize(players, size);
1.31 #if SOURCE_ENGINE >= SE_PORTAL2
1.32 @@ -431,6 +453,28 @@
1.33 }
1.34 case Pl_Changed:
1.35 {
1.36 + /* Client validation */
1.37 + for (int i = 0; i < size; i++)
1.38 + {
1.39 + int client = players[i];
1.40 + IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(client);
1.41 +
1.42 + if (!pPlayer)
1.43 + {
1.44 + pFunc->GetParentContext()->ThrowNativeError("Client index %d is invalid", client);
1.45 + } else if (!pPlayer->IsInGame()) {
1.46 + pFunc->GetParentContext()->ThrowNativeError("Client %d is not connected", client);
1.47 + } else {
1.48 + continue;
1.49 + }
1.50 +
1.51 +#if SOURCE_ENGINE >= SE_PORTAL2
1.52 + RETURN_META_VALUE(MRES_IGNORED, -1 );
1.53 +#else
1.54 + return;
1.55 +#endif
1.56 + }
1.57 +
1.58 CellRecipientFilter crf;
1.59 crf.Initialize(players, size);
1.60 #if SOURCE_ENGINE >= SE_PORTAL2