From 727cf3c01df3e278e165240652d49a069e7745cc Mon Sep 17 00:00:00 2001 From: asmodai Date: Sun, 16 Oct 2016 16:26:31 +0300 Subject: [PATCH] Fixed possible false error "trying to set return value without active hook" in hookchain forwards --- reapi/src/hook_callback.h | 10 ++++++---- reapi/src/natives/natives_misc.cpp | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 88f0073..f868288 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -40,7 +40,7 @@ inline AType getApiType(int) { return ATYPE_INTEGER; } inline AType getApiType(unsigned) { return ATYPE_INTEGER; } inline AType getApiType(float) { return ATYPE_FLOAT; } inline AType getApiType(const char *) { return ATYPE_STRING; } -inline AType getApiType(char []) { return ATYPE_STRING; } +inline AType getApiType(char[]) { return ATYPE_STRING; } inline AType getApiType(CBaseEntity *) { return ATYPE_CLASSPTR; } inline AType getApiType(edict_t *) { return ATYPE_EDICT; } inline AType getApiType(entvars_t *) { return ATYPE_EVARS; } @@ -155,10 +155,11 @@ template void callVoidForward(size_t func, original_t original, f_args... args) { hookctx_t hookCtx(sizeof...(args), args...); + hookctx_t* save = g_hookCtx; g_hookCtx = &hookCtx; _callVoidForward(g_hookManager.getHookFast(func), original, args...); - g_hookCtx = nullptr; + g_hookCtx = save; } template @@ -179,7 +180,7 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat } 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; } @@ -220,10 +221,11 @@ template R callForward(size_t func, original_t original, f_args... args) { hookctx_t hookCtx(sizeof...(args), args...); + hookctx_t* save = g_hookCtx; g_hookCtx = &hookCtx; auto ret = _callForward(g_hookManager.getHookFast(func), original, args...); - g_hookCtx = nullptr; + g_hookCtx = save; return ret; } diff --git a/reapi/src/natives/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp index 0d5982f..587edfa 100644 --- a/reapi/src/natives/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -109,6 +109,8 @@ cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params) pPlayer->RemovePlayerItem(pItem); pItem->Kill(); break; + case GT_APPEND: break; + default: break; } pItem = pItem->m_pNext;