diff --git a/include/core/offsets.hpp b/include/core/offsets.hpp index df7bea52..f08c7688 100644 --- a/include/core/offsets.hpp +++ b/include/core/offsets.hpp @@ -80,9 +80,9 @@ struct offsets { return PlatformOffset(7, undefined, undefined); } - static constexpr uint32_t CreateMoveLate() + static constexpr uint32_t CreateMoveEarly() { - return PlatformOffset(21, undefined, undefined); + return PlatformOffset(3, undefined, undefined); } static constexpr uint32_t CreateMove() { diff --git a/include/hooks/HookTools.hpp b/include/hooks/HookTools.hpp index c0c1ccb4..05f4d4e0 100644 --- a/include/hooks/HookTools.hpp +++ b/include/hooks/HookTools.hpp @@ -12,7 +12,7 @@ enum ec_types /* Note: engine prediction is run on this kind of CreateMove */ CreateMove = 0, /* Note: this is the CreatMove one layer higher, and should only be used for things that mess with command number*/ - CreateMoveLate, + CreateMoveEarly, /* This kind of CreateMove will run earlier than all CreateMove events * and guranteed to run before EnginePrediction */ diff --git a/include/hooks/HookedMethods.hpp b/include/hooks/HookedMethods.hpp index caf58beb..038123ed 100644 --- a/include/hooks/HookedMethods.hpp +++ b/include/hooks/HookedMethods.hpp @@ -41,11 +41,11 @@ DECLARE_HOOKED_METHOD(LevelShutdown, void, void *); // ClientMode + 4 DECLARE_HOOKED_METHOD(FireGameEvent, void, void *, IGameEvent *); // IBaseClient -DECLARE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float input_sample_time, bool arg3) DECLARE_HOOKED_METHOD(DispatchUserMessage, bool, void *, int, bf_read &); DECLARE_HOOKED_METHOD(IN_KeyEvent, int, void *, int, ButtonCode_t, const char *); DECLARE_HOOKED_METHOD(FrameStageNotify, void, void *, ClientFrameStage_t); // IInput +DECLARE_HOOKED_METHOD(CreateMoveEarly, void, IInput *, int, float, bool) DECLARE_HOOKED_METHOD(GetUserCmd, CUserCmd *, IInput *, int); // INetChannel DECLARE_HOOKED_METHOD(SendNetMsg, bool, INetChannel *, INetMessage &, bool, bool); diff --git a/src/crits.cpp b/src/crits.cpp index 1f071840..797a4806 100644 --- a/src/crits.cpp +++ b/src/crits.cpp @@ -1013,7 +1013,7 @@ static CatCommand debug_print_crit_info("debug_print_crit_info", "Print a bunch }); static InitRoutine init([]() { - EC::Register(EC::CreateMoveLate, CreateMove, "crit_cm"); + EC::Register(EC::CreateMoveEarly, CreateMove, "crit_cm"); #if ENABLE_VISUALS EC::Register(EC::Draw, Draw, "crit_draw"); #endif diff --git a/src/hack.cpp b/src/hack.cpp index 6c5a9e78..b455f3d6 100644 --- a/src/hack.cpp +++ b/src/hack.cpp @@ -185,7 +185,6 @@ void hack::Hook() hooks::client.Set(g_IBaseClient); hooks::client.HookMethod(HOOK_ARGS(DispatchUserMessage)); - hooks::client.HookMethod(HOOK_ARGS(CreateMoveLate)); #if ENABLE_VISUALS hooks::client.HookMethod(HOOK_ARGS(FrameStageNotify)); hooks::client.HookMethod(HOOK_ARGS(IN_KeyEvent)); @@ -215,6 +214,7 @@ void hack::Hook() hooks::input.Set(g_IInput); hooks::input.HookMethod(HOOK_ARGS(GetUserCmd)); + hooks::input.HookMethod(HOOK_ARGS(CreateMoveEarly)); hooks::input.Apply(); #if ENABLE_VISUALS || ENABLE_TEXTMODE diff --git a/src/hacks/ESP.cpp b/src/hacks/ESP.cpp index fcae75b2..32b0cdcf 100644 --- a/src/hacks/ESP.cpp +++ b/src/hacks/ESP.cpp @@ -189,7 +189,7 @@ struct bonelist_s return; // ent->m_bBonesSetup = false; - const auto &bones = ent->hitboxes.GetBones(); + const auto &bones = ent->hitboxes.GetBones(); DrawBoneList(bones, leg_r, 3, color); DrawBoneList(bones, leg_l, 3, color); DrawBoneList(bones, bottom, 3, color); @@ -295,8 +295,7 @@ static void cm() static draw::Texture atlas{ paths::getDataPath("/textures/atlas.png") }; static draw::Texture idspec{ paths::getDataPath("/textures/idspec.png") }; - - + Timer retry{}; void Init() { @@ -625,23 +624,23 @@ void _FASTCALL ProcessEntityPT(CachedEntity *ent) } } - if (draw_bones) - { + if (draw_bones) + { if (vischeck && !ent->IsVisible()) transparent = true; - rgba_t bone_color = colors::EntityF(ent); + rgba_t bone_color = colors::EntityF(ent); if (transparent) bone_color = colors::Transparent(bone_color); - bonelist_s bl; - if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant() && LOCAL_E->m_bAlivePlayer()) - { - if (bones_color) - bl.Draw(ent, bone_color); - else - bl.Draw(ent, colors::white); - } - } + bonelist_s bl; + if (!CE_INVALID(ent) && ent->m_bAlivePlayer() && !RAW_ENT(ent)->IsDormant() && LOCAL_E->m_bAlivePlayer()) + { + if (bones_color) + bl.Draw(ent, bone_color); + else + bl.Draw(ent, colors::white); + } + } // Top horizontal health bar if (*healthbar == 1) @@ -1372,7 +1371,7 @@ void _FASTCALL ProcessEntity(CachedEntity *ent) if (IDX_GOOD(widx)) { CachedEntity *weapon = ENTITY(widx); - if (CE_VALID(weapon)) + if (CE_VALID(weapon) && re::C_BaseCombatWeapon::IsBaseCombatWeapon(RAW_ENT(weapon))) { if (show_weapon) { diff --git a/src/hooks/CreateMove.cpp b/src/hooks/CreateMove.cpp index 290612b4..ce3f7c0e 100644 --- a/src/hooks/CreateMove.cpp +++ b/src/hooks/CreateMove.cpp @@ -420,14 +420,15 @@ void WriteCmd(IInput *input, CUserCmd *cmd, int sequence_nr) GetCmds(input)[sequence_nr % VERIFIED_CMD_SIZE] = *cmd; } -DEFINE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float input_sample_time, bool arg3) +// This gets called before the other CreateMove, but since we run original first in here all the stuff gets called after normal CreateMove is done +DEFINE_HOOKED_METHOD(CreateMoveEarly, void, IInput *this_, int sequence_nr, float input_sample_time, bool arg3) { - // Call original function, includes Early CreateMove - original::CreateMoveLate(this_, sequence_nr, input_sample_time, arg3); + // Call original function, includes Normal CreateMove + original::CreateMoveEarly(this_, sequence_nr, input_sample_time, arg3); CUserCmd *cmd = nullptr; - if (g_IInput && GetCmds(g_IInput) && sequence_nr > 0) - cmd = g_IInput->GetUserCmd(sequence_nr); + if (this_ && GetCmds(this_) && sequence_nr > 0) + cmd = this_->GetUserCmd(sequence_nr); if (!cmd) return; @@ -436,22 +437,22 @@ DEFINE_HOOKED_METHOD(CreateMoveLate, void, void *this_, int sequence_nr, float i if (!isHackActive()) { - WriteCmd(g_IInput, current_late_user_cmd, sequence_nr); + WriteCmd(this_, current_late_user_cmd, sequence_nr); return; } if (!g_IEngine->IsInGame()) { - WriteCmd(g_IInput, current_late_user_cmd, sequence_nr); + WriteCmd(this_, current_late_user_cmd, sequence_nr); return; } - PROF_SECTION(CreateMoveLate); + PROF_SECTION(CreateMoveEarly); // Run EC - EC::run(EC::CreateMoveLate); + EC::run(EC::CreateMoveEarly); // Write the usercmd - WriteCmd(g_IInput, current_late_user_cmd, sequence_nr); + WriteCmd(this_, current_late_user_cmd, sequence_nr); } } // namespace hooked_methods