Remove optional callback parameter from DHookCreateFromConf
Encourage passing the callback when hooking instead of when setting the hook up.
This commit is contained in:
parent
556290e088
commit
c6266bfcf3
15
natives.cpp
15
natives.cpp
@ -28,7 +28,7 @@ bool GetHandleIfValidOrError(HandleType_t type, void **object, IPluginContext *p
|
||||
return true;
|
||||
}
|
||||
|
||||
IPluginFunction *GetCallback(IPluginContext *pContext, HookSetup * setup, const cell_t *params, unsigned int callback_index)
|
||||
IPluginFunction *GetCallback(IPluginContext *pContext, HookSetup * setup, const cell_t *params, cell_t callback_index)
|
||||
{
|
||||
IPluginFunction *ret = NULL;
|
||||
|
||||
@ -77,7 +77,7 @@ cell_t Native_CreateDetour(IPluginContext *pContext, const cell_t *params)
|
||||
return hndl;
|
||||
}
|
||||
|
||||
// native Handle:DHookCreateFromConf(Handle:gameconf, const String:function[], DHookCallback:callback=INVALID_FUNCTION);
|
||||
// native Handle:DHookCreateFromConf(Handle:gameconf, const String:function[]);
|
||||
cell_t Native_DHookCreateFromConf(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
IGameConfig *conf;
|
||||
@ -96,14 +96,6 @@ cell_t Native_DHookCreateFromConf(IPluginContext *pContext, const cell_t *params
|
||||
return pContext->ThrowNativeError("Function signature \"%s\" was not found.", function);
|
||||
}
|
||||
|
||||
IPluginFunction *callback = nullptr;
|
||||
if (params[3] != -1)
|
||||
{
|
||||
callback = pContext->GetFunctionById(params[3]);
|
||||
if (!callback)
|
||||
return pContext->ThrowNativeError("Failed to find callback function.");
|
||||
}
|
||||
|
||||
HookSetup *setup = nullptr;
|
||||
// This is a virtual hook.
|
||||
if (sig->offset.length() > 0)
|
||||
@ -114,7 +106,7 @@ cell_t Native_DHookCreateFromConf(IPluginContext *pContext, const cell_t *params
|
||||
return BAD_HANDLE;
|
||||
}
|
||||
|
||||
setup = new HookSetup(sig->retType, PASSFLAG_BYVAL, sig->hookType, sig->thisType, offset, callback);
|
||||
setup = new HookSetup(sig->retType, PASSFLAG_BYVAL, sig->hookType, sig->thisType, offset, nullptr);
|
||||
}
|
||||
// This is a detour.
|
||||
else
|
||||
@ -211,7 +203,6 @@ cell_t Native_SetFromConf(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
//native bool:DHookAddParam(Handle:setup, HookParamType:type); OLD
|
||||
//native bool:DHookAddParam(Handle:setup, HookParamType:type, size=-1, DHookPassFlag:flag=DHookPass_ByVal, DHookRegister custom_register=DHookRegister_Default);
|
||||
cell_t Native_AddParam(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
|
@ -242,12 +242,11 @@ native Handle DHookCreateDetour(Address funcaddr, CallingConvention callConv, Re
|
||||
*
|
||||
* @param gameconf GameConfig handle
|
||||
* @param name Name of the function in the gamedata to load.
|
||||
* @param callback Callback function (only required for virtual hooks - ignored for detours).
|
||||
*
|
||||
* @return Setup handle for the detour or INVALID_HANDLE if offset/signature/address wasn't found.
|
||||
* @error Failed to create detour setup handle, invalid gamedata handle, invalid callback function or failed to find function in gamedata.
|
||||
*/
|
||||
native Handle DHookCreateFromConf(Handle gameconf, const char[] name, DHookCallback callback=INVALID_FUNCTION);
|
||||
native Handle DHookCreateFromConf(Handle gameconf, const char[] name);
|
||||
|
||||
/**
|
||||
* Load details for a vhook or detour from a gamedata file.
|
||||
@ -572,6 +571,7 @@ public __ext_dhooks_SetNTVOptional()
|
||||
MarkNativeAsOptional("DHookRemoveEntityListener");
|
||||
MarkNativeAsOptional("DHookCreate");
|
||||
MarkNativeAsOptional("DHookCreateDetour");
|
||||
MarkNativeAsOptional("DHookCreateFromConf");
|
||||
MarkNativeAsOptional("DHookSetFromConf");
|
||||
MarkNativeAsOptional("DHookEnableDetour");
|
||||
MarkNativeAsOptional("DHookDisableDetour");
|
||||
|
Loading…
Reference in New Issue
Block a user