r870 - in trunk/code: client server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Aug 25 21:45:27 EDT 2006


Author: thilo
Date: 2006-08-25 21:45:27 -0400 (Fri, 25 Aug 2006)
New Revision: 870

Modified:
   trunk/code/client/cl_cgame.c
   trunk/code/client/cl_main.c
   trunk/code/client/cl_parse.c
   trunk/code/client/client.h
   trunk/code/server/sv_main.c
   trunk/code/server/sv_snapshot.c
Log:
- compensate sv_fps for timescale value.
- Add a non-dirty-hack fix for client hanging when unpausing a game.


Modified: trunk/code/client/cl_cgame.c
===================================================================
--- trunk/code/client/cl_cgame.c	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/client/cl_cgame.c	2006-08-26 01:45:27 UTC (rev 870)
@@ -941,7 +941,7 @@
 	}
 
 	// allow pause in single player
-	if ( sv_paused->integer && cl_paused->integer && com_sv_running->integer ) {
+	if ( sv_paused->integer && CL_CheckPaused() && com_sv_running->integer ) {
 		// paused
 		return;
 	}

Modified: trunk/code/client/cl_main.c
===================================================================
--- trunk/code/client/cl_main.c	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/client/cl_main.c	2006-08-26 01:45:27 UTC (rev 870)
@@ -1961,7 +1961,7 @@
 	//
 	// check timeout
 	//
-	if ( ( !cl_paused->integer || !sv_paused->integer ) 
+	if ( ( !CL_CheckPaused() || !sv_paused->integer ) 
 		&& cls.state >= CA_CONNECTED && cls.state != CA_CINEMATIC
 	    && cls.realtime - clc.lastPacketTime > cl_timeout->value*1000) {
 		if (++cl.timeoutcount > 5) {	// timeoutcount saves debugger
@@ -1974,6 +1974,22 @@
 	}
 }
 
+/*
+==================
+CL_CheckPaused
+Check whether client has been paused.
+==================
+*/
+qboolean CL_CheckPaused(void)
+{
+	// if cl_paused->modified is set, the cvar has only been changed in
+	// this frame. Keep paused in this frame to ensure the server doesn't
+	// lag behind.
+	if(cl_paused->integer || cl_paused->modified)
+		return qtrue;
+	
+	return qfalse;
+}
 
 //============================================================================
 
@@ -1985,19 +2001,19 @@
 */
 void CL_CheckUserinfo( void ) {
 	// don't add reliable commands when not yet connected
-	if ( cls.state < CA_CHALLENGING ) {
+	if(cls.state < CA_CHALLENGING)
 		return;
-	}
+
 	// don't overflow the reliable command buffer when paused
-	if ( cl_paused->integer ) {
+	if(CL_CheckPaused())
 		return;
-	}
+
 	// send a reliable userinfo update if needed
-	if ( cvar_modifiedFlags & CVAR_USERINFO ) {
+	if(cvar_modifiedFlags & CVAR_USERINFO)
+	{
 		cvar_modifiedFlags &= ~CVAR_USERINFO;
 		CL_AddReliableCommand( va("userinfo \"%s\"", Cvar_InfoString( CVAR_USERINFO ) ) );
 	}
-
 }
 
 /*

Modified: trunk/code/client/cl_parse.c
===================================================================
--- trunk/code/client/cl_parse.c	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/client/cl_parse.c	2006-08-26 01:45:27 UTC (rev 870)
@@ -219,6 +219,10 @@
 
 	newSnap.serverTime = MSG_ReadLong( msg );
 
+	// if we were just unpaused, we can only *now* really let the
+	// change come into effect or the client hangs.
+	cl_paused->modified = 0;
+
 	newSnap.messageNum = clc.serverMessageSequence;
 
 	deltaNum = MSG_ReadByte( msg );

Modified: trunk/code/client/client.h
===================================================================
--- trunk/code/client/client.h	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/client/client.h	2006-08-26 01:45:27 UTC (rev 870)
@@ -394,6 +394,7 @@
 qboolean CL_CDKeyValidate( const char *key, const char *checksum );
 int CL_ServerStatus( char *serverAddress, char *serverStatusString, int maxLen );
 
+qboolean CL_CheckPaused(void);
 
 //
 // cl_input

Modified: trunk/code/server/sv_main.c
===================================================================
--- trunk/code/server/sv_main.c	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/server/sv_main.c	2006-08-26 01:45:27 UTC (rev 870)
@@ -798,7 +798,7 @@
 	if ( sv_fps->integer < 1 ) {
 		Cvar_Set( "sv_fps", "10" );
 	}
-	frameMsec = 1000 / sv_fps->integer ;
+	frameMsec = 1000 / sv_fps->integer * com_timescale->value;
 
 	sv.timeResidual += msec;
 

Modified: trunk/code/server/sv_snapshot.c
===================================================================
--- trunk/code/server/sv_snapshot.c	2006-08-25 16:25:51 UTC (rev 869)
+++ trunk/code/server/sv_snapshot.c	2006-08-26 01:45:27 UTC (rev 870)
@@ -587,12 +587,12 @@
 	// TTimo - https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=491
 	// added sv_lanForceRate check
 	if ( client->netchan.remoteAddress.type == NA_LOOPBACK || (sv_lanForceRate->integer && Sys_IsLANAddress (client->netchan.remoteAddress)) ) {
-		client->nextSnapshotTime = svs.time + (1000/sv_fps->integer);
+		client->nextSnapshotTime = svs.time + (1000.0 / sv_fps->integer * com_timescale->value);
 		return;
 	}
 	
 	// normal rate / snapshotMsec calculation
-	rateMsec = SV_RateMsec( client, msg->cursize );
+	rateMsec = SV_RateMsec(client, msg->cursize);
 
 	if ( rateMsec < client->snapshotMsec ) {
 		// never send more packets than this, no matter what the rate is at
@@ -602,16 +602,15 @@
 		client->rateDelayed = qtrue;
 	}
 
-	client->nextSnapshotTime = svs.time + rateMsec;
+	client->nextSnapshotTime = svs.time + rateMsec * com_timescale->value;
 
 	// don't pile up empty snapshots while connecting
 	if ( client->state != CS_ACTIVE ) {
 		// a gigantic connection message may have already put the nextSnapshotTime
 		// more than a second away, so don't shorten it
 		// do shorten if client is downloading
-		if ( !*client->downloadName && client->nextSnapshotTime < svs.time + 1000 ) {
-			client->nextSnapshotTime = svs.time + 1000;
-		}
+		if (!*client->downloadName && client->nextSnapshotTime < svs.time + 1000 * com_timescale->value)
+			client->nextSnapshotTime = svs.time + 1000 * com_timescale->value;
 	}
 }
 




More information about the quake3-commits mailing list