X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=host.c;h=b771602ca7b4382748fa54aacd68f54bdb096e32;hb=e40a37e7e99114e259dffe2e36416f0c238a6b40;hp=a4debb6293c83c45188c87da746c131ddc139d97;hpb=a84da20a7afb7f838f69123b47e6a451d3426e88;p=xonotic%2Fdarkplaces.git diff --git a/host.c b/host.c index a4debb62..b771602c 100644 --- a/host.c +++ b/host.c @@ -278,9 +278,10 @@ void Host_SaveConfig_f(void) // dedicated servers initialize the host but don't parse and set the // config.cfg cvars - if (host_initialized && cls.state != ca_dedicated) + // LordHavoc: save a config only after Host_Frame finished the first frame + if (host_initialized && host_loopactive && cls.state != ca_dedicated) { - f = FS_Open ("config.cfg", "wb", false); + f = FS_Open ("config.cfg", "wb", false, false); if (!f) { Con_Print("Couldn't write config.cfg.\n"); @@ -563,7 +564,7 @@ qboolean Host_FilterTime (double time) double timecap, timeleft; realtime += time; - if (sys_ticrate.value < 0.01 || sys_ticrate.value > 0.10001) + if (sys_ticrate.value < 0.00999 || sys_ticrate.value > 0.10001) Cvar_SetValue("sys_ticrate", bound(0.01, sys_ticrate.value, 0.1)); if (slowmo.value < 0) Cvar_SetValue("slowmo", 0); @@ -669,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; @@ -719,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; } @@ -942,6 +941,7 @@ void Host_Init (void) if (cls.state != ca_dedicated) { VID_Open(); + CDAudio_Startup(); CL_InitTEnts (); // We must wait after sound startup to load tent sounds SCR_BeginLoadingPlaque(); MR_Init(); @@ -977,15 +977,22 @@ void Host_Init (void) else Cbuf_InsertText("exec quake.rc\n"); + Cbuf_Execute(); + Cbuf_Execute(); + Cbuf_Execute(); + if (!sv.active && (cls.state == ca_dedicated || COM_CheckParm("-listen"))) Cbuf_InsertText ("startmap_dm\n"); // check for special benchmark mode // COMMANDLINEOPTION: Client: -benchmark runs a timedemo and quits, results of any timedemo can be found in gamedir/benchmark.log (for example id1/benchmark.log) i = COM_CheckParm("-benchmark"); - if (i && i + 1 < com_argc) + if (i && i + 1 < com_argc && !sv.active) Cbuf_InsertText(va("timedemo %s\n", com_argv[i + 1])); + if (!sv.active && !cls.demoplayback && !cls.connect_trying) + Cbuf_InsertText("togglemenu\n"); + Cbuf_Execute(); // We must wait for the log_file cvar to be initialized to start the log