Some more hookedfunction stuff
This commit is contained in:
parent
bd6f5f53ce
commit
c8118344a1
@ -97,7 +97,7 @@
|
||||
#include "init.hpp"
|
||||
#include "reclasses/reclasses.hpp"
|
||||
#include <CNavFile.h>
|
||||
//#include "HookTools.hpp"
|
||||
#include "HookTools.hpp"
|
||||
|
||||
#include "copypasted/Netvar.h"
|
||||
#include "copypasted/CSignature.h"
|
||||
|
@ -4,41 +4,37 @@
|
||||
#include <init.hpp>
|
||||
#include "core/logging.hpp"
|
||||
#include <string>
|
||||
#include "core/profiler.hpp"
|
||||
#include <string>
|
||||
#include "config.h"
|
||||
|
||||
class HookedFunction;
|
||||
namespace HookTools
|
||||
{
|
||||
std::vector<HookedFunction*> &GetHookedFunctions();
|
||||
enum types
|
||||
void CM();
|
||||
} // namespace HookTools
|
||||
|
||||
enum HookedFunctions_types
|
||||
{
|
||||
CreateMove = 0,
|
||||
Painttraverse
|
||||
HF_CreateMove = 0,
|
||||
HF_Painttraverse
|
||||
|
||||
};
|
||||
void CM();
|
||||
|
||||
// struct HookedBase
|
||||
//{
|
||||
// int m_priority;
|
||||
// std::string m_name;
|
||||
// std::function<void()> m_func;
|
||||
// HookTools::types m_type;
|
||||
//};
|
||||
} // namespace HookTools
|
||||
|
||||
class HookedFunction
|
||||
{
|
||||
std::string m_name;
|
||||
std::function<void()> m_func;
|
||||
HookTools::types m_type;
|
||||
void init(HookTools::types type, std::string name, int priority, std::function<void()> func)
|
||||
HookedFunctions_types m_type;
|
||||
void init(HookedFunctions_types type, std::string name, int priority, std::function<void()> func)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case HookTools::CreateMove:
|
||||
case HF_CreateMove:
|
||||
m_name = "CM_";
|
||||
break;
|
||||
case HookTools::Painttraverse:
|
||||
case HF_Painttraverse:
|
||||
m_name = "PT_";
|
||||
break;
|
||||
}
|
||||
@ -50,30 +46,34 @@ class HookedFunction
|
||||
}
|
||||
public:
|
||||
int m_priority;
|
||||
void run(HookTools::types type)
|
||||
void run(HookedFunctions_types type)
|
||||
{
|
||||
if (m_type == type)
|
||||
{
|
||||
#if ENABLE_PROFILER
|
||||
static ProfilerSection section(m_name);
|
||||
ProfilerNode node(section);
|
||||
#endif
|
||||
m_func();
|
||||
}
|
||||
}
|
||||
HookedFunction(HookTools::types type, std::string name, int priority, std::function<void()> func)
|
||||
HookedFunction(HookedFunctions_types type, std::string name, int priority, std::function<void()> func)
|
||||
{
|
||||
init(type, name, priority, func);
|
||||
}
|
||||
HookedFunction(HookTools::types type, int priority, std::function<void()> func)
|
||||
HookedFunction(HookedFunctions_types type, int priority, std::function<void()> func)
|
||||
{
|
||||
std::string name("UNNAMED_FUNCTION");
|
||||
static const std::string name("UNNAMED_FUNCTIONS");
|
||||
init(type, name, priority, func);
|
||||
}
|
||||
HookedFunction(HookTools::types type, std::string name, std::function<void()> func)
|
||||
HookedFunction(HookedFunctions_types type, std::string name, std::function<void()> func)
|
||||
{
|
||||
int priority = 5;
|
||||
init(type, name, priority, func);
|
||||
}
|
||||
HookedFunction(HookTools::types type, std::function<void()> func)
|
||||
HookedFunction(HookedFunctions_types type, std::function<void()> func)
|
||||
{
|
||||
std::string name("UNNAMED_FUNCTION");
|
||||
static const std::string name("UNNAMED_FUNCTIONS");
|
||||
int priority = 5;
|
||||
init(type, name, priority, func);
|
||||
}
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "common.hpp"
|
||||
#include "hack.hpp"
|
||||
#include "PlayerTools.hpp"
|
||||
#include "HookTools.hpp"
|
||||
|
||||
static settings::Bool enable{ "cat-bot.enable", "false" };
|
||||
|
||||
@ -287,7 +286,7 @@ void smart_crouch()
|
||||
}
|
||||
|
||||
// TODO: add more stuffs
|
||||
static HookedFunction cm(HookTools::CreateMove, 5, []()
|
||||
static HookedFunction cm(HF_CreateMove, "catbot", 5, []()
|
||||
{
|
||||
if (!*enable)
|
||||
return;
|
||||
|
@ -3,7 +3,6 @@
|
||||
#include <glez/draw.hpp>
|
||||
#endif
|
||||
#include <settings/Bool.hpp>
|
||||
#include "HookTools.hpp"
|
||||
|
||||
static settings::Bool enable{ "lightesp.enable", "false" };
|
||||
|
||||
@ -16,9 +15,8 @@ Vector maxp[32];
|
||||
bool drawEsp[32];
|
||||
|
||||
#if ENABLE_VISUALS
|
||||
static HookedFunction cm(HookTools::CreateMove, 5, [](){
|
||||
//PROF_SECTION(CM_lightesp);
|
||||
if (!enable)
|
||||
static HookedFunction cm(HF_CreateMove, "lightesp", 5, [](){
|
||||
if (!*enable)
|
||||
return;
|
||||
for (int i = 1; i < g_IEngine->GetMaxClients(); i++)
|
||||
{
|
||||
|
@ -6,21 +6,13 @@ std::vector<HookedFunction*> &HookTools::GetHookedFunctions()
|
||||
return CreateMoves;
|
||||
}
|
||||
|
||||
//CreateMove::CreateMove(int priority, std::function<void()> func)
|
||||
//{
|
||||
// auto &CreateMoves = GetCreateMoves();
|
||||
// CreateMoves.emplace_back(priority, func);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
void HookTools::CM()
|
||||
{
|
||||
for (auto i : GetHookedFunctions())
|
||||
{
|
||||
i->run(HookTools::CreateMove);
|
||||
i->run(HF_CreateMove);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user