diff --git a/include/common.hpp b/include/common.hpp index 3151f230..95819b26 100755 --- a/include/common.hpp +++ b/include/common.hpp @@ -97,7 +97,7 @@ #include "init.hpp" #include "reclasses/reclasses.hpp" #include -//#include "HookTools.hpp" +#include "HookTools.hpp" #include "copypasted/Netvar.h" #include "copypasted/CSignature.h" diff --git a/include/hooks/HookTools.hpp b/include/hooks/HookTools.hpp index 249d9c2a..a122df9e 100644 --- a/include/hooks/HookTools.hpp +++ b/include/hooks/HookTools.hpp @@ -4,41 +4,37 @@ #include #include "core/logging.hpp" #include +#include "core/profiler.hpp" +#include +#include "config.h" class HookedFunction; namespace HookTools { std::vector &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 m_func; -// HookTools::types m_type; -//}; -} // namespace HookTools class HookedFunction { std::string m_name; std::function m_func; - HookTools::types m_type; - void init(HookTools::types type, std::string name, int priority, std::function func) + HookedFunctions_types m_type; + void init(HookedFunctions_types type, std::string name, int priority, std::function 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 func) + HookedFunction(HookedFunctions_types type, std::string name, int priority, std::function func) { init(type, name, priority, func); } - HookedFunction(HookTools::types type, int priority, std::function func) + HookedFunction(HookedFunctions_types type, int priority, std::function 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 func) + HookedFunction(HookedFunctions_types type, std::string name, std::function func) { int priority = 5; init(type, name, priority, func); } - HookedFunction(HookTools::types type, std::function func) + HookedFunction(HookedFunctions_types type, std::function func) { - std::string name("UNNAMED_FUNCTION"); + static const std::string name("UNNAMED_FUNCTIONS"); int priority = 5; init(type, name, priority, func); } diff --git a/src/hacks/CatBot.cpp b/src/hacks/CatBot.cpp index efa6bf51..3eadfb8a 100644 --- a/src/hacks/CatBot.cpp +++ b/src/hacks/CatBot.cpp @@ -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; diff --git a/src/hacks/LightESP.cpp b/src/hacks/LightESP.cpp index d3db8f29..82519d26 100644 --- a/src/hacks/LightESP.cpp +++ b/src/hacks/LightESP.cpp @@ -3,7 +3,6 @@ #include #endif #include -#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++) { diff --git a/src/hooks/HookTools.cpp b/src/hooks/HookTools.cpp index 3fe0965d..3bd9da96 100644 --- a/src/hooks/HookTools.cpp +++ b/src/hooks/HookTools.cpp @@ -6,21 +6,13 @@ std::vector &HookTools::GetHookedFunctions() return CreateMoves; } -//CreateMove::CreateMove(int priority, std::function func) -//{ -// auto &CreateMoves = GetCreateMoves(); -// CreateMoves.emplace_back(priority, func); -//} - - - // ----------------------------------------------------------- void HookTools::CM() { for (auto i : GetHookedFunctions()) { - i->run(HookTools::CreateMove); + i->run(HF_CreateMove); } }