]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
set sv_maxidle_playertospectator 0 "move players idle for more than this amount of... 893/head
authorterencehill <piuntn@gmail.com>
Thu, 15 Apr 2021 13:21:56 +0000 (15:21 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 16 Apr 2021 09:53:37 +0000 (11:53 +0200)
notifications.cfg
qcsrc/common/notifications/all.inc
qcsrc/ecs/systems/sv_physics.qc
qcsrc/server/client.qc
qcsrc/server/client.qh
xonotic-server.cfg

index 61fafdecbb81da8cc99453a2a8cd6e17261c3375..00c921ddbbc59009d4821941ca6d6efa54dfc9d4 100644 (file)
@@ -11,7 +11,7 @@
 // **                                          ** //
 // ********************************************** //
 
-// MSG_ANNCE notifications (count = 89):
+// MSG_ANNCE notifications (count = 90):
 seta notification_ANNCE_ACHIEVEMENT_AIRSHOT "1" "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
 seta notification_ANNCE_ACHIEVEMENT_AMAZING "1" "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
 seta notification_ANNCE_ACHIEVEMENT_AWESOME "1" "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
@@ -250,6 +250,7 @@ seta notification_INFO_LMS_FORFEIT "2" "0 = off, 1 = print to console, 2 = print
 seta notification_INFO_LMS_NOLIVES "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_MINIGAME_INVITE "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_MONSTERS_DISABLED "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
+seta notification_INFO_MOVETOSPEC_IDLING "2" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_NEXBALL_RETURN_HELD "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_ONSLAUGHT_CAPTURE "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_ONSLAUGHT_CAPTURE_NONAME "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
@@ -351,7 +352,7 @@ seta notification_INFO_WEAPON_TUBA_SUICIDE "1" "0 = off, 1 = print to console, 2
 seta notification_INFO_WEAPON_VAPORIZER_MURDER "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 seta notification_INFO_WEAPON_VORTEX_MURDER "1" "0 = off, 1 = print to console, 2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
 
-// MSG_CENTER notifications (count = 240):
+// MSG_CENTER notifications (count = 241):
 seta notification_CENTER_ALONE "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_ASSAULT_ATTACKING "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_ASSAULT_DEFENDING "1" "0 = off, 1 = centerprint"
@@ -492,6 +493,7 @@ seta notification_CENTER_LMS_NOLIVES "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_MISSING_PLAYERS "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_MISSING_TEAMS "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_MOTD "1" "0 = off, 1 = centerprint"
+seta notification_CENTER_MOVETOSPEC_IDLING "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_NADE_BONUS "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_NADE_THROW "1" "0 = off, 1 = centerprint"
 seta notification_CENTER_NIX_COUNTDOWN "1" "0 = off, 1 = centerprint"
@@ -754,4 +756,4 @@ seta notification_show_sprees_info "3" "Show spree information in MSG_INFO messa
 seta notification_show_sprees_info_newline "1" "Show attacker spree information for MSG_INFO messages on a separate line than the death notification itself"
 seta notification_show_sprees_info_specialonly "1" "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
 
-// Notification counts (total = 847): MSG_ANNCE = 89, MSG_INFO = 334, MSG_CENTER = 240, MSG_MULTI = 156, MSG_CHOICE = 28
+// Notification counts (total = 849): MSG_ANNCE = 90, MSG_INFO = 334, MSG_CENTER = 241, MSG_MULTI = 156, MSG_CHOICE = 28
index d692d73c8df82aa1f5463f31e03e50b20aeb8901..fd3f7ae07b3d77a83f2924ac72bf1c05e29467fa 100644 (file)
@@ -415,6 +415,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
 
     MSG_INFO_NOTIF(QUIT_DISCONNECT,                         N_CHATCON,  1, 0, "s1", "",         "",             _("^BG%s^F3 disconnected"), "")
     MSG_INFO_NOTIF(QUIT_KICK_IDLING,                        N_CHATCON,  1, 0, "s1", "",         "",             _("^BG%s^F3 was kicked for idling"), "")
+    MSG_INFO_NOTIF(MOVETOSPEC_IDLING,                       N_CHATCON,  1, 0, "s1", "",         "",             _("^BG%s^F3 was moved to spectator for idling"), "")
     MSG_INFO_NOTIF(QUIT_KICK_SPECTATING,                    N_CONSOLE,  0, 0, "", "",           "",             _("^F2You were kicked from the server because you are a spectator and spectators aren't allowed at the moment."), "")
     MSG_INFO_NOTIF(QUIT_KICK_TEAMKILL,                      N_CHATCON,  1, 0, "s1", "",         "",             _("^BG%s^F3 was kicked for excessive teamkilling"), "")
     MSG_INFO_NOTIF(QUIT_SPECTATE,                           N_CHATCON,  1, 0, "s1", "",         "",             _("^BG%s^F3 is now spectating"), "")
@@ -657,6 +658,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
     MSG_CENTER_NOTIF(DEATH_TEAMKILL_FRAGGED,            N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^K1You were fragged by ^BG%s^K1, a team mate"), _("^K1You were scored against by ^BG%s^K1, a team mate"))
 
     MSG_CENTER_NOTIF(DISCONNECT_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", _("^K1Stop idling!\n^BGDisconnecting in ^COUNT..."), "")
+    MSG_CENTER_NOTIF(MOVETOSPEC_IDLING,                 N_ENABLE,    0, 1, "",               CPID_IDLING,            "1 f1", _("^K1Stop idling!\n^BGMoving to spectator in ^COUNT..."), "")
 
     MSG_CENTER_NOTIF(DOOR_LOCKED_NEED,                  N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou need %s^BG!"), "")
     MSG_CENTER_NOTIF(DOOR_LOCKED_ALSONEED,              N_ENABLE,    1, 0, "s1",             CPID_Null,              "0 0",  _("^BGYou also need %s^BG!"), "")
index d0ce80c5bc588a625f7b41bedbfefd7891e382fa..1454d0049fe76b0d6211f0e98e7379b47bb20857 100644 (file)
@@ -26,7 +26,7 @@ void sys_phys_monitor(entity this, float dt)
 {
        int buttons = PHYS_INPUT_BUTTON_MASK(this);
        anticheat_physics(this);
-       if (autocvar_sv_maxidle > 0) {
+       if (autocvar_sv_maxidle > 0 || autocvar_sv_maxidle_playertospectator > 0) {
                if (buttons != CS(this).buttons_old
                    || CS(this).movement != CS(this).movement_old
                    || this.v_angle != CS(this).v_angle_old) { CS(this).parm_idlesince = time; }
index 4cabc469798f1b74c095b94b1c94df35fe7c5414..0f4a46bf90363381a73686c6af9fca20c632bdcf 100644 (file)
@@ -241,6 +241,13 @@ void PutObserverInServer(entity this)
 
        if (IS_PLAYER(this))
        {
+               if (autocvar_sv_maxidle_playertospectator > 0 && CS(this).idlekick_lasttimeleft)
+               {
+                       Kill_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CPID_IDLING);
+                       CS(this).idlekick_lasttimeleft = 0;
+                       CS(this).parm_idlesince = time;
+               }
+
                if(GetResource(this, RES_HEALTH) >= 1)
                {
                        // despawn effect
@@ -2710,13 +2717,13 @@ void PlayerPostThink (entity this)
 {
        Player_Physics(this);
 
-       if (autocvar_sv_maxidle > 0)
+       if (autocvar_sv_maxidle > 0 || (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0))
        if (frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
        if (IS_REAL_CLIENT(this))
        if (IS_PLAYER(this) || autocvar_sv_maxidle_spectatorsareidle)
        {
                int totalClients = 0;
-               if(autocvar_sv_maxidle_slots > 0)
+               if(autocvar_sv_maxidle > 0 && autocvar_sv_maxidle_slots > 0)
                {
                        FOREACH_CLIENT(IS_REAL_CLIENT(it) || autocvar_sv_maxidle_slots_countbots,
                        {
@@ -2724,7 +2731,7 @@ void PlayerPostThink (entity this)
                        });
                }
 
-               if (autocvar_sv_maxidle_slots > 0 && (maxclients - totalClients) > autocvar_sv_maxidle_slots)
+               if (autocvar_sv_maxidle > 0 && autocvar_sv_maxidle_slots > 0 && (maxclients - totalClients) > autocvar_sv_maxidle_slots)
                { /* do nothing */ }
                else if (time - CS(this).parm_idlesince < 1) // instead of (time == this.parm_idlesince) to support sv_maxidle <= 10
                {
@@ -2736,14 +2743,33 @@ void PlayerPostThink (entity this)
                }
                else
                {
-                       float timeleft = ceil(autocvar_sv_maxidle - (time - CS(this).parm_idlesince));
-                       if (timeleft == min(10, autocvar_sv_maxidle - 1)) { // - 1 to support sv_maxidle <= 10
+                       float maxidle_time = autocvar_sv_maxidle;
+                       if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
+                               maxidle_time = autocvar_sv_maxidle_playertospectator;
+                       float timeleft = ceil(maxidle_time - (time - CS(this).parm_idlesince));
+                       if (timeleft == min(10, maxidle_time - 1)) { // - 1 to support maxidle_time <= 10
                                if (!CS(this).idlekick_lasttimeleft)
-                                       Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_DISCONNECT_IDLING, timeleft);
+                               {
+                                       if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
+                                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOVETOSPEC_IDLING, timeleft);
+                                       else
+                                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_DISCONNECT_IDLING, timeleft);
+                               }
                        }
                        if (timeleft <= 0) {
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_IDLING, this.netname);
-                               dropclient(this);
+                               if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
+                               {
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_MOVETOSPEC_IDLING, this.netname);
+                                       if (this.caplayer)
+                                               this.caplayer = 0;
+                                       PutObserverInServer(this);
+                                       CS(this).parm_idlesince = time;
+                               }
+                               else
+                               {
+                                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_KICK_IDLING, this.netname);
+                                       dropclient(this);
+                               }
                                return;
                        }
                        else if (timeleft <= 10) {
index 43e041bf62769b30bccc58f1681af2cbac1732a0..4dd93563e42707bbae74ecc238e20541ed5e7cf9 100644 (file)
@@ -33,6 +33,7 @@ bool autocvar_g_nodepthtestplayers;
 string autocvar_g_mutatormsg;
 float autocvar_sv_foginterval;
 float autocvar_sv_maxidle;
+float autocvar_sv_maxidle_playertospectator;
 bool autocvar_sv_maxidle_spectatorsareidle;
 int autocvar_sv_maxidle_slots;
 bool autocvar_sv_maxidle_slots_countbots;
index 5399e4096ef20bba829cffc5f690a7030d038280..61592980721f18c7c5ddd86301ffd61c14efe88b 100644 (file)
@@ -416,6 +416,8 @@ set sv_maxidle_spectatorsareidle 0 "when sv_maxidle is not 0, assume spectators
 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_playertospectator 0 "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
 sv_allowdownloads 0 // download protocol is evil