]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement sv_maxidle_slots
authorMario <mario@smbclan.net>
Fri, 24 Jun 2016 23:39:53 +0000 (09:39 +1000)
committerMario <mario@smbclan.net>
Fri, 24 Jun 2016 23:39:53 +0000 (09:39 +1000)
defaultXonotic.cfg
qcsrc/server/cl_client.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qh

index dea35012a76a36546bfb922a8247b4ea67c904e4..0c280744afa9f18d8dc9c24bd3f594c6dea0211e 100644 (file)
@@ -1005,6 +1005,8 @@ seta menu_cdtrack "rising-of-the-phoenix"
 
 set sv_maxidle 0 "kick players idle for more than this amount of time in seconds"
 set sv_maxidle_spectatorsareidle 0 "when sv_maxidle is not 0, assume spectators are idle too"
+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"
 
 // these entities are not referenced by anything directly, they just represent
 // teams and are found by find() when needed
index 3ba72b815d9daf92f3790da2034359e9b57ce269..733b0935571b9f8b75d33fea219e04fba7c3a074 100644 (file)
@@ -2420,7 +2420,18 @@ void PlayerPostThink (entity this)
        if (IS_REAL_CLIENT(this))
        if (IS_PLAYER(this) || sv_maxidle_spectatorsareidle)
        {
-               if (time - this.parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10
+               int totalClients = 0;
+               if(sv_maxidle_slots > 0)
+               {
+                       FOREACH_CLIENT(IS_REAL_CLIENT(it) || sv_maxidle_slots_countbots,
+                       {
+                               ++totalClients;
+                       });
+               }
+
+               if (sv_maxidle_slots > 0 && (maxclients - totalClients) > sv_maxidle_slots)
+               { /* do nothing */ }
+               else if (time - this.parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10
                {
                        if (this.idlekick_lasttimeleft)
                        {
index 8eea0dc203d189b4e4007dfbe8f51a23ea63ba27..d4aace83b73be41a7c854f23818a4e6040cdb423 100644 (file)
@@ -253,6 +253,8 @@ float lockteams;
 .float parm_idlesince;
 float sv_maxidle;
 float sv_maxidle_spectatorsareidle;
+int sv_maxidle_slots;
+bool sv_maxidle_slots_countbots;
 
 float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end);
 
index 7cd8c70125fad2746935424ea3716d9af7560a4c..b6ddd3c6a17cfd76d37019e80330a51b93a6e16c 100644 (file)
@@ -256,6 +256,8 @@ void readlevelcvars()
        g_jetpack = cvar("g_jetpack");
        sv_maxidle = cvar("sv_maxidle");
        sv_maxidle_spectatorsareidle = cvar("sv_maxidle_spectatorsareidle");
+       sv_maxidle_slots = cvar("sv_maxidle_slots");
+       sv_maxidle_slots_countbots = cvar("sv_maxidle_slots_countbots");
        sv_autotaunt = cvar("sv_autotaunt");
        sv_taunt = cvar("sv_taunt");