fix VDECODE_FLAG_ALLOWNOTINGAME flag (#2000)

Corrects the check for the VDECODE_FLAG_ALLOWNOTINGAME flag
This commit is contained in:
1mpulse 2024-06-01 16:57:07 +03:00 committed by GitHub
parent 4e73713fab
commit 9f3584a056
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -396,15 +396,17 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (index >= 1 && index <= playerhelpers->GetMaxClients()) if (index >= 1 && index <= playerhelpers->GetMaxClients())
{ {
IGamePlayer *player = playerhelpers->GetGamePlayer(index); IGamePlayer *player = playerhelpers->GetGamePlayer(index);
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected()) if(!player->IsConnected()) {
{
pContext->ThrowNativeError("Client %d is not connected", param); pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail; return Data_Fail;
} else if (!player->IsInGame()) { }
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param); pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail; return Data_Fail;
} }
pEntity = gamehelpers->ReferenceToEntity(param); pEntity = gamehelpers->ReferenceToEntity(param);
} else if (param == -1) { } else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL) if (data->decflags & VDECODE_FLAG_ALLOWNULL)
@ -441,15 +443,17 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (index >= 1 && index <= playerhelpers->GetMaxClients()) if (index >= 1 && index <= playerhelpers->GetMaxClients())
{ {
IGamePlayer *player = playerhelpers->GetGamePlayer(index); IGamePlayer *player = playerhelpers->GetGamePlayer(index);
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected()) if(!player->IsConnected()) {
{
pContext->ThrowNativeError("Client %d is not connected", param); pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail; return Data_Fail;
} else if (!player->IsInGame()) { }
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param); pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail; return Data_Fail;
} }
pEntity = gamehelpers->ReferenceToEntity(param); pEntity = gamehelpers->ReferenceToEntity(param);
} else if (param == -1) { } else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL) if (data->decflags & VDECODE_FLAG_ALLOWNULL)
@ -493,15 +497,17 @@ DataStatus DecodeValveParam(IPluginContext *pContext,
if (param >= 1 && param <= playerhelpers->GetMaxClients()) if (param >= 1 && param <= playerhelpers->GetMaxClients())
{ {
IGamePlayer *player = playerhelpers->GetGamePlayer(param); IGamePlayer *player = playerhelpers->GetGamePlayer(param);
if ((data->decflags & VDECODE_FLAG_ALLOWNOTINGAME)
&& !player->IsConnected()) if(!player->IsConnected()) {
{
pContext->ThrowNativeError("Client %d is not connected", param); pContext->ThrowNativeError("Client %d is not connected", param);
return Data_Fail; return Data_Fail;
} else if (!player->IsInGame()) { }
if(!(data->decflags & VDECODE_FLAG_ALLOWNOTINGAME) && !player->IsInGame()) {
pContext->ThrowNativeError("Client %d is not in game", param); pContext->ThrowNativeError("Client %d is not in game", param);
return Data_Fail; return Data_Fail;
} }
pEdict = player->GetEdict(); pEdict = player->GetEdict();
} else if (param == -1) { } else if (param == -1) {
if (data->decflags & VDECODE_FLAG_ALLOWNULL) if (data->decflags & VDECODE_FLAG_ALLOWNULL)