fixed the listen server unpause lag / time-out

this issue popped up after commit 176aa6a24d
This commit is contained in:
myT 2018-01-19 00:31:48 +01:00
parent f1bbe75937
commit 215d54cafd
4 changed files with 26 additions and 3 deletions

View File

@ -814,7 +814,7 @@ void CL_SetCGameTime()
} }
// allow pause in single player // allow pause in single player
if ( sv_paused->integer && cl_paused->integer && com_sv_running->integer ) { if ( sv_paused->integer && CL_Paused() && com_sv_running->integer ) {
return; return;
} }

View File

@ -1472,7 +1472,7 @@ static void CL_CheckTimeout()
return; return;
} }
if ( ( !cl_paused->integer || !sv_paused->integer ) if ( ( !CL_Paused() || !sv_paused->integer )
&& cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC && cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC
&& cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) { && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) {
if (++cl.timeoutcount > 5) { // timeoutcount saves debugger if (++cl.timeoutcount > 5) { // timeoutcount saves debugger
@ -1493,7 +1493,7 @@ static void CL_CheckUserinfo()
return; return;
} }
// don't overflow the reliable command buffer when paused // don't overflow the reliable command buffer when paused
if ( cl_paused->integer ) { if ( CL_Paused() ) {
return; return;
} }
// send a reliable userinfo update if needed // send a reliable userinfo update if needed
@ -1587,6 +1587,22 @@ int CL_ScaledMilliseconds()
} }
qbool CL_Paused()
{
// Summary: We keep the client pause active until we get a new server time through a snapshot.
//
// Without this fix, after the client pause ends and before we get a new server snapshot,
// CL_AdjustTimeDelta will update cl.serverTime to a higher value
// and that value is sent in the ucmd_t data to the server (CL_FinishMove).
// Since the timestamp is "from the future", anything that follows needs to be
// at least as high, which won't happen for a while because cl.serverTime will get reset to
// something correct (i.e. lower) upon reception of the next snapshot from the server.
// In other words: After a client pause of X seconds, the server ignores the client's input
// for X seconds and the client is basically timing out. Oops.
return cl_paused->integer || cl_paused->modified;
}
static void CL_InitRenderer() static void CL_InitRenderer()
{ {
// this sets up the renderer and calls R_Init // this sets up the renderer and calls R_Init

View File

@ -209,6 +209,11 @@ static void CL_ParseSnapshot( msg_t *msg )
newSnap.serverTime = MSG_ReadLong( msg ); newSnap.serverTime = MSG_ReadLong( msg );
// now that we have a server time update,
// we can consider the client pause (if active) truly over
// see CL_Paused for the details
cl_paused->modified = qfalse;
newSnap.messageNum = clc.serverMessageSequence; newSnap.messageNum = clc.serverMessageSequence;
deltaNum = MSG_ReadByte( msg ); deltaNum = MSG_ReadByte( msg );

View File

@ -376,6 +376,8 @@ int CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen )
void CL_DownloadsComplete(); void CL_DownloadsComplete();
void CL_DemoCompleted(); void CL_DemoCompleted();
qbool CL_Paused();
// cl_browser // cl_browser