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_CONTINUE = 0, // Plugin didn't take any action
|
||||||
HC_SUPERCEDE, // Skip real function, use my return value
|
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
|
// @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
|
// hookchain return type
|
||||||
enum HookChainState
|
enum HookChainState
|
||||||
{
|
{
|
||||||
HC_CONTINUE = 0, // plugin didn't take any action
|
HC_CONTINUE = 0, // Plugin didn't take any action
|
||||||
HC_SUPERCEDE, // skip real function, use my return value
|
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 the plugins.
|
// @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
|
// api types
|
||||||
@ -168,15 +171,17 @@ NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_ar
|
|||||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||||
{
|
{
|
||||||
hookCtx->SetId(fwd->GetIndex()); // set current handler hook
|
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();
|
hookCtx->ResetId();
|
||||||
|
|
||||||
if (unlikely(ret == HC_BREAK)) {
|
if (unlikely(ret == HC_BREAK))
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (unlikely(ret > hc_state))
|
if (unlikely(ret > hc_state))
|
||||||
hc_state = ret;
|
hc_state = ret;
|
||||||
|
|
||||||
|
if (unlikely(ret == HC_BYPASS))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,16 +192,19 @@ NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_ar
|
|||||||
hook->wasCalled = true;
|
hook->wasCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto fwd : hook->post)
|
if (hc_state != HC_BYPASS)
|
||||||
{
|
{
|
||||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
for (auto fwd : hook->post)
|
||||||
{
|
{
|
||||||
hookCtx->SetId(fwd->GetIndex()); // set current handler hook
|
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetFwdIndex(), std::forward<f_args &&>(args)...);
|
{
|
||||||
hookCtx->ResetId();
|
hookCtx->SetId(fwd->GetIndex()); // set current handler hook
|
||||||
|
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;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user