Fix afk timer not working.

This commit is contained in:
furo 2023-10-30 19:43:35 +01:00
parent 28f4739e46
commit 0ecc50ae0f
3 changed files with 10 additions and 3 deletions

View file

@ -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

View file

@ -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)

View file

@ -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;