From 139f210e38ca520cfde5a46bc4409606ca6301f2 Mon Sep 17 00:00:00 2001 From: Zwip-Zwap Zapony <ZwipZwapZapony@gmail.com> Date: Sun, 26 Nov 2023 16:02:52 +0100 Subject: [PATCH] Update player->quittime while a server is idling --- src/netcode/d_clisrv.c | 29 +++++++++++++++++++++++++++++ src/p_tick.c | 16 +--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/netcode/d_clisrv.c b/src/netcode/d_clisrv.c index 7804b068f7..3e401105fd 100644 --- a/src/netcode/d_clisrv.c +++ b/src/netcode/d_clisrv.c @@ -1275,6 +1275,7 @@ static void UpdatePingTable(void) } } +// Handle idle and disconnected player timers static void IdleUpdate(void) { INT32 i; @@ -1297,7 +1298,35 @@ static void IdleUpdate(void) } } else + { players[i].lastinputtime = 0; + + if (players[i].quittime && playeringame[i]) + { + players[i].quittime++; + + if (players[i].quittime == 30 * TICRATE && G_TagGametype()) + P_CheckSurvivors(); + + if (server && players[i].quittime >= (tic_t)FixedMul(cv_rejointimeout.value, 60 * TICRATE) + && !(players[i].quittime % TICRATE)) + { + boolean send = false; // Only broadcast the kick if any nodes are connected + for (INT32 j = 1; j < MAXNETNODES; j++) + { + if (netnodes[j].ingame) + { + send = true; + break; + } + } + if (send) + SendKick(i, KICK_MSG_PLAYER_QUIT); + else // If the server is empty, don't send a NetXCmd - that would wake an idling dedicated server + CL_RemovePlayer(i, KICK_MSG_PLAYER_QUIT); + } + } + } } } diff --git a/src/p_tick.c b/src/p_tick.c index 1bc7b78bf1..3934890f19 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -690,25 +690,11 @@ void P_Ticker(boolean run) { INT32 i; - // Increment jointime and quittime even if paused + // Increment jointime even if paused for (i = 0; i < MAXPLAYERS; i++) if (playeringame[i]) - { players[i].jointime++; - if (players[i].quittime) - { - players[i].quittime++; - - if (players[i].quittime == 30 * TICRATE && G_TagGametype()) - P_CheckSurvivors(); - - if (server && players[i].quittime >= (tic_t)FixedMul(cv_rejointimeout.value, 60 * TICRATE) - && !(players[i].quittime % TICRATE)) - SendKick(i, KICK_MSG_PLAYER_QUIT); - } - } - if (objectplacing) { if (OP_FreezeObjectplace()) -- GitLab