New method to make createmove functions!
This commit is contained in:
parent
54b440d003
commit
e8734a60f8
@ -1,5 +1,6 @@
|
||||
target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/HookedMethods.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/HookTools.hpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/PreDataUpdate.hpp")
|
||||
|
||||
target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
target_include_directories(cathook PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
14
include/hooks/HookTools.hpp
Normal file
14
include/hooks/HookTools.hpp
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
#include <init.hpp>
|
||||
#include "core/logging.hpp"
|
||||
|
||||
namespace HookTools {
|
||||
void CreateMove();
|
||||
}
|
||||
|
||||
struct CreateMove
|
||||
{
|
||||
CreateMove(int priority = 5, std::function<void()> func = [](){});
|
||||
};
|
@ -16,8 +16,9 @@ target_sources(cathook PRIVATE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/FireEvent.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/FireEventClientSide.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/IsPlayingTimeDemo.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/HookTools.cpp"
|
||||
"${CMAKE_CURRENT_LIST_DIR}/SendDatagram.cpp")
|
||||
|
||||
if(EnableVisuals)
|
||||
add_subdirectory(visual)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <settings/Bool.hpp>
|
||||
#include <hacks/AntiAntiAim.hpp>
|
||||
#include "NavBot.hpp"
|
||||
#include "HookTools.hpp"
|
||||
|
||||
#include "HookedMethods.hpp"
|
||||
#include "PreDataUpdate.hpp"
|
||||
@ -255,6 +256,11 @@ DEFINE_HOOKED_METHOD(CreateMove, bool, void *this_, float input_sample_time,
|
||||
hacks::shared::anti_anti_aim::createMove();
|
||||
}
|
||||
|
||||
{
|
||||
PROF_SECTION(CM_WRAPPER);
|
||||
HookTools::CreateMove();
|
||||
}
|
||||
|
||||
#if ENABLE_IPC
|
||||
#if !LAGBOT_MODE
|
||||
if (hacks::shared::followbot::isEnabled())
|
||||
|
35
src/hooks/HookTools.cpp
Normal file
35
src/hooks/HookTools.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include "HookTools.hpp"
|
||||
|
||||
std::vector<std::pair<int, std::function<void()>>> &GetCreateMoves()
|
||||
{
|
||||
static std::vector<std::pair<int, std::function<void()>>> CreateMoves;
|
||||
return CreateMoves;
|
||||
}
|
||||
|
||||
CreateMove::CreateMove(int priority, std::function<void()> func)
|
||||
{
|
||||
auto &CreateMoves = GetCreateMoves();
|
||||
CreateMoves.emplace_back(priority, func);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
void HookTools::CreateMove()
|
||||
{
|
||||
for (auto i : GetCreateMoves())
|
||||
{
|
||||
i.second();
|
||||
}
|
||||
}
|
||||
|
||||
static InitRoutine init([]() {
|
||||
auto &CreateMoves = GetCreateMoves();
|
||||
std::sort(CreateMoves.begin(),
|
||||
CreateMoves.end(),
|
||||
[](std::pair<int, std::function<void()>> a,
|
||||
std::pair<int, std::function<void()>> b) {
|
||||
return a.first > b.first;
|
||||
});
|
||||
logging::Info("Sorted CreateMove functions: %i",
|
||||
CreateMoves.size());
|
||||
});
|
Reference in New Issue
Block a user