]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve autopause for singleplayer/listen and enable it by default
authorbones_was_here <bones_was_here@xonotic.au>
Sun, 19 Mar 2023 16:50:34 +0000 (02:50 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 19 Mar 2023 16:50:34 +0000 (02:50 +1000)
This will pause if all clients are in menu/console/chat.  It considers
spectators because otherwise they cannot join the match if the current
player(s) are in menu/console/chat.

Disables snd_cdautopause by default which will only take effect in
current DP.

Closes #2670

qcsrc/server/main.qc
xonotic-client.cfg
xonotic-server.cfg

index bb75f5aa2f39e0acfd22eb55754db159a3b3eb18..8a2da54aa4a721c2312017b0bd30ae52bd72e561 100644 (file)
@@ -192,20 +192,29 @@ void Pause_TryPause_Dedicated(entity this)
                setpause(1);
 }
 
-void Pause_TryPause(bool ispaused)
+void Pause_TryPause()
 {
-       int n = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && IS_REAL_CLIENT(it), {
-               if (PHYS_INPUT_BUTTON_CHAT(it) != ispaused) return;
+       int n = 0, p = 0;
+       FOREACH_CLIENT(IS_REAL_CLIENT(it), {
+               if (PHYS_INPUT_BUTTON_CHAT(it)) ++p;
                ++n;
        });
        if (!n) return;
-       setpause(ispaused);
+       if (n == p)
+               setpause(1);
+       else
+               setpause(0);
 }
 
 void SV_PausedTic(float elapsedtime)
 {
-       if (!server_is_dedicated) Pause_TryPause(false);
+       if (!server_is_dedicated)
+       {
+               if (autocvar_sv_autopause)
+                       Pause_TryPause();
+               else
+                       setpause(0);
+       }
 }
 
 void dedicated_print(string input)
@@ -283,7 +292,7 @@ void StartFrame()
     IL_EACH(g_players, IS_FAKE_CLIENT(it), PlayerPreThink(it));
 
        execute_next_frame();
-       if (autocvar_sv_autopause && !server_is_dedicated) Pause_TryPause(true);
+       if (autocvar_sv_autopause && !server_is_dedicated) Pause_TryPause();
 
        delete_fn = remove_unsafely; // not during spawning!
        serverprevtime = servertime;
index 22792e06ef6e6e15bb011be78d95f9d59dd1940c..4bb3f1fdffe8878016d23623137c58327d7b598a 100644 (file)
@@ -348,6 +348,8 @@ seta cl_announcer default "name of the announcer you wish to use from data/sound
 seta cl_announcer_antispam 2 "number of seconds before an announcement of the same sound can be played again"
 seta cl_announcer_maptime 3 "play announcer sound telling you the remaining maptime - 0: do not play at all, 1: play at one minute, 2: play at five minutes, 3: play both"
 
+set snd_cdautopause 0
+
 // aliases:
 alias +fire +attack
 alias -fire -attack
index 511887ec14ed8cbff08d500300a3d66f3d8ee5ec..2b04015a470aec6fff93e9170b10de0dbf2b8caa 100644 (file)
@@ -51,7 +51,7 @@ set sv_timeout_number 2 "how many timeouts one player is allowed to call (gets r
 set sv_timeout_leadtime 4 "how long the players will be informed that a timeout was called before it starts, in seconds"
 set sv_timeout_resumetime 3 "how long the remaining timeout-time will be after a player called the timein command"
 
-set sv_autopause 0 "Single player: pause while the menu or console is open. Dedicated server: pause after starting a map if the server is empty and unpause when the first player joins the empty server."
+set sv_autopause 1 "Single player or listen server: pause while all clients have the menu, console or chat open. Dedicated server: pause after starting a map if the server is empty and unpause when the first player joins the empty server."
 
 set g_telefrags 1 "telefragging, i.e. killing someone who stands in the way of someone who is teleporting"
 set g_telefrags_teamplay 1 "never telefrag team mates"