From 4fcfc913d3f914c22d9456acb5de2edace6c24bd Mon Sep 17 00:00:00 2001 From: Vincent Herbet Date: Wed, 26 Jul 2017 20:36:17 +0200 Subject: [PATCH] Fix Ham_Item_GetItemInfo incorrect associated handler (#449) --- modules/hamsandwich/call_funcs.cpp | 7 +++---- modules/hamsandwich/call_funcs.h | 2 +- modules/hamsandwich/hook_callbacks.cpp | 14 ++++++++++---- modules/hamsandwich/hook_callbacks.h | 8 ++++---- modules/hamsandwich/hook_create.cpp | 2 +- modules/hamsandwich/hook_create.h | 2 +- modules/hamsandwich/hook_native.cpp | 2 +- 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/modules/hamsandwich/call_funcs.cpp b/modules/hamsandwich/call_funcs.cpp index 97504b70..f180573a 100644 --- a/modules/hamsandwich/call_funcs.cpp +++ b/modules/hamsandwich/call_funcs.cpp @@ -665,7 +665,7 @@ cell Call_Void_Int_Int_Int(AMX *amx, cell *params) return 1; } -cell Call_Void_ItemInfo(AMX *amx, cell *params) +cell Call_Int_ItemInfo(AMX *amx, cell *params) { SETUP(1); @@ -677,11 +677,10 @@ cell Call_Void_ItemInfo(AMX *amx, cell *params) return 0; } #if defined(_WIN32) - reinterpret_cast(__func)(pv, 0, ptr); + return reinterpret_cast(__func)(pv, 0, ptr); #elif defined(__linux__) || defined(__APPLE__) - reinterpret_cast(__func)(pv, ptr); + return reinterpret_cast(__func)(pv, ptr); #endif - return 1; } cell Call_Float_Void(AMX *amx, cell *params) diff --git a/modules/hamsandwich/call_funcs.h b/modules/hamsandwich/call_funcs.h index 93cde151..0b492a9c 100644 --- a/modules/hamsandwich/call_funcs.h +++ b/modules/hamsandwich/call_funcs.h @@ -75,7 +75,7 @@ cell Call_Void_Entvar_Float(AMX *amx, cell *params); cell Call_Void_Int_Int_Int(AMX *amx, cell *params); -cell Call_Void_ItemInfo(AMX *amx, cell *params); +cell Call_Int_ItemInfo(AMX *amx, cell *params); cell Call_Float_Void(AMX *amx, cell *params); diff --git a/modules/hamsandwich/hook_callbacks.cpp b/modules/hamsandwich/hook_callbacks.cpp index 3a1a13cd..59588adf 100644 --- a/modules/hamsandwich/hook_callbacks.cpp +++ b/modules/hamsandwich/hook_callbacks.cpp @@ -1080,9 +1080,12 @@ void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3) KILL_VECTOR() POP() } -void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo) +int Hook_Int_ItemInfo(Hook *hook, void *pthis, void *iteminfo) { - PUSH_VOID() + int ret = 0; + int origret = 0; + + PUSH_INT() MAKE_VECTOR() @@ -1092,9 +1095,9 @@ void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo) ,iteminfo PRE_END() #if defined(_WIN32) - reinterpret_cast(hook->func)(pthis, 0, iteminfo); + origret = reinterpret_cast(hook->func)(pthis, 0, iteminfo); #elif defined(__linux__) || defined(__APPLE__) - reinterpret_cast(hook->func)(pthis, iteminfo); + origret = reinterpret_cast(hook->func)(pthis, iteminfo); #endif POST_START() @@ -1103,6 +1106,9 @@ void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo) KILL_VECTOR() POP() + + CHECK_RETURN() + return ret; } float Hook_Float_Void(Hook *hook, void *pthis) diff --git a/modules/hamsandwich/hook_callbacks.h b/modules/hamsandwich/hook_callbacks.h index d9030856..c50f4f8e 100644 --- a/modules/hamsandwich/hook_callbacks.h +++ b/modules/hamsandwich/hook_callbacks.h @@ -198,10 +198,10 @@ const bool RB_Void_Int_Int_Int = false; const int PC_Void_Int_Int_Int = 3; void Hook_Void_Int_Int_Int(Hook *hook, void *pthis, int i1, int i2, int i3); -const bool RT_Void_ItemInfo = true; -const bool RB_Void_ItemInfo = false; -const int PC_Void_ItemInfo = 1; -void Hook_Void_ItemInfo(Hook *hook, void *pthis, void *iteminfo); +const bool RT_Int_ItemInfo = false; +const bool RB_Int_ItemInfo = false; +const int PC_Int_ItemInfo = 1; +int Hook_Int_ItemInfo(Hook *hook, void *pthis, void *iteminfo); const bool RT_Float_Void = false; diff --git a/modules/hamsandwich/hook_create.cpp b/modules/hamsandwich/hook_create.cpp index 4b356434..d2ab0061 100644 --- a/modules/hamsandwich/hook_create.cpp +++ b/modules/hamsandwich/hook_create.cpp @@ -163,7 +163,7 @@ int Create_Void_Int_Int_Int(AMX *amx, const char *func) return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); } -int Create_Void_ItemInfo(AMX *amx, const char *func) +int Create_Int_ItemInfo(AMX *amx, const char *func) { return MF_RegisterSPForwardByName(amx, func, FP_CELL, FP_CELL, FP_DONE); } diff --git a/modules/hamsandwich/hook_create.h b/modules/hamsandwich/hook_create.h index 9c7045cf..9bdd24ca 100644 --- a/modules/hamsandwich/hook_create.h +++ b/modules/hamsandwich/hook_create.h @@ -75,7 +75,7 @@ int Create_Void_Entvar_Float(AMX *amx, const char *func); int Create_Void_Int_Int_Int(AMX *amx, const char *func); -int Create_Void_ItemInfo(AMX *amx, const char *func); +int Create_Int_ItemInfo(AMX *amx, const char *func); int Create_Float_Void(AMX *amx, const char *func); diff --git a/modules/hamsandwich/hook_native.cpp b/modules/hamsandwich/hook_native.cpp index 4b70a492..42a8ed87 100644 --- a/modules/hamsandwich/hook_native.cpp +++ b/modules/hamsandwich/hook_native.cpp @@ -514,7 +514,7 @@ hook_t hooklist[] = { V("ts_weapon_alternateattack", Void_Void) }, - { V("item_getiteminfo", Void_ItemInfo) } + { V("item_getiteminfo", Int_ItemInfo) } };