Skip to content

Commit

Permalink
Improved AddVar/EstimateAbsVelocity hook code consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
lnx00 committed Jan 4, 2024
1 parent 571c55c commit 7a6edee
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions SEOwnedDE/SEOwnedDE/src/App/Hooks/C_BaseEntity_AddVar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

MAKE_HOOK(
C_BaseEntity_AddVar, Signatures::C_BaseEntity_AddVar.Get(),
void, __fastcall, void *ecx, void *edx, void *data, IInterpolatedVar *watcher, int type, bool bSetup)
void, __fastcall, C_BaseEntity* ecx, void* edx, void* data, IInterpolatedVar* watcher, int type, bool bSetup)
{
if (CFG::Misc_Accuracy_Improvements && watcher)
{
auto hash = HASH_RT(watcher->GetDebugName());
const auto hash = HASH_RT(watcher->GetDebugName());

static const auto m_iv_vecVelocity = HASH_CT("C_BaseEntity::m_iv_vecVelocity");
static const auto m_iv_angEyeAngles = HASH_CT("C_TFPlayer::m_iv_angEyeAngles");
static const auto m_iv_flPoseParameter = HASH_CT("C_BaseAnimating::m_iv_flPoseParameter");
static const auto m_iv_flCycle = HASH_CT("C_BaseAnimating::m_iv_flCycle");
static const auto m_iv_flMaxGroundSpeed = HASH_CT("CMultiPlayerAnimState::m_iv_flMaxGroundSpeed");
static constexpr auto m_iv_vecVelocity = HASH_CT("C_BaseEntity::m_iv_vecVelocity");
static constexpr auto m_iv_angEyeAngles = HASH_CT("C_TFPlayer::m_iv_angEyeAngles");
static constexpr auto m_iv_flPoseParameter = HASH_CT("C_BaseAnimating::m_iv_flPoseParameter");
static constexpr auto m_iv_flCycle = HASH_CT("C_BaseAnimating::m_iv_flCycle");
static constexpr auto m_iv_flMaxGroundSpeed = HASH_CT("CMultiPlayerAnimState::m_iv_flMaxGroundSpeed");

if (hash == m_iv_vecVelocity
|| hash == m_iv_flPoseParameter
Expand All @@ -34,21 +34,19 @@ MAKE_HOOK(

MAKE_HOOK(
C_BaseEntity_EstimateAbsVelocity, Signatures::C_BaseEntity_EstimateAbsVelocity.Get(),
void, __fastcall, void *ecx, void *edx, Vector &vel)
void, __fastcall, C_BaseEntity* ecx, void* edx, Vector& vel)
{
if (CFG::Misc_Accuracy_Improvements)
if (CFG::Misc_Accuracy_Improvements && ecx)
{
if (auto pEntity = reinterpret_cast<C_BaseEntity *>(ecx))
if (ecx->GetClassId() == ETFClassIds::CTFPlayer)
{
if (pEntity->GetClassId() == ETFClassIds::CTFPlayer)
if (const auto pPlayer = ecx->As<C_TFPlayer>())
{
if (auto pPlayer = pEntity->As<C_TFPlayer>()) {
vel = pPlayer->m_vecVelocity();
return;
}
vel = pPlayer->m_vecVelocity();
return;
}
}
}

CALL_ORIGINAL(ecx, edx, vel);
}
}

0 comments on commit 7a6edee

Please sign in to comment.