mirror of
https://github.com/rei-2/Amalgam
synced 2026-10-10 21:03:09 +08:00
fix crash while in jump while swimming
This commit is contained in:
@@ -43,6 +43,7 @@ void CEnginePrediction::Simulate(CTFPlayer* pLocal, CUserCmd* pCmd)
|
||||
const bool bOldIsFirstPrediction = I::Prediction->m_bFirstTimePredicted;
|
||||
const bool bOldInPrediction = I::Prediction->m_bInPrediction;
|
||||
|
||||
I::MoveHelper->SetHost(pLocal);
|
||||
pLocal->SetCurrentCmd(pCmd);
|
||||
*G::RandomSeed() = MD5_PseudoRandom(pCmd->command_number) & std::numeric_limits<int>::max();
|
||||
|
||||
@@ -81,6 +82,7 @@ void CEnginePrediction::Simulate(CTFPlayer* pLocal, CUserCmd* pCmd)
|
||||
I::Prediction->FinishMove(pLocal, pCmd, &m_MoveData);
|
||||
}
|
||||
|
||||
I::MoveHelper->SetHost(nullptr);
|
||||
pLocal->SetCurrentCmd(nullptr);
|
||||
*G::RandomSeed() = -1;
|
||||
|
||||
|
||||
@@ -388,7 +388,9 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& player
|
||||
|
||||
auto pPlayer = pEntity->As<CTFPlayer>();
|
||||
playerStorageOut.m_pPlayer = pPlayer;
|
||||
playerStorageOut.m_pPlayer->SetCurrentCmd(&DummyCmd);
|
||||
|
||||
I::MoveHelper->SetHost(pPlayer);
|
||||
pPlayer->SetCurrentCmd(&DummyCmd);
|
||||
|
||||
// store player restore data
|
||||
Store(playerStorageOut);
|
||||
@@ -458,7 +460,7 @@ bool CMovementSimulation::Initialize(CBaseEntity* pEntity, PlayerStorage& player
|
||||
// really hope this doesn't work like shit
|
||||
if (useHitchance && bCalculated && !pPlayer->m_vecVelocity().IsZero() && Vars::Aimbot::Projectile::Hitchance.Value)
|
||||
{
|
||||
const auto& vRecords = mRecords[playerStorageOut.m_pPlayer->entindex()];
|
||||
const auto& vRecords = mRecords[pPlayer->entindex()];
|
||||
const auto iSamples = vRecords.size();
|
||||
|
||||
float flCurrentChance = 1.f, flAverageYaw = 0.f;
|
||||
@@ -588,7 +590,7 @@ static int GetYawDifference(std::deque<MoveData>& vRecords, size_t i, float* pYa
|
||||
|
||||
static int iChanges, iStart;
|
||||
bool bStraight = fabsf(*pYaw) * pRecord1.m_vVelocity.Length2D() * iTicks <= flStraightFuzzyValue; // dumb way to get straight bool
|
||||
bool bChanged = iLastSign != iCurSign;
|
||||
bool bChanged = iLastSign && iCurSign && iLastSign != iCurSign;
|
||||
if (!i)
|
||||
{
|
||||
iChanges = 0, iStart = TIME_TO_TICKS(flTime1);
|
||||
@@ -792,6 +794,7 @@ void CMovementSimulation::Restore(PlayerStorage& playerStorage)
|
||||
if (playerStorage.m_bInitFailed || !playerStorage.m_pPlayer)
|
||||
return;
|
||||
|
||||
I::MoveHelper->SetHost(nullptr);
|
||||
playerStorage.m_pPlayer->SetCurrentCmd(nullptr);
|
||||
|
||||
Reset(playerStorage);
|
||||
|
||||
@@ -28,6 +28,16 @@ public:
|
||||
virtual IPhysicsSurfaceProps* GetSurfaceProps(void) = 0;
|
||||
virtual bool IsWorldEntity(const CBaseHandle& handle) = 0;
|
||||
|
||||
inline CBasePlayer* GetHost()
|
||||
{
|
||||
return *reinterpret_cast<CBasePlayer**>(uintptr_t(this) + 40);
|
||||
}
|
||||
|
||||
inline void SetHost(CBasePlayer* pHost)
|
||||
{
|
||||
*reinterpret_cast<CBasePlayer**>(uintptr_t(this) + 40) = pHost;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ~IMoveHelper() {}
|
||||
};
|
||||
|
||||
@@ -167,7 +167,7 @@ namespace Vars
|
||||
CVar(GroundMaxChanges, 0, DEBUGVAR)
|
||||
CVar(GroundMaxChangeTime, 0, DEBUGVAR)
|
||||
CVar(GroundNewWeight, 100.f, DEBUGVAR)
|
||||
CVar(GroundOldWeight, 0.f, DEBUGVAR)
|
||||
CVar(GroundOldWeight, 100.f, DEBUGVAR)
|
||||
|
||||
CVar(AirSamples, 33, DEBUGVAR)
|
||||
CVar(AirStraightFuzzyValue, 10.f, DEBUGVAR)
|
||||
@@ -178,7 +178,7 @@ namespace Vars
|
||||
CVar(AirMaxChanges, 1, DEBUGVAR)
|
||||
CVar(AirMaxChangeTime, 10, DEBUGVAR)
|
||||
CVar(AirNewWeight, 100.f, DEBUGVAR)
|
||||
CVar(AirOldWeight, 0.f, DEBUGVAR)
|
||||
CVar(AirOldWeight, 100.f, DEBUGVAR)
|
||||
|
||||
CVar(VelocityAverageCount, 5, DEBUGVAR)
|
||||
CVar(VerticalShift, 5.f, DEBUGVAR)
|
||||
|
||||
Reference in New Issue
Block a user