mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 04:43:09 +08:00
utilize cpredictioncopy for restoring vars rather than hardcoded vars
This commit is contained in:
@@ -1259,6 +1259,7 @@
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IInput.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IKeyValuesSystem.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\ILocalize.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IMemAlloc.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IPanel.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IStudioRender.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IUniformRandomStream.h" />
|
||||
@@ -1277,6 +1278,7 @@
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CModel.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IEngineTrace.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CParticleProperty.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CPredictionCopy.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Misc\CRangeCheckedVar.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CSniperDot.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\IAchievementMgr.h" />
|
||||
|
||||
@@ -582,6 +582,8 @@
|
||||
<ClInclude Include="src\Features\Visuals\Groups\Groups.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IFileSystem.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\ILocalize.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Interfaces\IMemAlloc.h" />
|
||||
<ClInclude Include="src\SDK\Definitions\Main\CPredictionCopy.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "../SDK/SDK.h"
|
||||
#include "../BytePatches/BytePatches.h"
|
||||
#include "../Features/Visuals/Materials/Materials.h"
|
||||
#include "../Features/Configs/Configs.h"
|
||||
#include "../Features/Commands/Commands.h"
|
||||
#include "../Features/ImGui/Menu/Menu.h"
|
||||
#include "../Features/EnginePrediction/EnginePrediction.h"
|
||||
#include "../Features/Visuals/Materials/Materials.h"
|
||||
#include "../Features/Visuals/Visuals.h"
|
||||
#include "../SDK/Events/Events.h"
|
||||
#include <Psapi.h>
|
||||
@@ -141,6 +141,7 @@ void CCore::Unload()
|
||||
U::ConVars.FindVar("cl_wpn_sway_scale")->SetValue(0.f);
|
||||
|
||||
Sleep(250);
|
||||
F::EnginePrediction.Unload();
|
||||
U::ConVars.Unload();
|
||||
F::Materials.UnloadMaterials();
|
||||
|
||||
|
||||
@@ -327,7 +327,7 @@ int CAimbotHitscan::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase*
|
||||
tTarget.m_vPos = tTarget.m_pEntity->m_vecOrigin();
|
||||
|
||||
// not lag compensated (i assume) so run movesim based on ping
|
||||
PlayerStorage tStorage;
|
||||
MoveStorage tStorage;
|
||||
F::MoveSim.Initialize(tTarget.m_pEntity, tStorage);
|
||||
if (!tStorage.m_bFailed)
|
||||
{
|
||||
|
||||
@@ -148,24 +148,24 @@ void CAimbotMelee::UpdateInfo(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCm
|
||||
|
||||
int iSimTicks = GetSwingTime(pWeapon), iSwingTicks = GetSwingTime(pWeapon, false);
|
||||
|
||||
if ((Vars::Aimbot::Melee::SwingPrediction.Value || m_iDoubletapTicks) && G::CanPrimaryAttack && pWeapon->m_flSmackTime() < 0.f)
|
||||
if ((Vars::Aimbot::Melee::SwingPrediction.Value && iSimTicks || m_iDoubletapTicks) && G::CanPrimaryAttack && pWeapon->m_flSmackTime() < 0.f)
|
||||
{
|
||||
std::unordered_map<int, PlayerStorage> mStorage;
|
||||
std::unordered_map<int, MoveStorage> mStorage;
|
||||
|
||||
F::MoveSim.Initialize(pLocal, mStorage[I::EngineClient->GetLocalPlayer()], false, !m_iDoubletapTicks);
|
||||
for (auto& tTarget : vTargets)
|
||||
F::MoveSim.Initialize(tTarget.m_pEntity, mStorage[tTarget.m_pEntity->entindex()], false);
|
||||
|
||||
int iMax = std::max(iSimTicks, m_iDoubletapTicks);
|
||||
int iLocal = iMax; bool bSwung = false;
|
||||
for (int i = 0; i < iLocal; i++) // intended for plocal to collide with targets
|
||||
int iTicks = iMax; bool bSwung = false;
|
||||
for (int i = 0; i < iTicks; i++) // intended for plocal to collide with targets
|
||||
{
|
||||
{
|
||||
auto& tStorage = mStorage[I::EngineClient->GetLocalPlayer()];
|
||||
|
||||
if (!bSwung && (!m_iDoubletapTicks || Vars::Doubletap::AntiWarp.Value && pLocal->m_hGroundEntity() || iMax - i <= iSwingTicks))
|
||||
{
|
||||
iLocal = std::min(i + iSwingTicks, iMax), bSwung = true;
|
||||
iTicks = std::min(i + iSwingTicks, iMax), bSwung = true;
|
||||
if (!iSwingTicks)
|
||||
break;
|
||||
|
||||
@@ -233,7 +233,7 @@ void CAimbotMelee::UpdateInfo(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCm
|
||||
F::MoveSim.Restore(tStorage);
|
||||
}
|
||||
|
||||
m_bShouldSwing = m_iDoubletapTicks <= (iSwingTicks) || Vars::Doubletap::AntiWarp.Value && pLocal->m_hGroundEntity();
|
||||
m_bShouldSwing = m_iDoubletapTicks <= iSwingTicks || Vars::Doubletap::AntiWarp.Value && pLocal->m_hGroundEntity();
|
||||
}
|
||||
|
||||
bool CAimbotMelee::CanBackstab(CBaseEntity* pTarget, CTFPlayer* pLocal, Vec3 vEyeAngles)
|
||||
@@ -395,7 +395,7 @@ int CAimbotMelee::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* pW
|
||||
|
||||
if (bReturn && Vars::Aimbot::Melee::AutoBackstab.Value && pWeapon->GetWeaponID() == TF_WEAPON_KNIFE)
|
||||
bReturn = CanBackstab(tTarget.m_pEntity, pLocal, tTarget.m_vAngleTo);
|
||||
|
||||
|
||||
tTarget.m_pEntity->SetAbsOrigin(vRestoreOrigin);
|
||||
tTarget.m_pEntity->m_vecMins() = vRestoreMins;
|
||||
tTarget.m_pEntity->m_vecMaxs() = vRestoreMaxs;
|
||||
@@ -414,10 +414,10 @@ int CAimbotMelee::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBase* pW
|
||||
{
|
||||
auto vAngle = Math::CalcAngle(m_vEyePos, tTarget.m_vPos);
|
||||
|
||||
Vec3 vForward = Vec3(); Math::AngleVectors(vAngle, &vForward);
|
||||
Vec3 vTraceEnd = m_vEyePos + (vForward * flRange);
|
||||
Math::AngleVectors(vAngle, &vForward);
|
||||
vTraceEnd = m_vEyePos + (vForward * flRange);
|
||||
|
||||
SDK::Trace(m_vEyePos, vTraceEnd, MASK_SHOT | CONTENTS_GRATE, &filter, &trace);
|
||||
SDK::TraceHull(m_vEyePos, vTraceEnd, vSwingMins, vSwingMaxs, MASK_SOLID, &filter, &trace);
|
||||
if (trace.m_pEnt && trace.m_pEnt == tTarget.m_pEntity)
|
||||
return 2;
|
||||
}
|
||||
|
||||
@@ -1365,7 +1365,7 @@ int CAimbotProjectile::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBas
|
||||
|| !F::ProjSim.Initialize(tProjInfo, false))
|
||||
return false;
|
||||
|
||||
PlayerStorage tStorage;
|
||||
MoveStorage tStorage;
|
||||
F::MoveSim.Initialize(tTarget.m_pEntity, tStorage);
|
||||
tTarget.m_vPos = tTarget.m_pEntity->m_vecOrigin();
|
||||
|
||||
@@ -2050,7 +2050,7 @@ bool CAimbotProjectile::CanHit(Target_t& tTarget, CTFPlayer* pLocal, CTFWeaponBa
|
||||
if (!F::ProjSim.Initialize(tProjInfo, false, true))
|
||||
return false;
|
||||
|
||||
PlayerStorage tStorage;
|
||||
MoveStorage tStorage;
|
||||
F::MoveSim.Initialize(tTarget.m_pEntity, tStorage);
|
||||
tTarget.m_vPos = tTarget.m_pEntity->m_vecOrigin();
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ bool CAutoRocketJump::SetAngles(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUser
|
||||
//float flOffset = pLocal->m_vecMaxs().x;
|
||||
float flOffset = sqrtf(2 * powf(vOffset.y, 2.f) + powf(vOffset.z, 2.f));
|
||||
bool bShouldReturn = true;
|
||||
PlayerStorage tStorage;
|
||||
MoveStorage tStorage;
|
||||
if (F::MoveSim.Initialize(pLocal, tStorage, false))
|
||||
{
|
||||
for (int n = 1; n < 10; n++)
|
||||
@@ -143,7 +143,7 @@ void CAutoRocketJump::Run(CTFPlayer* pLocal, CTFWeaponBase* pWeapon, CUserCmd* p
|
||||
bool bWillHit = false;
|
||||
if (Vars::Misc::Movement::AutoRocketJump.Value || Vars::Misc::Movement::AutoCTap.Value)
|
||||
{
|
||||
PlayerStorage tStorage;
|
||||
MoveStorage tStorage;
|
||||
ProjectileInfo tProjInfo = {};
|
||||
|
||||
bool bProjSimSetup = F::ProjSim.GetInfo(pLocal, pWeapon, m_vAngles, tProjInfo, ProjSimEnum::Trace | ProjSimEnum::InitCheck | ProjSimEnum::NoRandomAngles) && F::ProjSim.Initialize(tProjInfo);
|
||||
|
||||
@@ -72,6 +72,10 @@ void CEnginePrediction::Start(CTFPlayer* pLocal, CUserCmd* pCmd)
|
||||
if (!pLocal->IsAlive())
|
||||
return;
|
||||
|
||||
auto pMap = pLocal->GetPredDescMap();
|
||||
if (!pMap)
|
||||
return;
|
||||
|
||||
m_nOldTickCount = I::GlobalVars->tickcount;
|
||||
m_flOldCurrentTime = I::GlobalVars->curtime;
|
||||
m_flOldFrameTime = I::GlobalVars->frametime;
|
||||
@@ -80,8 +84,20 @@ void CEnginePrediction::Start(CTFPlayer* pLocal, CUserCmd* pCmd)
|
||||
I::GlobalVars->curtime = TICKS_TO_TIME(I::GlobalVars->tickcount);
|
||||
I::GlobalVars->frametime = I::Prediction->m_bEnginePaused ? 0.f : TICK_INTERVAL;
|
||||
|
||||
m_vOldOrigin = pLocal->m_vecOrigin();
|
||||
m_vOldVelocity = pLocal->m_vecVelocity();
|
||||
size_t iSize = pLocal->GetIntermediateDataSize();
|
||||
if (!m_tLocal.m_pData)
|
||||
{
|
||||
m_tLocal.m_pData = reinterpret_cast<byte*>(I::MemAlloc->Alloc(iSize));
|
||||
m_tLocal.m_iSize = iSize;
|
||||
}
|
||||
else if (m_tLocal.m_iSize != iSize)
|
||||
{
|
||||
m_tLocal.m_pData = reinterpret_cast<byte*>(I::MemAlloc->Realloc(m_tLocal.m_pData, iSize));
|
||||
m_tLocal.m_iSize = iSize;
|
||||
}
|
||||
|
||||
CPredictionCopy copy = { PC_EVERYTHING, m_tLocal.m_pData, PC_DATA_PACKED, pLocal, PC_DATA_NORMAL };
|
||||
copy.TransferData("EnginePredictionStart", pLocal->entindex(), pMap);
|
||||
|
||||
Simulate(pLocal, pCmd);
|
||||
}
|
||||
@@ -92,10 +108,23 @@ void CEnginePrediction::End(CTFPlayer* pLocal, CUserCmd* pCmd)
|
||||
if (!pLocal->IsAlive())
|
||||
return;
|
||||
|
||||
auto pMap = pLocal->GetPredDescMap();
|
||||
if (!pMap)
|
||||
return;
|
||||
|
||||
I::GlobalVars->tickcount = m_nOldTickCount;
|
||||
I::GlobalVars->curtime = m_flOldCurrentTime;
|
||||
I::GlobalVars->frametime = m_flOldFrameTime;
|
||||
|
||||
pLocal->SetAbsOrigin(pLocal->m_vecOrigin() = m_vOldOrigin);
|
||||
pLocal->SetAbsVelocity(pLocal->m_vecVelocity() = m_vOldVelocity);
|
||||
CPredictionCopy copy = { PC_EVERYTHING, pLocal, PC_DATA_NORMAL, m_tLocal.m_pData, PC_DATA_PACKED };
|
||||
copy.TransferData("EnginePredictionEnd", pLocal->entindex(), pMap);
|
||||
}
|
||||
|
||||
void CEnginePrediction::Unload()
|
||||
{
|
||||
if (m_tLocal.m_pData)
|
||||
{
|
||||
I::MemAlloc->Free(m_tLocal.m_pData);
|
||||
m_tLocal = {};
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
#pragma once
|
||||
#include "../../SDK/SDK.h"
|
||||
|
||||
struct DatamapRestore_t
|
||||
{
|
||||
byte* m_pData = nullptr;
|
||||
size_t m_iSize = 0;
|
||||
};
|
||||
|
||||
struct RestoreInfo_t
|
||||
{
|
||||
Vec3 m_vOrigin = {};
|
||||
@@ -19,8 +25,7 @@ private:
|
||||
float m_flOldCurrentTime = 0.f;
|
||||
float m_flOldFrameTime = 0.f;
|
||||
|
||||
Vec3 m_vOldOrigin = {};
|
||||
Vec3 m_vOldVelocity = {};
|
||||
DatamapRestore_t m_tLocal = {};
|
||||
|
||||
std::unordered_map<CTFPlayer*, RestoreInfo_t> m_mRestore = {};
|
||||
|
||||
@@ -28,6 +33,8 @@ public:
|
||||
void Start(CTFPlayer* pLocal, CUserCmd* pCmd);
|
||||
void End(CTFPlayer* pLocal, CUserCmd* pCmd);
|
||||
|
||||
void Unload();
|
||||
|
||||
void AdjustPlayers(CBaseEntity* pLocal);
|
||||
void RestorePlayers();
|
||||
|
||||
|
||||
@@ -5,106 +5,33 @@
|
||||
|
||||
static CUserCmd s_tDummyCmd = {};
|
||||
|
||||
void CMovementSimulation::Store(PlayerStorage& tStorage)
|
||||
void CMovementSimulation::Store(MoveStorage& tStorage)
|
||||
{
|
||||
tStorage.m_PlayerData.m_vecOrigin = tStorage.m_pPlayer->m_vecOrigin();
|
||||
tStorage.m_PlayerData.m_vecVelocity = tStorage.m_pPlayer->m_vecVelocity();
|
||||
tStorage.m_PlayerData.m_vecBaseVelocity = tStorage.m_pPlayer->m_vecBaseVelocity();
|
||||
tStorage.m_PlayerData.m_vecViewOffset = tStorage.m_pPlayer->m_vecViewOffset();
|
||||
tStorage.m_PlayerData.m_hGroundEntity = tStorage.m_pPlayer->m_hGroundEntity();
|
||||
tStorage.m_PlayerData.m_fFlags = tStorage.m_pPlayer->m_fFlags();
|
||||
tStorage.m_PlayerData.m_flDucktime = tStorage.m_pPlayer->m_flDucktime();
|
||||
tStorage.m_PlayerData.m_flDuckJumpTime = tStorage.m_pPlayer->m_flDuckJumpTime();
|
||||
tStorage.m_PlayerData.m_bDucked = tStorage.m_pPlayer->m_bDucked();
|
||||
tStorage.m_PlayerData.m_bDucking = tStorage.m_pPlayer->m_bDucking();
|
||||
tStorage.m_PlayerData.m_bInDuckJump = tStorage.m_pPlayer->m_bInDuckJump();
|
||||
tStorage.m_PlayerData.m_flModelScale = tStorage.m_pPlayer->m_flModelScale();
|
||||
tStorage.m_PlayerData.m_nButtons = tStorage.m_pPlayer->m_nButtons();
|
||||
tStorage.m_PlayerData.m_flLastMovementStunChange = tStorage.m_pPlayer->m_flLastMovementStunChange();
|
||||
tStorage.m_PlayerData.m_flStunLerpTarget = tStorage.m_pPlayer->m_flStunLerpTarget();
|
||||
tStorage.m_PlayerData.m_bStunNeedsFadeOut = tStorage.m_pPlayer->m_bStunNeedsFadeOut();
|
||||
tStorage.m_PlayerData.m_flPrevTauntYaw = tStorage.m_pPlayer->m_flPrevTauntYaw();
|
||||
tStorage.m_PlayerData.m_flTauntYaw = tStorage.m_pPlayer->m_flTauntYaw();
|
||||
tStorage.m_PlayerData.m_flCurrentTauntMoveSpeed = tStorage.m_pPlayer->m_flCurrentTauntMoveSpeed();
|
||||
tStorage.m_PlayerData.m_iKartState = tStorage.m_pPlayer->m_iKartState();
|
||||
tStorage.m_PlayerData.m_flVehicleReverseTime = tStorage.m_pPlayer->m_flVehicleReverseTime();
|
||||
tStorage.m_PlayerData.m_flHypeMeter = tStorage.m_pPlayer->m_flHypeMeter();
|
||||
tStorage.m_PlayerData.m_flMaxspeed = tStorage.m_pPlayer->m_flMaxspeed();
|
||||
tStorage.m_PlayerData.m_nAirDucked = tStorage.m_pPlayer->m_nAirDucked();
|
||||
tStorage.m_PlayerData.m_bJumping = tStorage.m_pPlayer->m_bJumping();
|
||||
tStorage.m_PlayerData.m_iAirDash = tStorage.m_pPlayer->m_iAirDash();
|
||||
tStorage.m_PlayerData.m_flWaterJumpTime = tStorage.m_pPlayer->m_flWaterJumpTime();
|
||||
tStorage.m_PlayerData.m_flSwimSoundTime = tStorage.m_pPlayer->m_flSwimSoundTime();
|
||||
tStorage.m_PlayerData.m_surfaceProps = tStorage.m_pPlayer->m_surfaceProps();
|
||||
tStorage.m_PlayerData.m_pSurfaceData = tStorage.m_pPlayer->m_pSurfaceData();
|
||||
tStorage.m_PlayerData.m_surfaceFriction = tStorage.m_pPlayer->m_surfaceFriction();
|
||||
tStorage.m_PlayerData.m_chTextureType = tStorage.m_pPlayer->m_chTextureType();
|
||||
tStorage.m_PlayerData.m_vecPunchAngle = tStorage.m_pPlayer->m_vecPunchAngle();
|
||||
tStorage.m_PlayerData.m_vecPunchAngleVel = tStorage.m_pPlayer->m_vecPunchAngleVel();
|
||||
tStorage.m_PlayerData.m_MoveType = tStorage.m_pPlayer->m_MoveType();
|
||||
tStorage.m_PlayerData.m_MoveCollide = tStorage.m_pPlayer->m_MoveCollide();
|
||||
tStorage.m_PlayerData.m_vecLadderNormal = tStorage.m_pPlayer->m_vecLadderNormal();
|
||||
tStorage.m_PlayerData.m_flGravity = tStorage.m_pPlayer->m_flGravity();
|
||||
tStorage.m_PlayerData.m_nWaterLevel = tStorage.m_pPlayer->m_nWaterLevel();
|
||||
tStorage.m_PlayerData.m_nWaterType = tStorage.m_pPlayer->m_nWaterType();
|
||||
tStorage.m_PlayerData.m_flFallVelocity = tStorage.m_pPlayer->m_flFallVelocity();
|
||||
tStorage.m_PlayerData.m_nPlayerCond = tStorage.m_pPlayer->m_nPlayerCond();
|
||||
tStorage.m_PlayerData.m_nPlayerCondEx = tStorage.m_pPlayer->m_nPlayerCondEx();
|
||||
tStorage.m_PlayerData.m_nPlayerCondEx2 = tStorage.m_pPlayer->m_nPlayerCondEx2();
|
||||
tStorage.m_PlayerData.m_nPlayerCondEx3 = tStorage.m_pPlayer->m_nPlayerCondEx3();
|
||||
tStorage.m_PlayerData.m_nPlayerCondEx4 = tStorage.m_pPlayer->m_nPlayerCondEx4();
|
||||
tStorage.m_PlayerData._condition_bits = tStorage.m_pPlayer->_condition_bits();
|
||||
auto pMap = tStorage.m_pPlayer->GetPredDescMap();
|
||||
if (!pMap)
|
||||
return;
|
||||
|
||||
size_t iSize = tStorage.m_pPlayer->GetIntermediateDataSize();
|
||||
tStorage.m_pData = reinterpret_cast<byte*>(I::MemAlloc->Alloc(iSize));
|
||||
|
||||
CPredictionCopy copy = { PC_NETWORKED_ONLY, tStorage.m_pData, PC_DATA_PACKED, tStorage.m_pPlayer, PC_DATA_NORMAL };
|
||||
copy.TransferData("MovementSimulationStore", tStorage.m_pPlayer->entindex(), pMap);
|
||||
}
|
||||
|
||||
void CMovementSimulation::Reset(PlayerStorage& tStorage)
|
||||
void CMovementSimulation::Reset(MoveStorage& tStorage)
|
||||
{
|
||||
tStorage.m_pPlayer->m_vecOrigin() = tStorage.m_PlayerData.m_vecOrigin;
|
||||
tStorage.m_pPlayer->m_vecVelocity() = tStorage.m_PlayerData.m_vecVelocity;
|
||||
tStorage.m_pPlayer->m_vecBaseVelocity() = tStorage.m_PlayerData.m_vecBaseVelocity;
|
||||
tStorage.m_pPlayer->m_vecViewOffset() = tStorage.m_PlayerData.m_vecViewOffset;
|
||||
tStorage.m_pPlayer->m_hGroundEntity() = tStorage.m_PlayerData.m_hGroundEntity;
|
||||
tStorage.m_pPlayer->m_fFlags() = tStorage.m_PlayerData.m_fFlags;
|
||||
tStorage.m_pPlayer->m_flDucktime() = tStorage.m_PlayerData.m_flDucktime;
|
||||
tStorage.m_pPlayer->m_flDuckJumpTime() = tStorage.m_PlayerData.m_flDuckJumpTime;
|
||||
tStorage.m_pPlayer->m_bDucked() = tStorage.m_PlayerData.m_bDucked;
|
||||
tStorage.m_pPlayer->m_bDucking() = tStorage.m_PlayerData.m_bDucking;
|
||||
tStorage.m_pPlayer->m_bInDuckJump() = tStorage.m_PlayerData.m_bInDuckJump;
|
||||
tStorage.m_pPlayer->m_flModelScale() = tStorage.m_PlayerData.m_flModelScale;
|
||||
tStorage.m_pPlayer->m_nButtons() = tStorage.m_PlayerData.m_nButtons;
|
||||
tStorage.m_pPlayer->m_flLastMovementStunChange() = tStorage.m_PlayerData.m_flLastMovementStunChange;
|
||||
tStorage.m_pPlayer->m_flStunLerpTarget() = tStorage.m_PlayerData.m_flStunLerpTarget;
|
||||
tStorage.m_pPlayer->m_bStunNeedsFadeOut() = tStorage.m_PlayerData.m_bStunNeedsFadeOut;
|
||||
tStorage.m_pPlayer->m_flPrevTauntYaw() = tStorage.m_PlayerData.m_flPrevTauntYaw;
|
||||
tStorage.m_pPlayer->m_flTauntYaw() = tStorage.m_PlayerData.m_flTauntYaw;
|
||||
tStorage.m_pPlayer->m_flCurrentTauntMoveSpeed() = tStorage.m_PlayerData.m_flCurrentTauntMoveSpeed;
|
||||
tStorage.m_pPlayer->m_iKartState() = tStorage.m_PlayerData.m_iKartState;
|
||||
tStorage.m_pPlayer->m_flVehicleReverseTime() = tStorage.m_PlayerData.m_flVehicleReverseTime;
|
||||
tStorage.m_pPlayer->m_flHypeMeter() = tStorage.m_PlayerData.m_flHypeMeter;
|
||||
tStorage.m_pPlayer->m_flMaxspeed() = tStorage.m_PlayerData.m_flMaxspeed;
|
||||
tStorage.m_pPlayer->m_nAirDucked() = tStorage.m_PlayerData.m_nAirDucked;
|
||||
tStorage.m_pPlayer->m_bJumping() = tStorage.m_PlayerData.m_bJumping;
|
||||
tStorage.m_pPlayer->m_iAirDash() = tStorage.m_PlayerData.m_iAirDash;
|
||||
tStorage.m_pPlayer->m_flWaterJumpTime() = tStorage.m_PlayerData.m_flWaterJumpTime;
|
||||
tStorage.m_pPlayer->m_flSwimSoundTime() = tStorage.m_PlayerData.m_flSwimSoundTime;
|
||||
tStorage.m_pPlayer->m_surfaceProps() = tStorage.m_PlayerData.m_surfaceProps;
|
||||
tStorage.m_pPlayer->m_pSurfaceData() = tStorage.m_PlayerData.m_pSurfaceData;
|
||||
tStorage.m_pPlayer->m_surfaceFriction() = tStorage.m_PlayerData.m_surfaceFriction;
|
||||
tStorage.m_pPlayer->m_chTextureType() = tStorage.m_PlayerData.m_chTextureType;
|
||||
tStorage.m_pPlayer->m_vecPunchAngle() = tStorage.m_PlayerData.m_vecPunchAngle;
|
||||
tStorage.m_pPlayer->m_vecPunchAngleVel() = tStorage.m_PlayerData.m_vecPunchAngleVel;
|
||||
tStorage.m_pPlayer->m_MoveType() = tStorage.m_PlayerData.m_MoveType;
|
||||
tStorage.m_pPlayer->m_MoveCollide() = tStorage.m_PlayerData.m_MoveCollide;
|
||||
tStorage.m_pPlayer->m_vecLadderNormal() = tStorage.m_PlayerData.m_vecLadderNormal;
|
||||
tStorage.m_pPlayer->m_flGravity() = tStorage.m_PlayerData.m_flGravity;
|
||||
tStorage.m_pPlayer->m_nWaterLevel() = tStorage.m_PlayerData.m_nWaterLevel;
|
||||
tStorage.m_pPlayer->m_nWaterType() = tStorage.m_PlayerData.m_nWaterType;
|
||||
tStorage.m_pPlayer->m_flFallVelocity() = tStorage.m_PlayerData.m_flFallVelocity;
|
||||
tStorage.m_pPlayer->m_nPlayerCond() = tStorage.m_PlayerData.m_nPlayerCond;
|
||||
tStorage.m_pPlayer->m_nPlayerCondEx() = tStorage.m_PlayerData.m_nPlayerCondEx;
|
||||
tStorage.m_pPlayer->m_nPlayerCondEx2() = tStorage.m_PlayerData.m_nPlayerCondEx2;
|
||||
tStorage.m_pPlayer->m_nPlayerCondEx3() = tStorage.m_PlayerData.m_nPlayerCondEx3;
|
||||
tStorage.m_pPlayer->m_nPlayerCondEx4() = tStorage.m_PlayerData.m_nPlayerCondEx4;
|
||||
tStorage.m_pPlayer->_condition_bits() = tStorage.m_PlayerData._condition_bits;
|
||||
if (tStorage.m_pData)
|
||||
{
|
||||
auto pMap = tStorage.m_pPlayer->GetPredDescMap();
|
||||
if (!pMap)
|
||||
return;
|
||||
|
||||
CPredictionCopy copy = { PC_NETWORKED_ONLY, tStorage.m_pPlayer, PC_DATA_NORMAL, tStorage.m_pData, PC_DATA_PACKED };
|
||||
copy.TransferData("MovementSimulationReset", tStorage.m_pPlayer->entindex(), pMap);
|
||||
|
||||
I::MemAlloc->Free(tStorage.m_pData);
|
||||
tStorage.m_pData = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementSimulation::Store()
|
||||
@@ -203,7 +130,7 @@ void CMovementSimulation::Store()
|
||||
|
||||
|
||||
|
||||
bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& tStorage, bool bHitchance, bool bStrafe)
|
||||
bool CMovementSimulation::Initialize(CBaseEntity* pEntity, MoveStorage& tStorage, bool bHitchance, bool bStrafe)
|
||||
{
|
||||
if (!pEntity || !pEntity->IsPlayer() || !pEntity->As<CTFPlayer>()->IsAlive())
|
||||
{
|
||||
@@ -214,43 +141,41 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& tStora
|
||||
auto pPlayer = pEntity->As<CTFPlayer>();
|
||||
tStorage.m_pPlayer = pPlayer;
|
||||
|
||||
I::MoveHelper->SetHost(pPlayer);
|
||||
pPlayer->m_pCurrentCommand() = &s_tDummyCmd;
|
||||
|
||||
// store player restore data
|
||||
Store(tStorage);
|
||||
|
||||
// store vars
|
||||
m_bOldInPrediction = I::Prediction->m_bInPrediction;
|
||||
m_bOldFirstTimePredicted = I::Prediction->m_bFirstTimePredicted;
|
||||
m_flOldFrametime = I::GlobalVars->frametime;
|
||||
|
||||
// store restore data
|
||||
Store(tStorage);
|
||||
|
||||
// the hacks that make it work
|
||||
I::MoveHelper->SetHost(pPlayer);
|
||||
pPlayer->m_pCurrentCommand() = &s_tDummyCmd;
|
||||
|
||||
if (auto pAvgVelocity = H::Entities.GetAvgVelocity(pPlayer->entindex()))
|
||||
pPlayer->m_vecVelocity() = *pAvgVelocity; // only use average velocity here
|
||||
|
||||
if (pPlayer->m_bDucked() = pPlayer->IsDucking())
|
||||
{
|
||||
if (auto pAvgVelocity = H::Entities.GetAvgVelocity(pPlayer->entindex()))
|
||||
pPlayer->m_vecVelocity() = *pAvgVelocity; // only use average velocity here
|
||||
|
||||
if (pPlayer->m_bDucked() = pPlayer->IsDucking())
|
||||
{
|
||||
pPlayer->m_fFlags() &= ~FL_DUCKING; // breaks origin's z if FL_DUCKING is not removed
|
||||
pPlayer->m_flDucktime() = 0.f;
|
||||
pPlayer->m_flDuckJumpTime() = 0.f;
|
||||
pPlayer->m_bDucking() = false;
|
||||
pPlayer->m_bInDuckJump() = false;
|
||||
}
|
||||
|
||||
if (pPlayer != H::Entities.GetLocal())
|
||||
{
|
||||
pPlayer->m_vecBaseVelocity() = Vec3(); // residual basevelocity causes issues
|
||||
if (pPlayer->IsOnGround())
|
||||
pPlayer->m_vecVelocity().z = std::min(pPlayer->m_vecVelocity().z, 0.f); // step fix
|
||||
else
|
||||
pPlayer->m_hGroundEntity() = nullptr; // fix for velocity.z being set to 0 even if in air
|
||||
}
|
||||
else if (Vars::Misc::Movement::Bunnyhop.Value && G::OriginalCmd.buttons & IN_JUMP)
|
||||
tStorage.m_bBunnyHop = true;
|
||||
pPlayer->m_fFlags() &= ~FL_DUCKING; // breaks origin's z if FL_DUCKING is not removed
|
||||
pPlayer->m_flDucktime() = 0.f;
|
||||
pPlayer->m_flDuckJumpTime() = 0.f;
|
||||
pPlayer->m_bDucking() = false;
|
||||
pPlayer->m_bInDuckJump() = false;
|
||||
}
|
||||
|
||||
if (pPlayer != H::Entities.GetLocal())
|
||||
{
|
||||
pPlayer->m_vecBaseVelocity() = Vec3(); // residual basevelocity causes issues
|
||||
if (pPlayer->IsOnGround())
|
||||
pPlayer->m_vecVelocity().z = std::min(pPlayer->m_vecVelocity().z, 0.f); // step fix
|
||||
else
|
||||
pPlayer->m_hGroundEntity() = nullptr; // fix for velocity.z being set to 0 even if in air
|
||||
}
|
||||
else if (Vars::Misc::Movement::Bunnyhop.Value && G::OriginalCmd.buttons & IN_JUMP)
|
||||
tStorage.m_bBunnyHop = true;
|
||||
|
||||
// setup move data
|
||||
if (!SetupMoveData(tStorage))
|
||||
{
|
||||
@@ -311,7 +236,7 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& tStora
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMovementSimulation::SetupMoveData(PlayerStorage& tStorage)
|
||||
bool CMovementSimulation::SetupMoveData(MoveStorage& tStorage)
|
||||
{
|
||||
if (!tStorage.m_pPlayer)
|
||||
return false;
|
||||
@@ -465,7 +390,7 @@ static inline bool GetYawDifference(MoveData& tRecord1, MoveData& tRecord2, bool
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementSimulation::GetAverageYaw(PlayerStorage& tStorage, int iSamples)
|
||||
void CMovementSimulation::GetAverageYaw(MoveStorage& tStorage, int iSamples)
|
||||
{
|
||||
auto pPlayer = tStorage.m_pPlayer;
|
||||
auto& vRecords = m_mRecords[pPlayer->entindex()];
|
||||
@@ -549,7 +474,7 @@ void CMovementSimulation::GetAverageYaw(PlayerStorage& tStorage, int iSamples)
|
||||
SDK::Output("MovementSimulation", std::format("flAverageYaw calculated to {} from {} ({}) {}", flAverageYaw, iTicks, iMinimum, pPlayer->entindex() == I::EngineClient->GetLocalPlayer() ? "(local)" : "").c_str(), { 100, 255, 150 }, Vars::Debug::Logging.Value);
|
||||
}
|
||||
|
||||
bool CMovementSimulation::StrafePrediction(PlayerStorage& tStorage, int iSamples)
|
||||
bool CMovementSimulation::StrafePrediction(MoveStorage& tStorage, int iSamples)
|
||||
{
|
||||
if (tStorage.m_bDirectMove
|
||||
? !(Vars::Aimbot::Projectile::StrafePrediction.Value & Vars::Aimbot::Projectile::StrafePredictionEnum::Ground)
|
||||
@@ -560,7 +485,7 @@ bool CMovementSimulation::StrafePrediction(PlayerStorage& tStorage, int iSamples
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CMovementSimulation::SetDuck(PlayerStorage& tStorage, bool bDuck) // this only touches origin, bounds
|
||||
bool CMovementSimulation::SetDuck(MoveStorage& tStorage, bool bDuck) // this only touches origin, bounds
|
||||
{
|
||||
if (bDuck == tStorage.m_pPlayer->m_bDucked())
|
||||
return true;
|
||||
@@ -631,7 +556,7 @@ void CMovementSimulation::RestoreBounds(CTFPlayer* pPlayer)
|
||||
}
|
||||
}
|
||||
|
||||
void CMovementSimulation::RunTick(PlayerStorage& tStorage, bool bPath, std::function<void(CMoveData&)>* pCallback)
|
||||
void CMovementSimulation::RunTick(MoveStorage& tStorage, bool bPath, std::function<void(CMoveData&)>* pCallback)
|
||||
{
|
||||
if (tStorage.m_bFailed || !tStorage.m_pPlayer || !tStorage.m_pPlayer->IsPlayer())
|
||||
return;
|
||||
@@ -701,12 +626,12 @@ void CMovementSimulation::RunTick(PlayerStorage& tStorage, bool bPath, std::func
|
||||
RestoreBounds(tStorage.m_pPlayer);
|
||||
}
|
||||
|
||||
void CMovementSimulation::RunTick(PlayerStorage& tStorage, bool bPath, std::function<void(CMoveData&)> fCallback)
|
||||
void CMovementSimulation::RunTick(MoveStorage& tStorage, bool bPath, std::function<void(CMoveData&)> fCallback)
|
||||
{
|
||||
RunTick(tStorage, bPath, &fCallback);
|
||||
}
|
||||
|
||||
void CMovementSimulation::Restore(PlayerStorage& tStorage)
|
||||
void CMovementSimulation::Restore(MoveStorage& tStorage)
|
||||
{
|
||||
if (tStorage.m_bInitFailed || !tStorage.m_pPlayer)
|
||||
return;
|
||||
@@ -719,12 +644,6 @@ void CMovementSimulation::Restore(PlayerStorage& tStorage)
|
||||
I::Prediction->m_bInPrediction = m_bOldInPrediction;
|
||||
I::Prediction->m_bFirstTimePredicted = m_bOldFirstTimePredicted;
|
||||
I::GlobalVars->frametime = m_flOldFrametime;
|
||||
|
||||
/*
|
||||
const bool bInitFailed = tStorage.m_bInitFailed, bFailed = tStorage.m_bFailed;
|
||||
memset(&tStorage, 0, sizeof(PlayerStorage));
|
||||
tStorage.m_bInitFailed = bInitFailed, tStorage.m_bFailed = bFailed;
|
||||
*/
|
||||
}
|
||||
|
||||
float CMovementSimulation::GetPredictedDelta(CBaseEntity* pEntity)
|
||||
|
||||
@@ -2,62 +2,11 @@
|
||||
#include "../../../SDK/SDK.h"
|
||||
#include <functional>
|
||||
|
||||
struct PlayerData
|
||||
{
|
||||
Vec3 m_vecOrigin = {};
|
||||
Vec3 m_vecVelocity = {};
|
||||
Vec3 m_vecBaseVelocity = {};
|
||||
Vec3 m_vecViewOffset = {};
|
||||
EHANDLE m_hGroundEntity = nullptr;
|
||||
int m_fFlags = 0;
|
||||
float m_flDucktime = 0.f;
|
||||
float m_flDuckJumpTime = 0.f;
|
||||
bool m_bDucked = false;
|
||||
bool m_bDucking = false;
|
||||
bool m_bInDuckJump = false;
|
||||
float m_flModelScale = 0.f;
|
||||
int m_nButtons = 0;
|
||||
float m_flLastMovementStunChange = 0.f;
|
||||
float m_flStunLerpTarget = 0.f;
|
||||
bool m_bStunNeedsFadeOut = false;
|
||||
float m_flPrevTauntYaw = 0.f;
|
||||
float m_flTauntYaw = 0.f;
|
||||
float m_flCurrentTauntMoveSpeed = 0.f;
|
||||
int m_iKartState = 0;
|
||||
float m_flVehicleReverseTime = 0.f;
|
||||
float m_flHypeMeter = 0.f;
|
||||
float m_flMaxspeed = 0.f;
|
||||
int m_nAirDucked = 0;
|
||||
bool m_bJumping = false;
|
||||
int m_iAirDash = 0;
|
||||
float m_flWaterJumpTime = 0.f;
|
||||
float m_flSwimSoundTime = 0.f;
|
||||
int m_surfaceProps = 0;
|
||||
void* m_pSurfaceData = nullptr;
|
||||
float m_surfaceFriction = 0.f;
|
||||
char m_chTextureType = 0;
|
||||
Vec3 m_vecPunchAngle = {};
|
||||
Vec3 m_vecPunchAngleVel = {};
|
||||
float m_flJumpTime = 0.f;
|
||||
byte m_MoveType = 0;
|
||||
byte m_MoveCollide = 0;
|
||||
Vec3 m_vecLadderNormal = {};
|
||||
float m_flGravity = 0.f;
|
||||
byte m_nWaterLevel = 0;
|
||||
byte m_nWaterType = 0;
|
||||
float m_flFallVelocity = 0.f;
|
||||
int m_nPlayerCond = 0;
|
||||
int m_nPlayerCondEx = 0;
|
||||
int m_nPlayerCondEx2 = 0;
|
||||
int m_nPlayerCondEx3 = 0;
|
||||
int m_nPlayerCondEx4 = 0;
|
||||
int _condition_bits = 0;
|
||||
};
|
||||
struct PlayerStorage
|
||||
struct MoveStorage
|
||||
{
|
||||
CTFPlayer* m_pPlayer = nullptr;
|
||||
CMoveData m_MoveData = {};
|
||||
PlayerData m_PlayerData = {};
|
||||
byte* m_pData = nullptr;
|
||||
|
||||
float m_flAverageYaw = 0.f;
|
||||
bool m_bBunnyHop = false;
|
||||
@@ -88,12 +37,12 @@ struct MoveData
|
||||
class CMovementSimulation
|
||||
{
|
||||
private:
|
||||
void Store(PlayerStorage& tStorage);
|
||||
void Reset(PlayerStorage& tStorage);
|
||||
void Store(MoveStorage& tStorage);
|
||||
void Reset(MoveStorage& tStorage);
|
||||
|
||||
bool SetupMoveData(PlayerStorage& tStorage);
|
||||
void GetAverageYaw(PlayerStorage& tStorage, int iSamples);
|
||||
bool StrafePrediction(PlayerStorage& tStorage, int iSamples);
|
||||
bool SetupMoveData(MoveStorage& tStorage);
|
||||
void GetAverageYaw(MoveStorage& tStorage, int iSamples);
|
||||
bool StrafePrediction(MoveStorage& tStorage, int iSamples);
|
||||
|
||||
void SetBounds(CTFPlayer* pPlayer);
|
||||
void RestoreBounds(CTFPlayer* pPlayer);
|
||||
@@ -108,11 +57,11 @@ private:
|
||||
public:
|
||||
void Store();
|
||||
|
||||
bool Initialize(CBaseEntity* pEntity, PlayerStorage& tStorage, bool bHitchance = true, bool bStrafe = true);
|
||||
bool SetDuck(PlayerStorage& tStorage, bool bDuck);
|
||||
void RunTick(PlayerStorage& tStorage, bool bPath = true, std::function<void(CMoveData&)>* pCallback = nullptr);
|
||||
void RunTick(PlayerStorage& tStorage, bool bPath, std::function<void(CMoveData&)> fCallback);
|
||||
void Restore(PlayerStorage& tStorage);
|
||||
bool Initialize(CBaseEntity* pEntity, MoveStorage& tStorage, bool bHitchance = true, bool bStrafe = true);
|
||||
bool SetDuck(MoveStorage& tStorage, bool bDuck);
|
||||
void RunTick(MoveStorage& tStorage, bool bPath = true, std::function<void(CMoveData&)>* pCallback = nullptr);
|
||||
void RunTick(MoveStorage& tStorage, bool bPath, std::function<void(CMoveData&)> fCallback);
|
||||
void Restore(MoveStorage& tStorage);
|
||||
|
||||
float GetPredictedDelta(CBaseEntity* pEntity);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "../SDK/SDK.h"
|
||||
|
||||
#include "../Features/EnginePrediction/EnginePrediction.h"
|
||||
#include "../Features/Spectate/Spectate.h"
|
||||
|
||||
MAKE_HOOK(CHLClient_LevelShutdown, U::Memory.GetVirtual(I::Client, 7), void,
|
||||
@@ -11,6 +12,7 @@ MAKE_HOOK(CHLClient_LevelShutdown, U::Memory.GetVirtual(I::Client, 7), void,
|
||||
#endif
|
||||
|
||||
H::Entities.Clear(true);
|
||||
F::EnginePrediction.Unload();
|
||||
F::Spectate.m_iIntendedTarget = -1;
|
||||
|
||||
CALL_ORIGINAL(rcx);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Main/CEconWearable.h"
|
||||
#include "Main/CEntitySphereQuery.h"
|
||||
#include "Main/CMultiPlayerAnimState.h"
|
||||
#include "Main/CPredictionCopy.h"
|
||||
#include "Main/CSniperDot.h"
|
||||
#include "Main/CTFPlayer.h"
|
||||
#include "Main/CTFPlayerResource.h"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "Interfaces/IKeyValuesSystem.h"
|
||||
#include "Interfaces/IMaterialSystem.h"
|
||||
#include "Interfaces/IMatSystemSurface.h"
|
||||
#include "Interfaces/IMemAlloc.h"
|
||||
#include "Interfaces/IMoveHelper.h"
|
||||
#include "Interfaces/IPanel.h"
|
||||
#include "Interfaces/IStudioRender.h"
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
#pragma once
|
||||
#include "Interface.h"
|
||||
#include "../Misc/BaseTypes.h"
|
||||
|
||||
typedef size_t(*MemAllocFailHandler_t)(size_t);
|
||||
class IVirtualMemorySection;
|
||||
|
||||
struct GenericMemoryStat_t
|
||||
{
|
||||
const char* name;
|
||||
int value;
|
||||
};
|
||||
|
||||
class IMemAlloc
|
||||
{
|
||||
public:
|
||||
virtual void* Alloc(size_t nSize) = 0;
|
||||
virtual void* Realloc(void* pMem, size_t nSize) = 0;
|
||||
virtual void Free(void* pMem) = 0;
|
||||
virtual void* Expand_NoLongerSupported(void* pMem, size_t nSize) = 0;
|
||||
virtual void* Alloc(size_t nSize, const char* pFileName, int nLine) = 0;
|
||||
virtual void* Realloc(void* pMem, size_t nSize, const char* pFileName, int nLine) = 0;
|
||||
virtual void Free(void* pMem, const char* pFileName, int nLine) = 0;
|
||||
virtual void* Expand_NoLongerSupported(void* pMem, size_t nSize, const char* pFileName, int nLine) = 0;
|
||||
virtual size_t GetSize(void* pMem) = 0;
|
||||
virtual void PushAllocDbgInfo(const char* pFileName, int nLine) = 0;
|
||||
virtual void PopAllocDbgInfo() = 0;
|
||||
virtual int32 CrtSetBreakAlloc(int32 lNewBreakAlloc) = 0;
|
||||
virtual int CrtSetReportMode(int nReportType, int nReportMode) = 0;
|
||||
virtual int CrtIsValidHeapPointer(const void* pMem) = 0;
|
||||
virtual int CrtIsValidPointer(const void* pMem, unsigned int size, int access) = 0;
|
||||
virtual int CrtCheckMemory(void) = 0;
|
||||
virtual int CrtSetDbgFlag(int nNewFlag) = 0;
|
||||
virtual void CrtMemCheckpoint(_CrtMemState* pState) = 0;
|
||||
virtual void DumpStats() = 0;
|
||||
virtual void DumpStatsFileBase(char const* pchFileBase) = 0;
|
||||
virtual size_t ComputeMemoryUsedBy(char const* pchSubStr) = 0;
|
||||
virtual void* CrtSetReportFile(int nRptType, void* hFile) = 0;
|
||||
virtual void* CrtSetReportHook(void* pfnNewHook) = 0;
|
||||
virtual int CrtDbgReport(int nRptType, const char* szFile, int nLine, const char* szModule, const char* pMsg) = 0;
|
||||
virtual int heapchk() = 0;
|
||||
virtual bool IsDebugHeap() = 0;
|
||||
virtual void GetActualDbgInfo(const char*& pFileName, int& nLine) = 0;
|
||||
virtual void RegisterAllocation(const char* pFileName, int nLine, size_t nLogicalSize, size_t nActualSize, unsigned nTime) = 0;
|
||||
virtual void RegisterDeallocation(const char* pFileName, int nLine, size_t nLogicalSize, size_t nActualSize, unsigned nTime) = 0;
|
||||
virtual int GetVersion() = 0;
|
||||
virtual void CompactHeap() = 0;
|
||||
virtual MemAllocFailHandler_t SetAllocFailHandler(MemAllocFailHandler_t pfnMemAllocFailHandler) = 0;
|
||||
virtual void DumpBlockStats(void*) = 0;
|
||||
virtual void SetStatsExtraInfo(const char* pMapName, const char* pComment) = 0;
|
||||
virtual size_t MemoryAllocFailed() = 0;
|
||||
virtual void CompactIncremental() = 0;
|
||||
virtual void OutOfMemory(size_t nBytesAttempted = 0) = 0;
|
||||
virtual void* RegionAlloc(int region, size_t nSize) = 0;
|
||||
virtual void* RegionAlloc(int region, size_t nSize, const char* pFileName, int nLine) = 0;
|
||||
virtual void GlobalMemoryStatus(size_t* pUsedMemory, size_t* pFreeMemory) = 0;
|
||||
virtual IVirtualMemorySection* AllocateVirtualMemorySection(size_t numMaxBytes) = 0;
|
||||
virtual int GetGenericMemoryStats(GenericMemoryStat_t** ppMemoryStats) = 0;
|
||||
virtual ~IMemAlloc() {};
|
||||
virtual uint32 GetDebugInfoSize() = 0;
|
||||
virtual void SaveDebugInfo(void* pvDebugInfo) = 0;
|
||||
virtual void RestoreDebugInfo(const void* pvDebugInfo) = 0;
|
||||
virtual void InitDebugInfo(void* pvDebugInfo, const char* pchRootFileName, int nLine) = 0;
|
||||
};
|
||||
|
||||
MAKE_INTERFACE_EXPORT(IMemAlloc, MemAlloc, "tier0.dll", "g_pMemAlloc", 1);
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
#include "../../SDK.h"
|
||||
|
||||
int CBaseEntity::GetIntermediateDataSize()
|
||||
{
|
||||
return std::max(GetPredDescMap()->packed_size, 4);
|
||||
}
|
||||
|
||||
Vec3 CBaseEntity::GetSize()
|
||||
{
|
||||
return m_vecMaxs() - m_vecMins();
|
||||
|
||||
@@ -290,6 +290,7 @@ public:
|
||||
return vOut;
|
||||
}
|
||||
|
||||
int GetIntermediateDataSize();
|
||||
Vec3 GetSize();
|
||||
Vec3 GetOffset();
|
||||
Vec3 GetCenter();
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#pragma once
|
||||
#include "../Misc/Datamap.h"
|
||||
#include "../../../Utils/Signatures/Signatures.h"
|
||||
|
||||
MAKE_SIGNATURE(CPredictionCopy_TransferData, "client.dll", "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 8B 3D", 0x0);
|
||||
|
||||
#define PC_DATA_PACKED true
|
||||
#define PC_DATA_NORMAL false
|
||||
|
||||
enum
|
||||
{
|
||||
PC_EVERYTHING = 0,
|
||||
PC_NON_NETWORKED_ONLY,
|
||||
PC_NETWORKED_ONLY,
|
||||
};
|
||||
|
||||
typedef void (*FN_FIELD_COMPARE)(const char* classname, const char* fieldname, const char* fieldtype,
|
||||
bool networked, bool noterrorchecked, bool differs, bool withintolerance, const char* value);
|
||||
|
||||
class CPredictionCopy
|
||||
{
|
||||
public:
|
||||
typedef enum
|
||||
{
|
||||
DIFFERS = 0,
|
||||
IDENTICAL,
|
||||
WITHINTOLERANCE,
|
||||
} difftype_t;
|
||||
|
||||
CPredictionCopy(int type, void* dest, bool dest_packed, void const* src, bool src_packed,
|
||||
bool counterrors = false, bool reporterrors = false, bool performcopy = true,
|
||||
bool describefields = false, FN_FIELD_COMPARE func = nullptr)
|
||||
{
|
||||
m_nType = type;
|
||||
m_pDest = dest;
|
||||
m_pSrc = src;
|
||||
m_nDestOffsetIndex = dest_packed ? TD_OFFSET_PACKED : TD_OFFSET_NORMAL;
|
||||
m_nSrcOffsetIndex = src_packed ? TD_OFFSET_PACKED : TD_OFFSET_NORMAL;
|
||||
m_bErrorCheck = counterrors;
|
||||
m_bReportErrors = reporterrors;
|
||||
m_bPerformCopy = performcopy;
|
||||
m_bDescribeFields = describefields;
|
||||
|
||||
m_pCurrentField = nullptr;
|
||||
m_pCurrentMap = nullptr;
|
||||
m_pCurrentClassName = nullptr;
|
||||
m_bShouldReport = false;
|
||||
m_bShouldDescribe = false;
|
||||
m_nErrorCount = 0;
|
||||
|
||||
m_FieldCompareFunc = func;
|
||||
}
|
||||
|
||||
int TransferData(const char* operation, int entindex, datamap_t* dmap)
|
||||
{
|
||||
return S::CPredictionCopy_TransferData.Call<int>(this, operation, entindex, dmap);
|
||||
}
|
||||
|
||||
public:
|
||||
int m_nType;
|
||||
void* m_pDest;
|
||||
void const* m_pSrc;
|
||||
int m_nDestOffsetIndex;
|
||||
int m_nSrcOffsetIndex;
|
||||
|
||||
bool m_bErrorCheck;
|
||||
bool m_bReportErrors;
|
||||
bool m_bDescribeFields;
|
||||
typedescription_t* m_pCurrentField;
|
||||
char const* m_pCurrentClassName;
|
||||
datamap_t* m_pCurrentMap;
|
||||
bool m_bShouldReport;
|
||||
bool m_bShouldDescribe;
|
||||
int m_nErrorCount;
|
||||
bool m_bPerformCopy;
|
||||
|
||||
FN_FIELD_COMPARE m_FieldCompareFunc;
|
||||
|
||||
typedescription_t* m_pWatchField;
|
||||
char const* m_pOperation;
|
||||
};
|
||||
@@ -10,11 +10,12 @@
|
||||
|
||||
#pragma warning (disable: 4172)
|
||||
|
||||
InterfaceInit_t::InterfaceInit_t(void** pPtr, const char* sDLLName, const char* sVersion, int nOffset, int nDereferenceCount)
|
||||
InterfaceInit_t::InterfaceInit_t(void** pPtr, const char* sDLL, const char* sName, int8_t nType, int8_t nOffset, int8_t nDereferenceCount)
|
||||
{
|
||||
m_pPtr = pPtr;
|
||||
m_sDLLName = sDLLName;
|
||||
m_sVersion = sVersion;
|
||||
m_sDLL = sDLL;
|
||||
m_sName = sName;
|
||||
m_nType = nType;
|
||||
m_nOffset = nOffset;
|
||||
m_nDereferenceCount = nDereferenceCount;
|
||||
|
||||
@@ -27,7 +28,7 @@ bool CInterfaces::Initialize()
|
||||
{
|
||||
const char* sModule = nullptr;
|
||||
std::vector<std::string> vModules;
|
||||
boost::split(vModules, Interface->m_sDLLName, boost::is_any_of(", "));
|
||||
boost::split(vModules, Interface->m_sDLL, boost::is_any_of(", "));
|
||||
if (vModules.size() == 1)
|
||||
sModule = vModules.front().c_str();
|
||||
else
|
||||
@@ -46,37 +47,48 @@ bool CInterfaces::Initialize()
|
||||
for (auto& sName : vModules)
|
||||
ssModuleStream << std::format("{}{}", !ssModuleStream.str().empty() ? ", " : "", sName);
|
||||
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to find module:\n {}\n {}", ssModuleStream.str(), Interface->m_sVersion).c_str());
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to find module:\n {}\n {}", ssModuleStream.str(), Interface->m_sName).c_str());
|
||||
m_bFailed = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (Interface->m_nOffset == -1)
|
||||
*Interface->m_pPtr = U::Memory.FindInterface(sModule, Interface->m_sVersion);
|
||||
else
|
||||
switch (Interface->m_nType)
|
||||
{
|
||||
auto dwDest = U::Memory.FindSignature(sModule, Interface->m_sVersion);
|
||||
case 0:
|
||||
{
|
||||
*Interface->m_pPtr = U::Memory.FindInterface(sModule, Interface->m_sName);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
*Interface->m_pPtr = U::Memory.GetModuleExport<void*>(sModule, Interface->m_sName);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
auto dwDest = U::Memory.FindSignature(sModule, Interface->m_sName);
|
||||
if (!dwDest)
|
||||
{
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to find signature:\n {}\n {}", sModule, Interface->m_sVersion).c_str());
|
||||
m_bFailed = true;
|
||||
continue;
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to find signature").c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
auto dwAddress = U::Memory.RelToAbs(dwDest);
|
||||
*Interface->m_pPtr = reinterpret_cast<void*>(dwAddress + Interface->m_nOffset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int n = 0; n < Interface->m_nDereferenceCount; n++)
|
||||
{
|
||||
if (Interface->m_pPtr)
|
||||
*Interface->m_pPtr = *reinterpret_cast<void**>(*Interface->m_pPtr);
|
||||
}
|
||||
for (int n = 0; n < Interface->m_nDereferenceCount; n++)
|
||||
{
|
||||
if (Interface->m_pPtr)
|
||||
*Interface->m_pPtr = *reinterpret_cast<void**>(*Interface->m_pPtr);
|
||||
}
|
||||
|
||||
if (!*Interface->m_pPtr)
|
||||
{
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to initialize:\n {}\n {}", sModule, Interface->m_sVersion).c_str());
|
||||
U::Core.AppendFailText(std::format("CInterfaces::Initialize() failed to initialize:\n {}\n {}", sModule, Interface->m_sName).c_str());
|
||||
m_bFailed = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,34 @@
|
||||
struct InterfaceInit_t
|
||||
{
|
||||
void** m_pPtr;
|
||||
const char* m_sDLLName;
|
||||
const char* m_sVersion;
|
||||
int m_nOffset; //if not -1 we're going to sig scan (m_sVersion is the sig)
|
||||
int m_nDereferenceCount;
|
||||
const char* m_sDLL;
|
||||
const char* m_sName;
|
||||
int8_t m_nType; // 0: find interface, 1: get export, 2: sig scan
|
||||
int8_t m_nOffset;
|
||||
int8_t m_nDereferenceCount;
|
||||
|
||||
InterfaceInit_t(void** pPtr, const char* sDLLName, const char* sVersion, int nOffset, int nDereferenceCount);
|
||||
InterfaceInit_t(void** pPtr, const char* sDLL, const char* sName, int8_t nType, int8_t nOffset = 0, int8_t nDereferenceCount = 0);
|
||||
};
|
||||
|
||||
#define MAKE_INTERFACE_VERSION(type, name, dll, version) namespace I { inline type *name = nullptr; } \
|
||||
#define MAKE_INTERFACE_VERSION(type, symbol, dll, version) namespace I { inline type *symbol = nullptr; } \
|
||||
namespace MAKE_INTERFACE_SCOPE \
|
||||
{\
|
||||
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, version, -1, 0); \
|
||||
inline InterfaceInit_t symbol##InterfaceInit_t(reinterpret_cast<void**>(&I::symbol), dll, version, 0); \
|
||||
}
|
||||
|
||||
#define MAKE_INTERFACE_SIGNATURE(type, name, dll, signature, offset, deref) namespace I { inline type *name = nullptr; } \
|
||||
#define MAKE_INTERFACE_EXPORT(type, symbol, dll, name, deref) namespace I { inline type *symbol = nullptr; } \
|
||||
namespace MAKE_INTERFACE_SCOPE \
|
||||
{\
|
||||
inline InterfaceInit_t name##InterfaceInit_t(reinterpret_cast<void **>(&I::name), dll, signature, offset, deref); \
|
||||
inline InterfaceInit_t symbol##InterfaceInit_t(reinterpret_cast<void**>(&I::symbol), dll, name, 1, 0, deref); \
|
||||
}
|
||||
|
||||
#define MAKE_INTERFACE_NULL(type, name) namespace I { inline type *name = nullptr; }
|
||||
#define MAKE_INTERFACE_SIGNATURE(type, symbol, dll, signature, offset, deref) namespace I { inline type *symbol = nullptr; } \
|
||||
namespace MAKE_INTERFACE_SCOPE \
|
||||
{\
|
||||
inline InterfaceInit_t symbol##InterfaceInit_t(reinterpret_cast<void**>(&I::symbol), dll, signature, 2, offset, deref); \
|
||||
}
|
||||
|
||||
#define MAKE_INTERFACE_NULL(type, symbol) namespace I { inline type *symbol = nullptr; }
|
||||
|
||||
class CInterfaces
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <string>
|
||||
#include <format>
|
||||
|
||||
CSignature::CSignature(const char* sDLLName, const char* sSignature, int nOffset, const char* sName)
|
||||
CSignature::CSignature(const char* sDLLName, const char* sSignature, int8_t nOffset, const char* sName)
|
||||
{
|
||||
m_dwVal = 0x0;
|
||||
m_sDLLName = sDLLName;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
#include "../Macros/Macros.h"
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
class CSignature
|
||||
@@ -9,11 +8,11 @@ private:
|
||||
uintptr_t m_dwVal;
|
||||
const char* m_sDLLName;
|
||||
const char* m_sSignature;
|
||||
int m_nOffset;
|
||||
int8_t m_nOffset;
|
||||
const char* m_sName;
|
||||
|
||||
public:
|
||||
CSignature(const char* sDLLName, const char* sSignature, int nOffset, const char* sName);
|
||||
CSignature(const char* sDLLName, const char* sSignature, int8_t nOffset, const char* sName);
|
||||
|
||||
bool Initialize();
|
||||
|
||||
|
||||
@@ -21,10 +21,8 @@
|
||||
<br><br>
|
||||
<sub>If nightly.link is down or can't be accessed, you can still download through [GitHub](https://github.com/rei-2/Amalgam/actions) with an account. </sub>
|
||||
|
||||
</div>
|
||||
##
|
||||
|
||||
##
|
||||
Read about Amalgam's documentation and features [here](../../wiki).
|
||||
|
||||
[VAC bypass](https://github.com/danielkrupinski/VAC-Bypass-Loader) and [Xenos](https://github.com/DarthTon/Xenos/releases) recommended.
|
||||
|
||||
Read about Amalgam's documentation and features [here](../../wiki).
|
||||
</div>
|
||||
Reference in New Issue
Block a user