fix a couple oversights

This commit is contained in:
rei-2
2024-12-13 22:35:05 -05:00
parent 578a97847d
commit 1f5c90ac68
5 changed files with 39 additions and 46 deletions
@@ -96,7 +96,6 @@ bool CAutoDetonate::CheckDetonation(CTFPlayer* pLocal, EGroupType entityGroup, f
return false;
float flLatency = std::max(F::Backtrack.GetReal() - 0.05f, 0.f);
PredictPlayers(pLocal, flLatency);
for (auto pProjectile : vProjectiles)
{
@@ -137,14 +136,13 @@ bool CAutoDetonate::CheckDetonation(CTFPlayer* pLocal, EGroupType entityGroup, f
flRadius = SDK::AttribHookValue(flRadius, "mult_explosion_radius", pWeapon);
Vec3 vOrigin = PredictOrigin(pProjectile->m_vecOrigin(), pProjectile->GetAbsVelocity(), flLatency);
PredictPlayers(pLocal, flLatency);
bool bCheck = CheckEntities(pLocal, pWeapon, nullptr, pProjectile, flRadius, vOrigin);
RestorePlayers();
bCheck = bCheck && CheckEntities(pLocal, pWeapon, pCmd, pProjectile, flRadius, pProjectile->m_vecOrigin());
if (bCheck)
if (bCheck && CheckEntities(pLocal, pWeapon, pCmd, pProjectile, flRadius, pProjectile->m_vecOrigin()))
return true;
}
RestorePlayers();
return false;
}
+7 -10
View File
@@ -260,18 +260,15 @@ bool CCritHack::WeaponCanCrit(CTFWeaponBase* pWeapon, bool bWeaponOnly)
void CCritHack::ResetWeapons(CTFPlayer* pLocal)
{
std::unordered_map<int, bool> mWeapons = {};
auto hWeapons = pLocal->GetMyWeapons();
if (!hWeapons)
if (!pLocal->m_hMyWeapons())
return;
for (size_t i = 0; hWeapons[i]; i++)
{
auto pWeapon = pLocal->GetWeaponFromSlot(int(i));
if (!pWeapon)
break;
std::unordered_map<int, bool> mWeapons = {};
if (!WeaponCanCrit(pWeapon))
for (int i = 0; i < MAX_WEAPONS; i++)
{
auto pWeapon = pLocal->GetWeaponFromSlot(i);
if (!pWeapon || !WeaponCanCrit(pWeapon))
continue;
int iSlot = pWeapon->GetSlot();
@@ -291,7 +288,7 @@ void CCritHack::ResetWeapons(CTFPlayer* pLocal)
for (auto& [iSlot, _] : m_mStorage)
{
if (m_mStorage.contains(iSlot) && !mWeapons[iSlot])
if (m_mStorage.contains(iSlot) && !mWeapons.contains(iSlot))
m_mStorage.erase(iSlot);
}
}
+18 -22
View File
@@ -36,33 +36,31 @@ MAKE_HOOK(CL_ProcessPacketEntities, S::CL_ProcessPacketEntities(), bool,
CTFPlayer* pLocal = I::ClientEntityList->GetClientEntity(I::EngineClient->GetLocalPlayer())->As<CTFPlayer>();
if (!pLocal)
{
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (1)", { 255, 100, 100, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (1)", { 255, 100, 100, 255 });
return CALL_ORIGINAL(entmsg);
}
auto hWeapons = pLocal->GetMyWeapons();
if (!hWeapons)
if (!pLocal->m_hMyWeapons())
{
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (2)", { 255, 100, 100, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (2)", { 255, 100, 100, 255 });
return CALL_ORIGINAL(entmsg);
}
std::unordered_map<int, CriticalStorage_t> mCriticalStorage = {};
for (size_t i = 0; hWeapons[i]; i++)
{
auto pWeapon = pLocal->GetWeaponFromSlot(int(i));
if (!pWeapon)
break;
const int iSlot = pWeapon->GetSlot();
mCriticalStorage[iSlot].m_flCritTokenBucket = pWeapon->m_flCritTokenBucket();
mCriticalStorage[iSlot].m_nCritChecks = pWeapon->m_nCritChecks();
mCriticalStorage[iSlot].m_nCritSeedRequests = pWeapon->m_nCritSeedRequests();
for (int i = 0; i < MAX_WEAPONS; i++)
{
auto pWeapon = pLocal->GetWeaponFromSlot(i);
if (!pWeapon)
continue;
mCriticalStorage[i].m_flCritTokenBucket = pWeapon->m_flCritTokenBucket();
mCriticalStorage[i].m_nCritChecks = pWeapon->m_nCritChecks();
mCriticalStorage[i].m_nCritSeedRequests = pWeapon->m_nCritSeedRequests();
if (Vars::Debug::Logging.Value) I::CVar->ConsolePrintf("\n");
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[iSlot].m_flCritTokenBucket = {}", iSlot, uintptr_t(pWeapon), pWeapon->m_flCritTokenBucket()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[iSlot].m_nCritChecks = {}", iSlot, uintptr_t(pWeapon), pWeapon->m_nCritChecks()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[iSlot].m_nCritSeedRequests = {}", iSlot, uintptr_t(pWeapon), pWeapon->m_nCritSeedRequests()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[i].m_flCritTokenBucket = {}", i, uintptr_t(pWeapon), pWeapon->m_flCritTokenBucket()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[i].m_nCritChecks = {}", i, uintptr_t(pWeapon), pWeapon->m_nCritChecks()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", std::format("{} ({:#x}): mCriticalStorage[i].m_nCritSeedRequests = {}", i, uintptr_t(pWeapon), pWeapon->m_nCritSeedRequests()).c_str(), { 100, 150, 255, 255 }, Vars::Debug::Logging.Value);
}
bool bReturn = CALL_ORIGINAL(entmsg);
@@ -70,14 +68,12 @@ MAKE_HOOK(CL_ProcessPacketEntities, S::CL_ProcessPacketEntities(), bool,
pLocal = I::ClientEntityList->GetClientEntity(I::EngineClient->GetLocalPlayer())->As<CTFPlayer>();
if (!pLocal)
{
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (3)", { 255, 100, 100, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (3)", { 255, 100, 100, 255 });
return bReturn;
}
hWeapons = pLocal->GetMyWeapons();
if (!hWeapons)
if (!pLocal->m_hMyWeapons())
{
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (4)", { 255, 100, 100, 255 }, Vars::Debug::Logging.Value);
SDK::Output("ProcessPacketEntities", "Failed to restore weapon crit data! (4)", { 255, 100, 100, 255 });
return bReturn;
}
@@ -1,17 +1,26 @@
#pragma once
#include "CBaseFlex.h"
class CTFWeaponBase;
class CBaseCombatCharacter : public CBaseFlex
{
public:
NETVAR(m_flNextAttack, float, "CBaseCombatCharacter", "m_flNextAttack");
NETVAR(m_hActiveWeapon, EHANDLE, "CBaseCombatCharacter", "m_hActiveWeapon");
NETVAR(m_hMyWeapons, EHANDLE, "CBaseCombatCharacter", "m_hMyWeapons");
//NETVAR(m_hMyWeapons, EHANDLE, "CBaseCombatCharacter", "m_hMyWeapons");
NETVAR(m_bGlowEnabled, bool, "CBaseCombatCharacter", "m_bGlowEnabled");
inline size_t* GetMyWeapons()
inline CHandle<CTFWeaponBase>(&m_hMyWeapons())[MAX_WEAPONS]
{
static int nOffset = U::NetVars.GetNetVar("CBaseCombatCharacter", "m_hMyWeapons");
return reinterpret_cast<size_t*>(uintptr_t(this) + nOffset);
return *reinterpret_cast<CHandle<CTFWeaponBase>(*)[MAX_WEAPONS]>(uintptr_t(this) + nOffset);
}
inline CTFWeaponBase* GetWeaponFromSlot(int nSlot)
{
if (nSlot < 0 || nSlot >= MAX_WEAPONS)
return nullptr;
return m_hMyWeapons()[nSlot].Get();
}
};
@@ -427,13 +427,6 @@ public:
return true;
}
inline CTFWeaponBase* GetWeaponFromSlot(int nSlot)
{
static int nOffset = U::NetVars.GetNetVar("CBaseCombatCharacter", "m_hMyWeapons");
auto& hWeapon = *reinterpret_cast<EHANDLE*>(uintptr_t(this) + nOffset + nSlot * 4);
return hWeapon.Get()->As<CTFWeaponBase>();
}
inline float TeamFortress_CalculateMaxSpeed(bool bIgnoreSpecialAbility = false)
{
return S::TeamFortress_CalculateMaxSpeed.Call<float>(this, bIgnoreSpecialAbility);