]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
sv_autopause: don't pause during intermission, unpause on endmatch command
authorbones_was_here <bones_was_here@xonotic.au>
Thu, 5 Oct 2023 15:16:46 +0000 (01:16 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Thu, 5 Oct 2023 15:16:46 +0000 (01:16 +1000)
qcsrc/server/main.qc
qcsrc/server/world.qc

index 0d36ea47ede68762063b9780ac487f3053c13582..d03edc9cb2b486e12a8f9f75ae1075a488eb3128 100644 (file)
@@ -187,12 +187,14 @@ void CreatureFrame_All()
        });
 }
 
+// called shortly after map change in dedicated
 void Pause_TryPause_Dedicated(entity this)
 {
-       if (player_count == 0)
+       if (player_count == 0 && !intermission_running && !autocvar__endmatch)
                setpause(1);
 }
 
+// called every normal frame in singleplayer/listen
 void Pause_TryPause()
 {
        int n = 0, p = 0;
@@ -207,9 +209,12 @@ void Pause_TryPause()
                setpause(0);
 }
 
+// called every paused frame by DP
 void SV_PausedTic(float elapsedtime)
 {
-       if (!server_is_dedicated)
+       if (autocvar__endmatch) // `endmatch` while paused
+               setpause(0); // proceed to intermission
+       else if (!server_is_dedicated)
        {
                if (autocvar_sv_autopause)
                        Pause_TryPause();
@@ -293,7 +298,6 @@ void StartFrame()
        IL_EACH(g_players, IS_FAKE_CLIENT(it), PlayerPreThink(it));
 
        execute_next_frame();
-       if (autocvar_sv_autopause && !server_is_dedicated) Pause_TryPause();
 
        delete_fn = remove_unsafely; // not during spawning!
        serverprevtime = servertime;
@@ -346,6 +350,10 @@ void StartFrame()
        CreatureFrame_All();
        CheckRules_World();
 
+       // after CheckRules_World() as it may set intermission_running, and after RedirectionThink() in case listen server is closing
+       if (autocvar_sv_autopause && !server_is_dedicated && !intermission_running)
+               Pause_TryPause();
+
        if (warmup_stage && !game_stopped && warmup_limit > 0 && time - game_starttime >= warmup_limit) {
                ReadyRestart(true);
                return;
index 311800dcd10eee8509b43ea99352d738835b0594..6e79c73ef1c014d1de388729a8de6f15fdbffd1f 100644 (file)
@@ -1063,7 +1063,7 @@ spawnfunc(worldspawn)
        WinningConditionHelper(this); // set worldstatus
 
        if (autocvar_sv_autopause && server_is_dedicated && !wantrestart)
-               // INITPRIO_LAST is to soon: bots either didn't join yet or didn't leave yet, see: bot_fixcount()
+               // INITPRIO_LAST is too soon: bots either didn't join yet or didn't leave yet, see: bot_fixcount()
                defer(this, 5, Pause_TryPause_Dedicated);
 
        world_initialized = 1;