Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Prediction.h"
- // yay we can hit skeet now. Just for me to make a good resolver and we gucci. i also updated eye angle pointer so resolver works
- float m_flOldCurtime;
- float m_flOldFrametime;
- int* nPredictionRandomSeed = nullptr;
- #define TICK_INTERVAL ( Interfaces::Globals->interval_per_tick )
- #define TIME_TO_TICKS( dt ) ( (int)( 0.5f + (float)(dt) / TICK_INTERVAL ) )
- #define TICKS_TO_TIME( t ) ( Interfaces::Globals->interval_per_tick * ( t ) )
- void LagComp::LagCompensation(CUserCmd *cmd, IClientEntity *pLocal)
- {
- LagRecord *prevRecord = NULL;
- LagRecord *record = NULL;
- Vector prevOrg = pLocal->GetOrigin();
- Vector delta = record->m_vecOrigin - prevOrg;
- /*if (delta.Length2DSqr() > prevRecord->m_flTeleportDistanceSqr) 64
- {
- // lost track, too much difference
- return;
- }*/
- // correct is the amout of time we have to correct game time
- float correct = 0.0f;
- // calc number of view interpolation ticks - 1
- int lerpTicks = TIME_TO_TICKS(cmd->m_fLerpTime);
- // add view interpolation latency see C_BaseEntity::GetInterpolationAmount()
- correct += TICKS_TO_TIME(lerpTicks);
- // correct tick send by player
- int targettick = cmd->tick_count - lerpTicks;
- // calc difference between tick send by player and our latency based tick
- float deltaTime = correct - TICKS_TO_TIME(Interfaces::Globals->tickcount - targettick);
- if (fabs(deltaTime) > 0.2f)
- {
- // difference between cmd time and latency is too big > 200ms, use time correction based on latency
- targettick = Interfaces::Globals->tickcount - TIME_TO_TICKS(correct);
- }
- }
- void Prediction::PredictionStart(CUserCmd* cmd, IClientEntity* pLocal)
- {
- BYTE bMoveData[0x200];
- float curtime = Interfaces::Globals->curtime;
- float frametime = Interfaces::Globals->frametime;
- int iFlags = pLocal->GetFlags();
- Interfaces::Globals->curtime = (float)pLocal->GetTickBase() * Interfaces::Globals->interval_per_tick;
- Interfaces::Globals->frametime = Interfaces::Globals->interval_per_tick;
- Interfaces::MoveHelper->SetHost(pLocal);
- Interfaces::GamePrediction->SetupMove(pLocal, cmd, nullptr, bMoveData);
- Interfaces::GameMovement->ProcessMovement(pLocal, bMoveData);
- Interfaces::GamePrediction->FinishMove(pLocal, cmd, bMoveData);
- Interfaces::MoveHelper->SetHost(0);
- Interfaces::Globals->curtime = curtime;
- Interfaces::Globals->frametime = frametime;
- *pLocal->GetPointerFlags() = iFlags;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement