Disabled clock correction, not stable enough

This commit is contained in:
Kamay Xutax 2024-08-24 14:17:13 +02:00
parent 7a92c3afde
commit 4cf14a0939
2 changed files with 43 additions and 19 deletions

View file

@ -515,10 +515,31 @@ void CL_ReadPackets ( bool bFinalTick )
if ( !Host_ShouldRun() ) if ( !Host_ShouldRun() )
return; return;
// update client times/tick
cl.oldtickcount = cl.GetServerTickCount(); // update client times/tick
if (!CClockDriftMgr::IsClockCorrectionEnabled())
{
cl.oldtickcount = cl.GetServerTickCount();
}
// Moved after process socket so we can receive the lastest updates.
if ( !cl.IsPaused() )
{
// While clock correction is off, we have the old behavior of matching the client and server clocks.
if (!CClockDriftMgr::IsClockCorrectionEnabled())
{
cl.SetClientTickCount(cl.GetClientTickCount() + 1);
cl.SetServerTickCount(cl.GetClientTickCount());
g_ClientGlobalVariables.tickcount = cl.GetClientTickCount();
g_ClientGlobalVariables.curtime = cl.GetTime();
}
}
if (!CClockDriftMgr::IsClockCorrectionEnabled())
{
// 0 or tick_rate if simulating
g_ClientGlobalVariables.frametime = cl.GetFrameTime();
}
// read packets, if any in queue // read packets, if any in queue
if ( demoplayer->IsPlayingBack() && cl.m_NetChannel ) if ( demoplayer->IsPlayingBack() && cl.m_NetChannel )
@ -562,25 +583,28 @@ void CL_ReadPackets ( bool bFinalTick )
} }
#endif #endif
if (CClockDriftMgr::IsClockCorrectionEnabled())
{
cl.oldtickcount = cl.GetServerTickCount();
}
// Moved after process socket so we can receive the lastest updates. // Moved after process socket so we can receive the lastest updates.
if ( !cl.IsPaused() ) if ( !cl.IsPaused() )
{ {
// While clock correction is off, we have the old behavior of matching the client and server clocks. // While clock correction is off, we have the old behavior of matching the client and server clocks.
if (!CClockDriftMgr::IsClockCorrectionEnabled()) if (CClockDriftMgr::IsClockCorrectionEnabled())
{ {
cl.SetClientTickCount(cl.GetClientTickCount() + 1); cl.m_ClockDriftMgr.IncrementCachedTickCount(bFinalTick);
cl.SetServerTickCount(cl.GetClientTickCount()); g_ClientGlobalVariables.tickcount = cl.GetClientTickCount();
} g_ClientGlobalVariables.curtime = cl.GetTime();
else }
{ }
cl.m_ClockDriftMgr.IncrementCachedTickCount(bFinalTick);
} if (CClockDriftMgr::IsClockCorrectionEnabled())
{
g_ClientGlobalVariables.tickcount = cl.GetClientTickCount(); // 0 or tick_rate if simulating
g_ClientGlobalVariables.curtime = cl.GetTime(); g_ClientGlobalVariables.frametime = cl.GetFrameTime();
} }
// 0 or tick_rate if simulating
g_ClientGlobalVariables.frametime = cl.GetFrameTime();
} }

View file

@ -11,7 +11,7 @@
#include "enginethreads.h" #include "enginethreads.h"
ConVar cl_clock_correction( "cl_clock_correction", "1", FCVAR_CHEAT, "Enable/disable clock correction on the client." ); ConVar cl_clock_correction( "cl_clock_correction", "0", FCVAR_CHEAT, "Enable/disable clock correction on the client." );
ConVar cl_clockdrift_max_ms( "cl_clockdrift_max_ms", "150", FCVAR_CHEAT, "Maximum number of milliseconds the clock is allowed to drift before the client snaps its clock to the server's." ); ConVar cl_clockdrift_max_ms( "cl_clockdrift_max_ms", "150", FCVAR_CHEAT, "Maximum number of milliseconds the clock is allowed to drift before the client snaps its clock to the server's." );
ConVar cl_clockdrift_max_ms_threadmode( "cl_clockdrift_max_ms_threadmode", "0", FCVAR_CHEAT, "Maximum number of milliseconds the clock is allowed to drift before the client snaps its clock to the server's." ); ConVar cl_clockdrift_max_ms_threadmode( "cl_clockdrift_max_ms_threadmode", "0", FCVAR_CHEAT, "Maximum number of milliseconds the clock is allowed to drift before the client snaps its clock to the server's." );