From: Mario Date: Fri, 24 Jun 2016 23:39:53 +0000 (+1000) Subject: Implement sv_maxidle_slots X-Git-Tag: xonotic-v0.8.2~700^2~127 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7716f00d0c63fe71ac8759049d8093919026d9aa;p=xonotic%2Fxonotic-data.pk3dir.git Implement sv_maxidle_slots --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index dea35012a..0c280744a 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -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 diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 3ba72b815..733b09355 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -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) { diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 8eea0dc20..d4aace83b 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -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); diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index 7cd8c7012..b6ddd3c6a 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -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");