Skip to content

Commit 7e14d12

Browse files
Revert "Implemented IsReapiHookOriginalWasCalled which determine whether original function was called or not (rehlds#172)"
This reverts commit fb5ec01.
1 parent fb5ec01 commit 7e14d12

File tree

6 files changed

+10
-70
lines changed

6 files changed

+10
-70
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
majorVersion=5
2-
minorVersion=16
2+
minorVersion=15
33
maintenanceVersion=0

reapi/extra/amxmodx/scripting/include/reapi.inc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ native any:GetHookChainReturn(AType:type, any:...);
192192
*/
193193
native SetHookChainArg(number, AType:type, any:...);
194194

195-
/*
196-
* Return call state of original API function (that are available into enum).
197-
* Look at the enums for parameter lists.
198-
*
199-
* @param func The function to get state
200-
*
201-
* @return Returns true if the original function was called, otherwise false
202-
*/
203-
native bool:IsReapiHookOriginalWasCalled({EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib}:function_id);
204-
205195
/*
206196
* Compares the entity to a specified classname.
207197
* @note This native also checks the validity of an entity.

reapi/src/hook_callback.h

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,12 @@ struct hookctx_t
144144
extern hookctx_t* g_hookCtx;
145145

146146
template <typename original_t, typename ...f_args>
147-
NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_args&&... args)
147+
NOINLINE void DLLEXPORT _callVoidForward(const hook_t* hook, original_t original, f_args&&... args)
148148
{
149149
auto hookCtx = g_hookCtx;
150150
hookCtx->reset();
151151
int hc_state = HC_CONTINUE;
152152

153-
hook->wasCalled = false;
154-
155153
for (auto fwd : hook->pre)
156154
{
157155
if (likely(fwd->GetState() == FSTATE_ENABLED))
@@ -171,21 +169,16 @@ NOINLINE void DLLEXPORT _callVoidForward(hook_t* hook, original_t original, f_ar
171169
g_hookCtx = nullptr;
172170
original(std::forward<f_args &&>(args)...);
173171
g_hookCtx = hookCtx;
174-
hook->wasCalled = true;
175172
}
176173

177-
for (auto fwd : hook->post)
178-
{
179-
if (likely(fwd->GetState() == FSTATE_ENABLED))
180-
{
174+
for (auto fwd : hook->post) {
175+
if (likely(fwd->GetState() == FSTATE_ENABLED)) {
181176
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), std::forward<f_args &&>(args)...);
182177

183178
if (unlikely(ret == HC_BREAK))
184179
break;
185180
}
186181
}
187-
188-
hook->wasCalled = false;
189182
}
190183

191184
template <typename original_t, typename ...f_args>
@@ -204,15 +197,13 @@ void callVoidForward(size_t func, original_t original, f_args&&... args)
204197
}
205198

206199
template <typename R, typename original_t, typename ...f_args>
207-
NOINLINE R DLLEXPORT _callForward(hook_t* hook, original_t original, f_args&&... args)
200+
NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, f_args&&... args)
208201
{
209202
auto hookCtx = g_hookCtx;
210203
hookCtx->reset(getApiType(R()));
211204

212205
int hc_state = HC_CONTINUE;
213206

214-
hook->wasCalled = false;
215-
216207
for (auto fwd : hook->pre)
217208
{
218209
if (likely(fwd->GetState() == FSTATE_ENABLED))
@@ -242,7 +233,6 @@ NOINLINE R DLLEXPORT _callForward(hook_t* hook, original_t original, f_args&&...
242233
g_hookCtx = nullptr;
243234
auto retVal = original(std::forward<f_args &&>(args)...);
244235
g_hookCtx = hookCtx;
245-
hook->wasCalled = true;
246236

247237
if (unlikely(!hookCtx->retVal.set)) {
248238
switch (sizeof retVal) {
@@ -260,18 +250,14 @@ NOINLINE R DLLEXPORT _callForward(hook_t* hook, original_t original, f_args&&...
260250
}
261251
}
262252

263-
for (auto fwd : hook->post)
264-
{
265-
if (likely(fwd->GetState() == FSTATE_ENABLED))
266-
{
253+
for (auto fwd : hook->post) {
254+
if (likely(fwd->GetState() == FSTATE_ENABLED)) {
267255
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), std::forward<f_args &&>(args)...);
268256

269257
if (unlikely(ret == HC_BREAK))
270258
break;
271259
}
272260
}
273-
274-
hook->wasCalled = false;
275261

276262
return *(R *)&hookCtx->retVal._integer;
277263
}

reapi/src/hook_list.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct regfunc
7171

7272
int regfunc::current_cell = 1;
7373

74-
#define ENG(h,...) { {}, {}, #h, "ReHLDS", [](){ return api_cfg.hasReHLDS(); }, ((!(RH_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RH_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RehldsHookchains->h()->registerHook(&h); }, [](){ g_RehldsHookchains->h()->unregisterHook(&h); }, false}
74+
#define ENG(h,...) { {}, {}, #h, "ReHLDS", [](){ return api_cfg.hasReHLDS(); }, ((!(RH_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RH_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RehldsHookchains->h()->registerHook(&h); }, [](){ g_RehldsHookchains->h()->unregisterHook(&h); }}
7575
hook_t hooklist_engine[] = {
7676
ENG(SV_StartSound),
7777
ENG(SV_DropClient),
@@ -80,7 +80,7 @@ hook_t hooklist_engine[] = {
8080
ENG(SV_WriteFullClientUpdate, _AMXX)
8181
};
8282

83-
#define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }, false}
83+
#define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }}
8484
hook_t hooklist_gamedll[] = {
8585
DLL(GetForceCamera),
8686
DLL(PlayerBlind),
@@ -213,7 +213,7 @@ hook_t hooklist_gib[] = {
213213
DLL(CGib_WaitTillLand),
214214
};
215215

216-
#define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }, false}
216+
#define RCHECK(h,...) { {}, {}, #h, "ReChecker", [](){ return api_cfg.hasRechecker(); }, ((!(RC_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RC_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_RecheckerHookchains->h()->registerHook(&h); }, [](){ g_RecheckerHookchains->h()->unregisterHook(&h); }}
217217
hook_t hooklist_rechecker[] = {
218218
RCHECK(FileConsistencyProcess, _AMXX),
219219
RCHECK(FileConsistencyFinal),

reapi/src/hook_list.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ struct hook_t
2323
regchain_t unregisterHookchain; // unregister re* API hook
2424

2525
void clear();
26-
27-
bool wasCalled;
2826
};
2927

3028
extern hook_t hooklist_engine[];

reapi/src/natives/natives_hookchains.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -314,38 +314,6 @@ cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params)
314314
return TRUE;
315315
}
316316

317-
/*
318-
* Return call state of original API function (that are available into enum).
319-
* Look at the enums for parameter lists.
320-
*
321-
* @param func The function to get state
322-
*
323-
* @return Returns true if the API original function was called, otherwise false
324-
*
325-
* native bool:IsReapiHookOriginalWasCalled(any:function_id);
326-
*/
327-
cell AMX_NATIVE_CALL IsReapiHookOriginalWasCalled(AMX* amx, cell* params)
328-
{
329-
enum args_e { arg_count, arg_func };
330-
331-
int func = params[arg_func];
332-
auto hook = g_hookManager.getHook(func);
333-
334-
if (unlikely(hook == nullptr))
335-
{
336-
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: function with id (%d) doesn't exist in current API version.", __FUNCTION__, func);
337-
return INVALID_HOOKCHAIN;
338-
}
339-
340-
if (unlikely(!hook->checkRequirements()))
341-
{
342-
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: function (%s) is not available, %s required.", __FUNCTION__, hook->func_name, hook->depend_name);
343-
return INVALID_HOOKCHAIN;
344-
}
345-
346-
return hook->wasCalled ? TRUE : FALSE;
347-
}
348-
349317
AMX_NATIVE_INFO HookChain_Natives[] =
350318
{
351319
{ "RegisterHookChain", RegisterHookChain },
@@ -358,8 +326,6 @@ AMX_NATIVE_INFO HookChain_Natives[] =
358326

359327
{ "SetHookChainArg", SetHookChainArg },
360328

361-
{ "IsReapiHookOriginalWasCalled", IsReapiHookOriginalWasCalled },
362-
363329
{ nullptr, nullptr }
364330
};
365331

0 commit comments

Comments
 (0)