From c13a46b7e98aa7a9a161ffb2c967d9e89ae61bf8 Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 2 Apr 2005 18:25:26 +0000 Subject: [PATCH] rewrote parts of Host_ServerFrame to make host_framerate cvar work again for The Ascension Of Vigil git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5142 d7cf8633-e32d-0410-b094-e92efae38249 --- host.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/host.c b/host.c index 19bd12ad..b771602c 100644 --- a/host.c +++ b/host.c @@ -670,30 +670,28 @@ void Host_ServerFrame (void) { // never run more than 5 frames at a time as a sanity limit int framecount, framelimit = 5; - double advancetime, newtime; + double advancetime; if (!sv.active) + { + sv.timer = 0; return; - newtime = Sys_DoubleTime(); - // if this is the first frame of a new server, ignore the huge time difference - if (!sv.timer) - sv.timer = newtime; - // if we're already past the new time, don't run a frame - // (does not happen if cl.islocalgame) - if (sv.timer > newtime) - return; + } + sv.timer += host_realframetime; // run the world state // don't allow simulation to run too fast or too slow or logic glitches can occur - for (framecount = 0;framecount < framelimit && sv.timer < newtime;framecount++) + for (framecount = 0;framecount < framelimit && sv.timer > 0;framecount++) { if (cl.islocalgame) - advancetime = min(newtime - sv.timer, sys_ticrate.value); + advancetime = min(sv.timer, sys_ticrate.value); else advancetime = sys_ticrate.value; - sv.timer += advancetime; + sv.timer -= advancetime; // only advance time if not paused // the game also pauses in singleplayer when menu or console is used sv.frametime = advancetime * slowmo.value; + if (host_framerate.value) + sv.frametime = host_framerate.value; if (sv.paused || (cl.islocalgame && (key_dest != key_game || key_consoleactive))) sv.frametime = 0; @@ -720,8 +718,8 @@ void Host_ServerFrame (void) NetConn_Heartbeat(0); } // if we fell behind too many frames just don't worry about it - if (sv.timer < newtime) - sv.timer = newtime; + if (sv.timer > 0) + sv.timer = 0; } -- 2.39.2