mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2024-12-24 13:55:36 +03:00
Fix specialbot not working with [Enable/Disable]HamForward natives
This commit is contained in:
parent
d8fc093fd8
commit
b451fbd1c8
@ -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);
|
||||
|
@ -19,14 +19,14 @@ extern ke::Vector<Hook*> 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);
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include "ham_utils.h"
|
||||
#include <am-vector.h>
|
||||
#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<CRegisterHamParams*> m_RHP_list;
|
||||
void **m_specialbot_vtable;
|
||||
|
Loading…
Reference in New Issue
Block a user