* 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:
parent
a7cb35c2af
commit
39d604ae6c
@ -699,6 +699,12 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params)
|
||||
*(bool *)addr = (params[3] ? true : false);
|
||||
break;
|
||||
case HookParamType_CBaseEntity:
|
||||
{
|
||||
if(params[2] == -1)
|
||||
{
|
||||
*(CBaseEntity **)addr = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]);
|
||||
|
||||
@ -708,6 +714,7 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params)
|
||||
}
|
||||
|
||||
*(CBaseEntity **)addr = pEnt;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case HookParamType_Edict:
|
||||
|
@ -273,6 +273,8 @@ methodmap DHookParam < Handle
|
||||
// Set the value of a parameter.
|
||||
// Use only for: int, entity, edict, bool or float parameter types.
|
||||
//
|
||||
// An entity parameter type can be set to NULL using INVALID_ENT_REFERENCE (-1).
|
||||
//
|
||||
// The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
|
||||
// is returned in the callback.
|
||||
//
|
||||
@ -390,6 +392,8 @@ methodmap DHookReturn < Handle
|
||||
// Retrieves or sets the return value.
|
||||
// Use only for: int, entity, edict, bool or float return types.
|
||||
//
|
||||
// An entity return type can be set to NULL using INVALID_ENT_REFERENCE (-1).
|
||||
//
|
||||
// The return value is only readable in a post hook.
|
||||
// The value is only applied when MRES_Override or MRES_Supercede is returned
|
||||
// in the callback.
|
||||
@ -781,7 +785,7 @@ native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB remova
|
||||
native bool DHookRemoveHookID(int hookid);
|
||||
|
||||
/**
|
||||
* Get param value (Use only for: int, entity, bool or float param types)
|
||||
* Get param value (Use only for: int, entity, edict, bool or float param types)
|
||||
*
|
||||
* @param hParams Handle to params structure
|
||||
* @param num Param number to get. (Example if the function has 2 params and you need the value of the first
|
||||
@ -818,7 +822,9 @@ native void DHookGetParamVector(Handle hParams, int num, float vec[3]);
|
||||
native void DHookGetParamString(Handle hParams, int num, char[] buffer, int size);
|
||||
|
||||
/**
|
||||
* Set param value (Use only for: int, entity, bool or float param types)
|
||||
* Set param value (Use only for: int, entity, edict, bool or float param types)
|
||||
*
|
||||
* An entity param type can be set to NULL using INVALID_ENT_REFERENCE (-1).
|
||||
*
|
||||
* @param hParams Handle to params structure
|
||||
* @param num Param number to set (Example if the function has 2 params and you need to set the value of the
|
||||
@ -887,6 +893,8 @@ native void DHookGetReturnString(Handle hReturn, char[] buffer, int size);
|
||||
/**
|
||||
* Set return value (Use only for: int, entity, bool or float return types)
|
||||
*
|
||||
* An entity return type can be set to NULL using INVALID_ENT_REFERENCE (-1).
|
||||
*
|
||||
* @param hReturn Handle to return structure
|
||||
* @param value Value to set return as
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user