From b451fbd1c8303c63641f32c3951ff5ce46bfa65d Mon Sep 17 00:00:00 2001 From: Arkshine Date: Sat, 25 Oct 2014 20:44:17 +0200 Subject: [PATCH] Fix specialbot not working with [Enable/Disable]HamForward natives --- dlls/hamsandwich/hook_native.cpp | 6 +++--- dlls/hamsandwich/hook_specialbot.cpp | 16 +++++++--------- dlls/hamsandwich/hook_specialbot.h | 9 +++++---- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/dlls/hamsandwich/hook_native.cpp b/dlls/hamsandwich/hook_native.cpp index 161a8915..fd45979e 100644 --- a/dlls/hamsandwich/hook_native.cpp +++ b/dlls/hamsandwich/hook_native.cpp @@ -582,10 +582,12 @@ static cell AMX_NATIVE_CALL RegisterHam(AMX *amx, cell *params) enableSpecialBot = params[5] > 0; } + Forward *pfwd = new Forward(fwd); + // We've passed all tests... if (strcmp(classname, "player") == 0 && enableSpecialBot) { - SpecialbotHandler.RegisterHamSpecialBot(amx, func, function, post, fwd); + SpecialbotHandler.RegisterHamSpecialBot(amx, func, function, post, pfwd); } int **ivtable=(int **)vtable; @@ -599,7 +601,6 @@ static cell AMX_NATIVE_CALL RegisterHam(AMX *amx, cell *params) if (hooks[func].at(i)->tramp == vfunction) { // Yes, this function is hooked - Forward *pfwd=new Forward(fwd); if (post) { hooks[func].at(i)->post.append(pfwd); @@ -616,7 +617,6 @@ static cell AMX_NATIVE_CALL RegisterHam(AMX *amx, cell *params) Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname); hooks[func].append(hook); - Forward *pfwd=new Forward(fwd); if (post) { hook->post.append(pfwd); diff --git a/dlls/hamsandwich/hook_specialbot.cpp b/dlls/hamsandwich/hook_specialbot.cpp index 1fb27e7c..2e3e99ed 100644 --- a/dlls/hamsandwich/hook_specialbot.cpp +++ b/dlls/hamsandwich/hook_specialbot.cpp @@ -19,14 +19,14 @@ extern ke::Vector hooks[HAM_LAST_ENTRY_DONT_USE_ME_LOL]; extern hook_t hooklist[]; -CRegisterHamParams::CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, int &arg_fwd) +CRegisterHamParams::CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, Forward *arg_pfwd) { amx = arg_amx; func = arg_func; function = new char[strlen(arg_function)+1]; strcpy(function, arg_function); post = arg_post; - fwd = arg_fwd; + pfwd = arg_pfwd; } CRegisterHamParams::~CRegisterHamParams() @@ -64,25 +64,25 @@ void CHamSpecialBotHandler::CheckClientKeyValue(int &clientIndex, char *infobuff for (size_t i = 0; i < m_RHP_list.length(); ++i) { CRegisterHamParams *item = m_RHP_list.at(i); - RegisterChecked(item->amx, item->func, item->function, item->post, item->fwd); + RegisterChecked(item->amx, item->func, item->function, item->post, item->pfwd); delete item; } m_RHP_list.clear(); } -void CHamSpecialBotHandler::RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, int &fwd) +void CHamSpecialBotHandler::RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, Forward *pfwd) { if(m_specialbot_vtable == NULL) { - m_RHP_list.append( new CRegisterHamParams(amx, func, function, post, fwd) ); + m_RHP_list.append(new CRegisterHamParams(amx, func, function, post, pfwd)); return; } - RegisterChecked(amx, func, function, post, fwd); + RegisterChecked(amx, func, function, post, pfwd); } -void CHamSpecialBotHandler::RegisterChecked(AMX *amx, int &func, const char *function, int &post, int &fwd) +void CHamSpecialBotHandler::RegisterChecked(AMX *amx, int &func, const char *function, int &post, Forward *pfwd) { void **vtable = m_specialbot_vtable; int **ivtable=(int **)vtable; @@ -94,7 +94,6 @@ void CHamSpecialBotHandler::RegisterChecked(AMX *amx, int &func, const char *fun if (hooks[func].at(i)->tramp == vfunction) { // Yes, this function is hooked - Forward *pfwd = new Forward(fwd); if (post) { hooks[func].at(i)->post.append(pfwd); @@ -113,7 +112,6 @@ void CHamSpecialBotHandler::RegisterChecked(AMX *amx, int &func, const char *fun Hook *hook = new Hook(vtable, hooklist[func].vtid, hooklist[func].targetfunc, hooklist[func].isvoid, hooklist[func].needsretbuf, hooklist[func].paramcount, classname); hooks[func].append(hook); - Forward *pfwd=new Forward(fwd); if (post) { hook->post.append(pfwd); diff --git a/dlls/hamsandwich/hook_specialbot.h b/dlls/hamsandwich/hook_specialbot.h index 85bbb941..d1b1d932 100644 --- a/dlls/hamsandwich/hook_specialbot.h +++ b/dlls/hamsandwich/hook_specialbot.h @@ -16,6 +16,7 @@ #include "ham_utils.h" #include +#include "forward.h" class CRegisterHamParams { @@ -24,9 +25,9 @@ public: int func; char *function; int post; - int fwd; + Forward *pfwd; - CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, int &arg_fwd); + CRegisterHamParams(AMX *arg_amx, int &arg_func, const char *arg_function, int &arg_post, Forward *arg_pfwd); ~CRegisterHamParams(); private: CRegisterHamParams(){} @@ -37,10 +38,10 @@ class CHamSpecialBotHandler public: CHamSpecialBotHandler(); void CheckClientKeyValue(int &clientIndex, char *infobuffer, const char *key, const char *value); - void RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, int &fwd); + void RegisterHamSpecialBot(AMX *amx, int &func, const char *function, int &post, Forward *pfwd); private: - void RegisterChecked(AMX *amx, int &func, const char *function, int &post, int &fwd); + void RegisterChecked(AMX *amx, int &func, const char *function, int &post, Forward *pfwd); ke::Vector m_RHP_list; void **m_specialbot_vtable;