From 0ecc50ae0f6eee7e54003c19dabe32d06f65e134 Mon Sep 17 00:00:00 2001 From: furo Date: Mon, 30 Oct 2023 19:43:35 +0100 Subject: [PATCH] Fix afk timer not working. --- src/game/server/gamecontext.cpp | 2 +- src/game/server/player.cpp | 10 ++++++++-- src/game/server/player.h | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index bb4520a75..9c102fec3 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1612,7 +1612,7 @@ void CGameContext::OnClientConnected(int ClientID, void *pData) if(m_apPlayers[ClientID]) delete m_apPlayers[ClientID]; m_apPlayers[ClientID] = new(ClientID) CPlayer(this, NextUniqueClientID, ClientID, StartTeam); - m_apPlayers[ClientID]->SetAfk(Afk); + m_apPlayers[ClientID]->SetInitialAfk(Afk); NextUniqueClientID += 1; #ifdef CONF_DEBUG diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index dbad705d2..054c9800f 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -714,15 +714,21 @@ void CPlayer::AfkTimer() void CPlayer::SetAfk(bool Afk) { if(m_Afk != Afk) + { Server()->ExpireServerInfo(); + m_Afk = Afk; + } +} +void CPlayer::SetInitialAfk(bool Afk) +{ if(g_Config.m_SvMaxAfkTime == 0) { - m_Afk = false; + SetAfk(false); return; } - m_Afk = Afk; + SetAfk(Afk); // Ensure that the AFK state is not reset again automatically if(Afk) diff --git a/src/game/server/player.h b/src/game/server/player.h index 651cc5e62..2ddbf23ff 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -193,6 +193,7 @@ public: void UpdatePlaytime(); void AfkTimer(); void SetAfk(bool Afk); + void SetInitialAfk(bool Afk); bool IsAfk() const { return m_Afk; } int64_t m_LastPlaytime;