Move CL_SendMove to MiscTemporary for control over call order

This commit is contained in:
BenCat07 2020-06-10 21:17:07 +02:00
parent dfbb26ad6a
commit 75a4e22b66
4 changed files with 13 additions and 6 deletions

View File

@ -7,6 +7,7 @@
#include <settings/Bool.hpp>
#include "common.hpp"
#include "DetourHook.hpp"
#define MENU_COLOR (menu_color)
@ -44,6 +45,8 @@ extern int stored_buttons;
#if ENABLE_VISUALS
extern bool freecam_is_toggled;
#endif
typedef void (*CL_SendMove_t)();
extern DetourHook cl_warp_sendmovedetour;
namespace hacks::tf2::misc_aimbot
{
bool ShouldHitBuilding(CachedEntity *ent);

View File

@ -3,4 +3,5 @@ class INetMessage;
namespace hacks::tf2::warp
{
void SendNetMessage(INetMessage &msg);
}
void CL_SendMove_hook();
} // namespace hacks::tf2::warp

View File

@ -4,6 +4,7 @@
*/
#include "MiscTemporary.hpp"
#include "Warp.hpp"
std::array<Timer, 32> timers{};
std::array<int, 32> bruteint{};
@ -42,7 +43,13 @@ void color_callback(settings::VariableBase<int> &, int)
{
menu_color = Color(*print_r, *print_g, *print_b, 255);
}
DetourHook cl_warp_sendmovedetour;
static InitRoutine misc_init([]() {
static auto cl_sendmove_addr = gSignatures.GetEngineSignature("55 89 E5 57 56 53 81 EC 2C 10 00 00 C6 85 ? ? ? ? 01");
// Order matters!
cl_warp_sendmovedetour.Init(cl_sendmove_addr, (void *) hacks::tf2::warp::CL_SendMove_hook);
cl_nospread_sendmovedetour.Init(cl_sendmove_addr, (void *) hacks::tf2::nospread::CL_SendMove_hook);
static std::optional<BytePatch> patch;
static std::optional<BytePatch> patch2;
print_r.installChangeCallback(color_callback);
@ -104,6 +111,7 @@ static InitRoutine misc_init([]() {
EC::Register(
EC::Shutdown,
[]() {
cl_warp_sendmovedetour.Shutdown();
if (backup_lerp)
{
cl_interp->SetValue(backup_lerp);

View File

@ -552,8 +552,6 @@ void rvarCallback(settings::VariableBase<bool> &, bool)
yaw_selections.push_back(90.0f);
}
DetourHook cl_sendmove_detour;
typedef void (*CL_SendMove_t)();
void CL_SendMove_hook()
{
byte data[4000];
@ -624,8 +622,6 @@ void CL_Move_hook(float accumulated_extra_samples, bool bFinalTick)
}
static InitRoutine init([]() {
static auto cl_sendmove_addr = gSignatures.GetEngineSignature("55 89 E5 57 56 53 81 EC 2C 10 00 00 C6 85 ? ? ? ? 01");
cl_sendmove_detour.Init(cl_sendmove_addr, (void *) CL_SendMove_hook);
static auto cl_move_addr = gSignatures.GetEngineSignature("55 89 E5 57 56 53 81 EC 9C 00 00 00 83 3D ? ? ? ? 01");
cl_move_detour.Init(cl_move_addr, (void *) CL_Move_hook);
@ -636,7 +632,6 @@ static InitRoutine init([]() {
EC::Shutdown,
[]() {
g_IEventManager2->RemoveListener(&listener);
cl_sendmove_detour.Shutdown();
cl_move_detour.Shutdown();
},
"warp_shutdown");