Fix hooking inconsistencies in SDKHooks when hooking by ent ref (bug 6069).

This commit is contained in:
Nicholas Hastings 2014-05-05 11:01:18 -04:00
parent 24c12197ee
commit 170a086b1e
2 changed files with 4 additions and 3 deletions

View File

@ -540,10 +540,11 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac
return HookRet_BadEntForHookType; return HookRet_BadEntForHookType;
} }
int bcompatRef = gamehelpers->EntityToBCompatRef(pEnt);
bool bHooked = false; bool bHooked = false;
HOOKLOOP HOOKLOOP
{ {
if (g_HookList[i].entity == entity && g_HookList[i].type == type) if (g_HookList[i].entity == bcompatRef && g_HookList[i].type == type)
{ {
bHooked = true; bHooked = true;
break; break;
@ -677,7 +678,7 @@ HookReturn SDKHooks::Hook(int entity, SDKHookType type, IPluginFunction *callbac
// Add hook to hook list // Add hook to hook list
HookList hook; HookList hook;
hook.entity = entity; hook.entity = bcompatRef;
hook.type = type; hook.type = type;
hook.callback = callback; hook.callback = callback;
g_HookList.AddToTail(hook); g_HookList.AddToTail(hook);

View File

@ -90,7 +90,7 @@ cell_t Native_HookEx(IPluginContext *pContext, const cell_t *params)
cell_t Native_Unhook(IPluginContext *pContext, const cell_t *params) cell_t Native_Unhook(IPluginContext *pContext, const cell_t *params)
{ {
int entity = (int)params[1]; int entity = gamehelpers->ReferenceToBCompatRef(params[1]);
SDKHookType type = (SDKHookType)params[2]; SDKHookType type = (SDKHookType)params[2];
IPluginFunction *callback = pContext->GetFunctionById(params[3]); IPluginFunction *callback = pContext->GetFunctionById(params[3]);