2
0
mirror of https://github.com/rehlds/reapi.git synced 2025-01-01 01:25:47 +03:00

Fixed possible false error "trying to set return value without active hook" in hookchain forwards

This commit is contained in:
asmodai 2016-10-16 16:26:31 +03:00
parent 8617956d66
commit 727cf3c01d
2 changed files with 8 additions and 4 deletions

View File

@ -155,10 +155,11 @@ template <typename original_t, typename ...f_args>
void callVoidForward(size_t func, original_t original, f_args... args) void callVoidForward(size_t func, original_t original, f_args... args)
{ {
hookctx_t hookCtx(sizeof...(args), args...); hookctx_t hookCtx(sizeof...(args), args...);
hookctx_t* save = g_hookCtx;
g_hookCtx = &hookCtx; g_hookCtx = &hookCtx;
_callVoidForward(g_hookManager.getHookFast(func), original, args...); _callVoidForward(g_hookManager.getHookFast(func), original, args...);
g_hookCtx = nullptr; g_hookCtx = save;
} }
template <typename R, typename original_t, typename ...f_args> template <typename R, typename original_t, typename ...f_args>
@ -179,7 +180,7 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat
} }
if (!hookCtx->retVal.set) { if (!hookCtx->retVal.set) {
g_amxxapi.LogError(fwd->GetAmx(), AMX_ERR_CALLBACK, "%s", "can't suppress original function call without new return value set"); g_amxxapi.LogError(fwd->GetAmx(), AMX_ERR_CALLBACK, "can't suppress original function call without new return value set");
continue; continue;
} }
@ -220,10 +221,11 @@ template <typename R, typename original_t, typename ...f_args>
R callForward(size_t func, original_t original, f_args... args) R callForward(size_t func, original_t original, f_args... args)
{ {
hookctx_t hookCtx(sizeof...(args), args...); hookctx_t hookCtx(sizeof...(args), args...);
hookctx_t* save = g_hookCtx;
g_hookCtx = &hookCtx; g_hookCtx = &hookCtx;
auto ret = _callForward<R>(g_hookManager.getHookFast(func), original, args...); auto ret = _callForward<R>(g_hookManager.getHookFast(func), original, args...);
g_hookCtx = nullptr; g_hookCtx = save;
return ret; return ret;
} }

View File

@ -109,6 +109,8 @@ cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params)
pPlayer->RemovePlayerItem(pItem); pPlayer->RemovePlayerItem(pItem);
pItem->Kill(); pItem->Kill();
break; break;
case GT_APPEND: break;
default: break;
} }
pItem = pItem->m_pNext; pItem = pItem->m_pNext;