Merge pull request #7262 from furo321/expire-server-info-afk

Expire server info when changing `m_Afk`
This commit is contained in:
Dennis Felsing 2023-09-27 10:44:55 +00:00 committed by GitHub
commit 6a030e1a2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -219,7 +219,7 @@ void CPlayer::Tick()
if(Server()->GetNetErrorString(m_ClientID)[0]) if(Server()->GetNetErrorString(m_ClientID)[0])
{ {
m_Afk = true; SetAfk(true);
char aBuf[512]; char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' would have timed out, but can use timeout protection now", Server()->ClientName(m_ClientID)); str_format(aBuf, sizeof(aBuf), "'%s' would have timed out, but can use timeout protection now", Server()->ClientName(m_ClientID));
@ -705,11 +705,14 @@ void CPlayer::UpdatePlaytime()
void CPlayer::AfkTimer() void CPlayer::AfkTimer()
{ {
m_Afk = g_Config.m_SvMaxAfkTime != 0 && m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkTime; SetAfk(g_Config.m_SvMaxAfkTime != 0 && m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkTime);
} }
void CPlayer::SetAfk(bool Afk) void CPlayer::SetAfk(bool Afk)
{ {
if(m_Afk != Afk)
Server()->ExpireServerInfo();
if(g_Config.m_SvMaxAfkTime == 0) if(g_Config.m_SvMaxAfkTime == 0)
{ {
m_Afk = false; m_Afk = false;