Merge pull request #7394 from furo321/fix-setafk

Fix afk timer not working.
This commit is contained in:
Dennis Felsing 2023-10-30 23:03:17 +00:00 committed by GitHub
commit 2eff91083d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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

@ -711,15 +711,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;