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]);
} }
@ -1716,6 +1716,9 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
} }
case PropEnt_Edict: case PropEnt_Edict:
{
edict_t *pOtherEdict = NULL;
if (pOther)
{ {
IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable(); IServerNetworkable *pNetworkable = ((IServerUnknown *) pOther)->GetNetworkable();
if (!pNetworkable) if (!pNetworkable)
@ -1723,11 +1726,12 @@ static cell_t SetEntPropEnt(IPluginContext *pContext, const cell_t *params)
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 *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;
break; break;