DHooks: Allow setting CBaseEntity* param to NULL #1751 (#1754)

* DHooks: Allow setting CBaseEntity* param to NULL #1751

The param had to be a valid entity and wasn't allowed to be set to NULL. Behave similar to SetReturn which maps INVALID_ENT_REFERENCE (or -1) to NULL.

* Update include documentation
This commit is contained in:
peace-maker
2023-08-30 22:08:45 +02:00
committed by Your Name
parent b27243c3ac
commit b25d25890a
2 changed files with 22 additions and 7 deletions
+12 -5
View File
@@ -700,14 +700,21 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params)
break;
case HookParamType_CBaseEntity:
{
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]);
if(!pEnt)
if(params[2] == -1)
{
return pContext->ThrowNativeError("Invalid entity index passed for param value");
*(CBaseEntity **)addr = nullptr;
}
else
{
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]);
*(CBaseEntity **)addr = pEnt;
if(!pEnt)
{
return pContext->ThrowNativeError("Invalid entity index passed for param value");
}
*(CBaseEntity **)addr = pEnt;
}
break;
}
case HookParamType_Edict: