Fixed last few stuff with clock correction

This commit is contained in:
Kamay Xutax 2024-07-23 05:03:22 +02:00
parent 6691968046
commit a3b6b94959
4 changed files with 24 additions and 8 deletions

View file

@ -2234,7 +2234,15 @@ void CL_Move(float accumulated_extra_samples, bool bFinalTick )
if ( cl.IsActive() )
{
NET_Tick mymsg( cl.m_nDeltaTick, cl.m_ClockDriftMgr.m_nCachedRealClientTick, host_frametime_unbounded, host_frametime_stddeviation );
// TODO_ENHANCED:
// When fps is lower than tickrate,
// the server doesn't really know how many ticks were processed this frame client-side.
//
// When the client tick count is sent to server, sv_max_usercmd_future_ticks doesn't take into account when
// multiple commands are ran from client because it had low fps.
// We could probably store in CUserCmd structure the current tick number to account for that ?
// This works anyway.
NET_Tick mymsg( cl.m_nDeltaTick, cl.m_ClockDriftMgr.m_nCachedRealClientTick + cl.m_ClockDriftMgr.m_nCurrentTick, host_frametime_unbounded, host_frametime_stddeviation );
cl.m_NetChannel->SendNetMsg( mymsg );
}

View file

@ -99,9 +99,10 @@ void CClockDriftMgr::ApplyClockCorrection(bool bFinalTick)
{
if (bFinalTick)
{
m_nCachedRealClientTick++;
cl.m_ClockDriftMgr.m_nCachedRealClientTick += cl.m_ClockDriftMgr.m_nNumberOfTicks;
}
m_nClientTick = m_nCachedRealClientTick + m_nLagDiff + g_ClientGlobalVariables.simTicksThisFrame - 1;
m_nClientTick = m_nCachedRealClientTick + m_nLagDiff;
}
void CClockDriftMgr::ShowDebugInfo()

View file

@ -39,6 +39,8 @@ public:
int m_nOldServerTick;
int m_nServerTick; // Last-received tick from the server.
int m_nClientTick;
int m_nNumberOfTicks;
int m_nCurrentTick;
int m_nCachedRealClientTick; // The client's own tick counter (specifically, for interpolation during rendering).
// The server may be on a slightly different tick and the client will drift towards it.
int m_nLaggedClientTick;

View file

@ -3130,6 +3130,8 @@ void _Host_RunFrame (float time)
host_remainder -= numticks * host_state.interval_per_tick;
}
cl.m_ClockDriftMgr.m_nNumberOfTicks = numticks;
host_nexttick = host_state.interval_per_tick - host_remainder;
g_pMDLCache->MarkFrame();
@ -3246,7 +3248,7 @@ void _Host_RunFrame (float time)
#endif
cl.m_tickRemainder = host_remainder;
g_ServerGlobalVariables.simTicksThisFrame = 1;
cl.SetFrameTime( host_frametime );
cl.SetFrameTime(host_frametime);
for ( int tick = 0; tick < numticks; tick++ )
{
// Emit an ETW event every simulation frame.
@ -3315,8 +3317,9 @@ void _Host_RunFrame (float time)
//-------------------
#ifndef SWDS
if ( !sv.IsDedicated() )
{
_Host_RunFrame_Client( bFinalTick );
{
cl.m_ClockDriftMgr.m_nCurrentTick = tick;
_Host_RunFrame_Client(bFinalTick);
}
toolframework->Think( bFinalTick );
@ -3358,7 +3361,8 @@ void _Host_RunFrame (float time)
// as quickly as we can.
if ( numticks == 0 && ( demoplayer->IsPlayingTimeDemo() || demoplayer->IsSkipping() ) )
{
_Host_RunFrame_Client( true );
cl.m_ClockDriftMgr.m_nCurrentTick = 0;
_Host_RunFrame_Client(true);
}
if ( !sv.IsDedicated() )
@ -3455,7 +3459,8 @@ void _Host_RunFrame (float time)
//-------------------
if ( !sv.IsDedicated() )
{
_Host_RunFrame_Client( bFinalTick );
cl.m_ClockDriftMgr.m_nCurrentTick = tick;
_Host_RunFrame_Client(bFinalTick);
}
toolframework->Think( bFinalTick );
}