From a755327517b1a63246123c8bca14664253c525c0 Mon Sep 17 00:00:00 2001 From: Stephen Date: Sat, 7 Jan 2023 17:19:14 -0500 Subject: [PATCH] Player Anim Fix --- src/hooks/PlayerAnimFix.cpp | 45 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/hooks/PlayerAnimFix.cpp b/src/hooks/PlayerAnimFix.cpp index 876f9009..ec52304f 100644 --- a/src/hooks/PlayerAnimFix.cpp +++ b/src/hooks/PlayerAnimFix.cpp @@ -50,10 +50,10 @@ bool ShouldInterpolate_hook(IClientEntity *ent) if (ent && IDX_GOOD(ent->entindex())) { CachedEntity *cent = ENTITY(ent->entindex()); - if (cent->m_Type() == ENTITY_PLAYER && cent->m_IDX != g_pLocalPlayer->entity_idx) - { + if (CE_BAD(cent)) + return false; + if (cent->m_Type() == ENTITY_PLAYER && cent->m_IDX != g_pLocalPlayer->entity_idx) return false; - } } } ShouldInterpolate_t original = (ShouldInterpolate_t) shouldinterpolate_detour.GetOriginalFunc(); @@ -87,25 +87,28 @@ void LevelInit() previous_simtimes.resize(g_IEngine->GetMaxClients()); } -static InitRoutine init([]() { - static auto ShouldInterpolate_signature = CSignature::GetClientSignature("55 89 E5 56 53 83 EC 10 A1 ? ? ? ? 8B 5D ? 8B 10 89 04 24 FF 52 ? 8B 53"); - shouldinterpolate_detour.Init(ShouldInterpolate_signature, (void *) ShouldInterpolate_hook); +static InitRoutine init( + []() + { + static auto ShouldInterpolate_signature = CSignature::GetClientSignature("55 89 E5 56 53 83 EC 10 A1 ? ? ? ? 8B 5D ? 8B 10 89 04 24 FF 52 ? 8B 53"); + shouldinterpolate_detour.Init(ShouldInterpolate_signature, (void *) ShouldInterpolate_hook); - /*static auto CheckForSequenceChange_signature = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 1C 8B 45 ? 8B 75 ? 8B 4D ? 8B 7D"); - checkforsequencechange_detour.Init(CheckForSequenceChange_signature, (void *) CheckForSequenceChange_hook);*/ + /*static auto CheckForSequenceChange_signature = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 1C 8B 45 ? 8B 75 ? 8B 4D ? 8B 7D"); + checkforsequencechange_detour.Init(CheckForSequenceChange_signature, (void *) CheckForSequenceChange_hook);*/ - static auto FrameAdvance_signature = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 4C 8B 5D ? 80 BB ? ? ? ? 00 0F 85 ? ? ? ? 8B B3"); - frameadvance_detour.Init(FrameAdvance_signature, (void *) FrameAdvance_hook); - EC::Register(EC::LevelInit, LevelInit, "levelinit_animfix"); - LevelInit(); + static auto FrameAdvance_signature = gSignatures.GetClientSignature("55 89 E5 57 56 53 83 EC 4C 8B 5D ? 80 BB ? ? ? ? 00 0F 85 ? ? ? ? 8B B3"); + frameadvance_detour.Init(FrameAdvance_signature, (void *) FrameAdvance_hook); + EC::Register(EC::LevelInit, LevelInit, "levelinit_animfix"); + LevelInit(); - EC::Register( - EC::Shutdown, - []() { - frameadvance_detour.Shutdown(); - // checkforsequencechange_detour.Shutdown(); - frameadvance_detour.Shutdown(); - }, - "shutdown_animfix"); -}); + EC::Register( + EC::Shutdown, + []() + { + frameadvance_detour.Shutdown(); + // checkforsequencechange_detour.Shutdown(); + frameadvance_detour.Shutdown(); + }, + "shutdown_animfix"); + }); } // namespace hacks::tf2::animfix