mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-14 15:48:03 +03:00
Add new return type for amxx forwards
This commit is contained in:
parent
8f9e7c16cb
commit
592ebca528
@ -120,8 +120,11 @@ enum
|
||||
{
|
||||
HC_CONTINUE = 0, // Plugin didn't take any action
|
||||
HC_SUPERCEDE, // Skip real function, use my return value
|
||||
HC_BREAK // Skip all forwards and real function, use my return value
|
||||
HC_BREAK, // Skip all forwards and real function, use my return value
|
||||
// @note Warning: Be very careful, using this type of return will skip calls for all following AMXX plugins
|
||||
|
||||
HC_BYPASS // Skip calls for all following AMXX plugins, but call the original function
|
||||
// @note Warning: In PRE skips all forwards including POST forwards
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -5,10 +5,13 @@
|
||||
// hookchain return type
|
||||
enum HookChainState
|
||||
{
|
||||
HC_CONTINUE = 0, // plugin didn't take any action
|
||||
HC_SUPERCEDE, // skip real function, use my return value
|
||||
HC_BREAK // skip all forwards and real function, use my return value
|
||||
// @note Warning: Be very careful using this type of return will skip calls for all following AMXX the plugins.
|
||||
HC_CONTINUE = 0, // Plugin didn't take any action
|
||||
HC_SUPERCEDE, // Skip real function, use my return value
|
||||
HC_BREAK, // Skip all forwards and real function, use my return value
|
||||
// @note Warning: Be very careful using this type of return will skip calls for all following AMXX the plugins
|
||||
|
||||
HC_BYPASS // Skip calls for all following AMXX plugins, but call the original function
|
||||
// @note Warning: In PRE skips all forwards including POST forwards
|
||||
};
|
||||
|
||||
// api types
|
||||
@ -168,15 +171,17 @@ NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_ar
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||
{
|
||||
hookCtx->SetId(fwd->GetIndex()); // set current handler hook
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetFwdIndex(), std::forward<f_args &&>(args)...);
|
||||
int ret = g_amxxapi.ExecuteForward(fwd->GetFwdIndex(), std::forward<f_args &&>(args)...);
|
||||
hookCtx->ResetId();
|
||||
|
||||
if (unlikely(ret == HC_BREAK)) {
|
||||
if (unlikely(ret == HC_BREAK))
|
||||
return;
|
||||
}
|
||||
|
||||
if (unlikely(ret > hc_state))
|
||||
hc_state = ret;
|
||||
|
||||
if (unlikely(ret == HC_BYPASS))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,18 +192,21 @@ NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_ar
|
||||
hook->wasCalled = true;
|
||||
}
|
||||
|
||||
if (hc_state != HC_BYPASS)
|
||||
{
|
||||
for (auto fwd : hook->post)
|
||||
{
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||
{
|
||||
hookCtx->SetId(fwd->GetIndex()); // set current handler hook
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetFwdIndex(), std::forward<f_args &&>(args)...);
|
||||
int ret = g_amxxapi.ExecuteForward(fwd->GetFwdIndex(), std::forward<f_args &&>(args)...);
|
||||
hookCtx->ResetId();
|
||||
|
||||
if (unlikely(ret == HC_BREAK))
|
||||
if (unlikely(ret == HC_BREAK || ret == HC_BYPASS))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hook->wasCalled = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user