]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
sv_maxidle*: Give players longer warning countdowns for longer timeouts
authorbones_was_here <bones_was_here@xa.org.au>
Sun, 18 Apr 2021 10:05:49 +0000 (20:05 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Sun, 18 Apr 2021 11:03:07 +0000 (21:03 +1000)
1/3 of timeout, or 10s, whichever is greater

qcsrc/server/client.qc

index d752eea3690680cbb2e8f31a7a73864a8aa49dbc..c6c1ecf12a46712b6b21f2e90d9120a81c4b5afe 100644 (file)
@@ -2728,14 +2728,13 @@ void PlayerPostThink (entity this)
                        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)
-                               {
-                                       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);
-                               }
+                       float countdown_time = max(min(10, maxidle_time - 1), ceil(maxidle_time * 0.33)); // - 1 to support maxidle_time <= 10
+                       if (timeleft == countdown_time && !CS(this).idlekick_lasttimeleft)
+                       {
+                               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) {
                                if (IS_PLAYER(this) && autocvar_sv_maxidle_playertospectator > 0)
@@ -2752,8 +2751,8 @@ void PlayerPostThink (entity this)
                                }
                                return;
                        }
-                       else if (timeleft <= 10) {
-                               if (timeleft != CS(this).idlekick_lasttimeleft)
+                       else if (timeleft <= countdown_time) {
+                               if (timeleft != CS(this).idlekick_lasttimeleft && timeleft <= 10)
                                        Send_Notification(NOTIF_ONE, this, MSG_ANNCE, Announcer_PickNumber(CNT_IDLE, timeleft));
                                CS(this).idlekick_lasttimeleft = timeleft;
                        }