Remove obsolete AfkTimer function

This commit is contained in:
Arda Demir 2022-06-11 20:26:24 +03:00
parent 425f07c03d
commit 18ab88d33e
3 changed files with 0 additions and 64 deletions

View file

@ -331,7 +331,6 @@ MACRO_CONFIG_INT(ClBackgroundShowTilesLayers, cl_background_show_tiles_layers, 0
MACRO_CONFIG_INT(SvShowOthers, sv_show_others, 1, 0, 1, CFGFLAG_SERVER, "Whether players can use the command showothers or not")
MACRO_CONFIG_INT(SvShowOthersDefault, sv_show_others_default, 0, 0, 2, CFGFLAG_SERVER | CFGFLAG_GAME, "Whether players see others by default (2 for own team)")
MACRO_CONFIG_INT(SvShowAllDefault, sv_show_all_default, 0, 0, 1, CFGFLAG_SERVER, "Whether players see all tees by default")
MACRO_CONFIG_INT(SvMaxAfkTime, sv_max_afk_time, 0, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player is allowed to be afk (0 = disabled)")
MACRO_CONFIG_INT(SvMaxAfkVoteTime, sv_max_afk_vote_time, 300, 0, 9999, CFGFLAG_SERVER, "The time in seconds a player can be afk and his votes still count (0 = disabled)")
MACRO_CONFIG_INT(SvPlasmaRange, sv_plasma_range, 700, 1, 99999, CFGFLAG_SERVER | CFGFLAG_GAME, "How far will the plasma gun track tees")
MACRO_CONFIG_INT(SvPlasmaPerSec, sv_plasma_per_sec, 3, 0, 50, CFGFLAG_SERVER | CFGFLAG_GAME, "How many shots does the plasma gun fire per seconds")

View file

@ -57,7 +57,6 @@ void CPlayer::Reset()
m_LastCommandPos = 0;
m_LastPlaytime = 0;
mem_zero(m_SentAfkWarning, sizeof(m_SentAfkWarning));
m_ChatScore = 0;
m_Moderating = false;
m_EyeEmoteEnabled = true;
@ -527,8 +526,6 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
if(NewInput->m_PlayerFlags)
Server()->SetClientFlags(m_ClientID, NewInput->m_PlayerFlags);
if(AfkTimer(NewInput))
return; // we must return if kicked, as player struct is already deleted
AfkVoteTimer(NewInput);
if(((!m_pCharacter && m_Team == TEAM_SPECTATORS) || m_Paused) && m_SpectatorID == SPEC_FREEVIEW)
@ -693,59 +690,6 @@ void CPlayer::TryRespawn()
m_pCharacter->SetSolo(true);
}
bool CPlayer::AfkTimer(CNetObj_PlayerInput *pNewTarget)
{
/*
afk timer (x, y = mouse coordinates)
Since a player has to move the mouse to play, this is a better method than checking
the player's position in the game world, because it can easily be bypassed by just locking a key.
Frozen players could be kicked as well, because they can't move.
It also works for spectators.
returns true if kicked
*/
if(Server()->GetAuthedState(m_ClientID))
return false; // don't kick admins
if(g_Config.m_SvMaxAfkTime == 0)
return false; // 0 = disabled
if(pNewTarget->m_TargetX != m_pLastTarget->m_TargetX || pNewTarget->m_TargetY != m_pLastTarget->m_TargetY)
{
UpdatePlaytime();
// we shouldn't update m_pLastTarget here
mem_zero(m_SentAfkWarning, sizeof(m_SentAfkWarning)); // resetting warnings
}
else
{
if(!m_Paused)
{
// kick if player stays afk too long
if(m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkTime)
{
m_pGameServer->Server()->Kick(m_ClientID, "Away from keyboard");
return true;
}
// not playing, check how long
for(int i = 0; i < 2; i++)
{
int AfkTime = (int)(g_Config.m_SvMaxAfkTime * (i == 0 ? 0.5 : 0.9));
if(!m_SentAfkWarning[i] && m_LastPlaytime < time_get() - time_freq() * AfkTime)
{
char aAfkMsg[160];
str_format(aAfkMsg, sizeof(aAfkMsg),
"You have been afk for %d seconds now. Please note that you get kicked after not playing for %d seconds.",
AfkTime,
g_Config.m_SvMaxAfkTime);
m_pGameServer->SendChatTarget(m_ClientID, aAfkMsg);
m_SentAfkWarning[i] = true;
break;
}
}
}
}
return false;
}
void CPlayer::UpdatePlaytime()
{
m_LastPlaytime = time_get();

View file

@ -179,7 +179,6 @@ public:
bool m_Moderating;
bool AfkTimer(CNetObj_PlayerInput *pNewTarget); // returns true if kicked
void UpdatePlaytime();
void AfkVoteTimer(CNetObj_PlayerInput *pNewTarget);
int64_t m_LastPlaytime;
@ -189,12 +188,6 @@ public:
CNetObj_PlayerInput *m_pLastTarget;
bool m_LastTargetInit;
/*
afk timer's 1st warning after 50% of sv_max_afk_time
2nd warning after 90%
kick after reaching 100% of sv_max_afk_time
*/
bool m_SentAfkWarning[2];
bool m_EyeEmoteEnabled;
int m_TimerType;