]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/maxidle_fix' into 'master'
authorMario <mario.mario@y7mail.com>
Mon, 6 Sep 2021 10:43:50 +0000 (10:43 +0000)
committerMario <mario.mario@y7mail.com>
Mon, 6 Sep 2021 10:43:50 +0000 (10:43 +0000)
Maxidle fix

Closes #2615

See merge request xonotic/xonotic-data.pk3dir!925

qcsrc/server/client.qc
qcsrc/server/client.qh
ruleset-XDF.cfg
ruleset-XPM.cfg
xonotic-server.cfg

index a9758146f5dddfaca618b7ddc6b6a624fa7da1ef..dadc04b5bae7cda9766655e88f721ec846bd684f 100644 (file)
@@ -2643,14 +2643,30 @@ void PlayerPostThink (entity this)
                int totalClients = 0;
                if(autocvar_sv_maxidle > 0 && autocvar_sv_maxidle_slots > 0)
                {
-                       FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_maxidle_slots_countbots,
+                       // maxidle disabled in local matches by not counting clients (totalClients 0)
+                       if (server_is_dedicated)
+                       {
+                               FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_maxidle_slots_countbots,
+                               {
+                                       ++totalClients;
+                               });
+                               if (maxclients - totalClients > autocvar_sv_maxidle_slots)
+                                       totalClients = 0;
+                       }
+               }
+               else if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
+               {
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it),
                        {
                                ++totalClients;
                        });
                }
 
-               if (autocvar_sv_maxidle > 0 && autocvar_sv_maxidle_slots > 0 && (maxclients - totalClients) > autocvar_sv_maxidle_slots)
-               { /* do nothing */ }
+               if (totalClients < autocvar_sv_maxidle_minplayers)
+               {
+                       // idle kick disabled
+                       CS(this).parm_idlesince = time;
+               }
                else if (time - CS(this).parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10
                {
                        if (CS(this).idlekick_lasttimeleft)
index 3199d155a9c853c17d82cf67b5c26c3d7b467fe1..b7166609bd2f79f4c74010962c7aeb7c8dfbc7fc 100644 (file)
@@ -33,6 +33,7 @@ bool autocvar_g_nodepthtestplayers;
 string autocvar_g_mutatormsg;
 float autocvar_sv_foginterval;
 float autocvar_sv_maxidle;
+int autocvar_sv_maxidle_minplayers = 2;
 float autocvar_sv_maxidle_playertospectator = 60;
 bool autocvar_sv_maxidle_alsokickspectators;
 int autocvar_sv_maxidle_slots;
index 170c38d79a03e5c0cd06d639d5628ab424d341c9..7e7d308a09e26b2754aa7c02ec954f6b72e9fdff 100644 (file)
@@ -23,6 +23,7 @@ g_weapon_stay 1
 teamplay_mode 2 // friendly fire and self damage
 sv_vote_nospectators 1
 timelimit_override 20
+sv_maxidle_playertospectator 0
 
 // speed powerup (q3 haste replacement)
 g_movement_highspeed_q3_compat 1
index 817b9f1eafa092c450177aefe8b55b7879da74d0..0a89a01de5b125c024b66edc1cefaf09a83da091 100644 (file)
@@ -26,3 +26,4 @@ g_turrets 0
 g_vehicles 0
 sv_showspectators 0
 sv_taunt 0
+sv_maxidle_playertospectator 0
index 39323f0dc6fba66ed95c10acde291b1e4c40db1c..a6213cb24a48b6b13ce159ede2f57592c8d416f1 100644 (file)
@@ -418,7 +418,7 @@ set sv_maxidle 0 "kick players idle for more than this amount of time in seconds
 set sv_maxidle_alsokickspectators 1 "when sv_maxidle is > 0, kick idle spectators as well as players"
 set sv_maxidle_slots 0 "when not 0, only kick idlers when this many or less player slots are available"
 set sv_maxidle_slots_countbots 1 "count bots as player slots"
-
+set sv_maxidle_minplayers 2 "check for idlers only when there are at least this many players (only in dedicated servers)"
 set sv_maxidle_playertospectator 60 "move players idle for more than this amount of time in seconds to spectators (sv_maxidle timer starts again after sv_maxidle_playertospectator has moved a player to spectators)"
 
 sv_allowdownloads_inarchive 1 // for csprogs.dat