Fix regression stopping -1 from being a valid value in SetEntPropEnt.

This commit is contained in:
Nicholas Hastings 2014-07-09 22:23:20 -04:00
parent 0b5e587db9
commit 31a79231f8

View File

@ -1689,7 +1689,7 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
} }
CBaseEntity *pOther = GetEntity(params[4]); 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]); 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: case PropEnt_Edict:
{ {
IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); edict_t *pOtherEdict = NULL;
if (!pNetworkable) if (pOther)
{ {
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); 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(); pOtherEdict = pNetworkable->GetEdict();
if (!pOtherEdict || pOtherEdict->IsFree()) if (!pOtherEdict || pOtherEdict->IsFree())
{ {
return pContext->ThrowNativeError("Entity %d (%d) does not have a valid edict", g_HL2.ReferenceToIndex(params[4]), params[4]); 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; *(edict_t **) ((uint8_t *) pEntity + offset) = pOtherEdict;