From bbd8c31ea9339eb2d96cb05f34a034a18529d436 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Sun, 18 Apr 2021 20:05:49 +1000 Subject: [PATCH] sv_maxidle*: Give players longer warning countdowns for longer timeouts 1/3 of timeout, or 10s, whichever is greater --- qcsrc/server/client.qc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index d752eea36..c6c1ecf12 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; } -- 2.39.2