From 31a79231f8457f3408fdf30a09fcbc60e641da66 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Wed, 9 Jul 2014 22:23:20 -0400 Subject: [PATCH] Fix regression stopping -1 from being a valid value in SetEntPropEnt. --- core/smn_entities.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/core/smn_entities.cpp b/core/smn_entities.cpp index 461131e9..d7d99b4b 100644 --- a/core/smn_entities.cpp +++ b/core/smn_entities.cpp @@ -1689,7 +1689,7 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) } CBaseEntity *pOther = GetEntity(params[4]); - if (!pOther) + if (!pOther && params[4] != -1) { return pContext->ThrowNativeError("Entity %d (%d) is invalid", g_HL2.ReferenceToIndex(params[4]), params[4]); } @@ -1717,16 +1717,20 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params) case PropEnt_Edict: { - IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); - if (!pNetworkable) - { - return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); - } + edict_t *pOtherEdict = NULL; + if (pOther) + { + IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); + if (!pNetworkable) + { + return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); + } - edict_t *pOtherEdict = pNetworkable->GetEdict(); - if (!pOtherEdict || pOtherEdict->IsFree()) - { - return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); + pOtherEdict = pNetworkable->GetEdict(); + if (!pOtherEdict || pOtherEdict->IsFree()) + { + return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); + } } *(edict_t **) ((uint8_t *) pEntity + offset) = pOtherEdict;