From 436de2180831aec6b14de01e1aa61ba894c5c1ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Sat, 7 Oct 2023 00:07:56 +0200 Subject: [PATCH] Refactor code after review comments --- src/d_player.h | 1 + src/netcode/d_clisrv.c | 10 +++++----- src/netcode/d_net.h | 1 - 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 7ad5b9f81..ca700d4e1 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -607,6 +607,7 @@ typedef struct player_s tic_t jointime; // Timer when player joins game to change skin/color tic_t quittime; // Time elapsed since user disconnected, zero if connected + tic_t lastinputtime; // the last tic the player has made any input #ifdef HWRENDER fixed_t fovadd; // adjust FOV for hw rendering #endif diff --git a/src/netcode/d_clisrv.c b/src/netcode/d_clisrv.c index efa251ff7..4571930f8 100644 --- a/src/netcode/d_clisrv.c +++ b/src/netcode/d_clisrv.c @@ -1282,19 +1282,19 @@ static void IdleUpdate(void) for (i = 1; i < MAXPLAYERS; i++) { - if (cv_idletime.value && playeringame[i] && playernode[i] != UINT8_MAX && !players[i].quittime && !players[i].spectator && i != serverplayer) + if (cv_idletime.value && playeringame[i] && playernode[i] != UINT8_MAX && !players[i].quittime && !players[i].spectator && !IsPlayerAdmin(i)) { if (players[i].cmd.forwardmove || players[i].cmd.sidemove || players[i].cmd.buttons) - netnodes[i].lastinput = gametime; + players[i].lastinputtime = gametime; - if (gametime - netnodes[i].lastinput > cv_idletime.value * TICRATE) + if (gametime - players[i].lastinputtime > (tic_t)cv_idletime.value * TICRATE * 60) { - netnodes[i].lastinput = gametime; + players[i].lastinputtime = gametime; SendKick(i, KICK_MSG_IDLE | KICK_MSG_KEEP_BODY); } } else - netnodes[i].lastinput = gametime; + players[i].lastinputtime = gametime; } } diff --git a/src/netcode/d_net.h b/src/netcode/d_net.h index e8e3b5895..549f2b93c 100644 --- a/src/netcode/d_net.h +++ b/src/netcode/d_net.h @@ -43,7 +43,6 @@ typedef struct netnode_s { boolean ingame; // set false as nodes leave game tic_t freezetimeout; // Until when can this node freeze the server before getting a timeout? - tic_t lastinput; // the last tic the player has made any input SINT8 player; SINT8 player2; // say the numplayer for this node if any (splitscreen)