-// run the world state
- if (!sv.paused && (!cl.islocalgame || (key_dest == key_game && !key_consoleactive)))
- sv.frametime = pr_global_struct->frametime = frametimetotal;
- else
- sv.frametime = 0;
- frametimetotal = 0;
- lastservertime = realtime;
+ // 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 > 0;framecount++)
+ {
+ // setup the VM frame
+ SV_VM_Begin();
+
+ if (cl.islocalgame)
+ advancetime = min(sv.timer, sys_ticrate.value);
+ else
+ advancetime = sys_ticrate.value;
+ 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;
+
+ // set the time and clear the general datagram
+ SV_ClearDatagram();
+
+ // check for network packets to the server each world step incase they
+ // come in midframe (particularly if host is running really slow)
+ NetConn_ServerFrame();
+
+ // move things around and think unless paused
+ if (sv.frametime)
+ SV_Physics();