From: cloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Date: Wed, 15 Jul 2020 02:44:15 +0000 (+0000)
Subject: host: Adjust timers at the end of each client or server frame, and other tweaks
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=be135a8eb4c9f12f7f561671b7c7684b4fba5587;p=xonotic%2Fdarkplaces.git

host: Adjust timers at the end of each client or server frame, and other tweaks

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12807 d7cf8633-e32d-0410-b094-e92efae38249
---

diff --git a/host.c b/host.c
index 3cfccf4b..2f8fcfd3 100644
--- a/host.c
+++ b/host.c
@@ -413,7 +413,7 @@ void Host_Main(void)
 
 	host.realtime = 0;
 	host.sleeptime = 0;
-	host.dirtytime = Sys_DirtyTime();
+	host.dirtytime = oldtime = Sys_DirtyTime();
 
 	while(host.state != host_shutdown)
 	{
@@ -423,8 +423,7 @@ void Host_Main(void)
 			continue;			// something bad happened, or the server disconnected
 		}
 
-		oldtime = host.dirtytime;
-		newtime = Sys_DirtyTime();
+		newtime = host.dirtytime = Sys_DirtyTime();
 		time = newtime - oldtime;
 		if (time < 0)
 		{
@@ -439,10 +438,6 @@ void Host_Main(void)
 			time = 0;
 		}
 		host.realtime += time;
-		host.dirtytime = newtime;
-
-		cl_timer += time;
-		sv_timer += time;
 
 		if (host_framerate.value < 0.00001 && host_framerate.value != 0)
 			Cvar_SetValueQuick(&host_framerate, 0);
@@ -660,6 +655,8 @@ void Host_Main(void)
 			sv_timer = 0;
 		}
 
+		sv_timer += time;
+
 	//-------------------
 	//
 	// client operations
@@ -804,6 +801,8 @@ void Host_Main(void)
 		if (cl_timer >= 0)
 			cl_timer = 0;
 
+		cl_timer += time;
+
 #if MEMPARANOIA
 		Mem_CheckSentinelsGlobal();
 #else
@@ -812,6 +811,7 @@ void Host_Main(void)
 #endif
 
 		host.framecount++;
+		oldtime = newtime;
 	}
 
 	Sys_Quit(0);