* 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
@ -700,14 +700,21 @@ cell_t Native_SetParam(IPluginContext *pContext, const cell_t *params)
|
|||||||
break;
|
break;
|
||||||
case HookParamType_CBaseEntity:
|
case HookParamType_CBaseEntity:
|
||||||
{
|
{
|
||||||
CBaseEntity *pEnt = gamehelpers->ReferenceToEntity(params[2]);
|
if(params[2] == -1)
|
||||||
|
|
||||||
if(!pEnt)
|
|
||||||
{
|
{
|
||||||
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;
|
break;
|
||||||
}
|
}
|
||||||
case HookParamType_Edict:
|
case HookParamType_Edict:
|
||||||
|
@ -273,6 +273,8 @@ methodmap DHookParam < Handle
|
|||||||
// Set the value of a parameter.
|
// Set the value of a parameter.
|
||||||
// Use only for: int, entity, edict, bool or float parameter types.
|
// 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
|
// The changes are only applied when MRES_ChangedHandled or MRES_ChangedOverride
|
||||||
// is returned in the callback.
|
// is returned in the callback.
|
||||||
//
|
//
|
||||||
@ -390,6 +392,8 @@ methodmap DHookReturn < Handle
|
|||||||
// Retrieves or sets the return value.
|
// Retrieves or sets the return value.
|
||||||
// Use only for: int, entity, edict, bool or float return types.
|
// 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 return value is only readable in a post hook.
|
||||||
// The value is only applied when MRES_Override or MRES_Supercede is returned
|
// The value is only applied when MRES_Override or MRES_Supercede is returned
|
||||||
// in the callback.
|
// in the callback.
|
||||||
@ -781,7 +785,7 @@ native int DHookRaw(Handle setup, bool post, Address addr, DHookRemovalCB remova
|
|||||||
native bool DHookRemoveHookID(int hookid);
|
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 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
|
* @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);
|
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 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
|
* @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)
|
* 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 hReturn Handle to return structure
|
||||||
* @param value Value to set return as
|
* @param value Value to set return as
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user