Add afk vote timer

This commit is contained in:
def 2013-08-18 03:27:30 +02:00
parent a54c035e36
commit a2c7feda17
4 changed files with 32 additions and 0 deletions

View file

@ -199,6 +199,7 @@ MACRO_CONFIG_INT(ClShowQuads, cl_show_quads, 1, 0, 1, CFGFLAG_CLIENT|CFGFLAG_SAV
MACRO_CONFIG_INT(ClBackground, cl_background, 0, 0, 0xFFFFFF, CFGFLAG_CLIENT|CFGFLAG_SAVE, "Show background")
MACRO_CONFIG_INT(SvShowOthers, sv_show_others, 1, 0, 1, CFGFLAG_SERVER, "Whether players can user the command showothers or not")
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, "How far will the plasma gun track tees")
MACRO_CONFIG_INT(SvPlasmaPerSec, sv_plasma_per_sec, 3, 0, 50, CFGFLAG_SERVER, "How many shots does the plasma gun fire per seconds")
MACRO_CONFIG_INT(SvVotePause, sv_vote_pause, 1, 0, 1, CFGFLAG_SERVER, "Allow voting to pause players (instead of moving to spectators)")

View file

@ -516,6 +516,9 @@ void CGameContext::OnTick()
GetPlayerChar(m_VoteCreator)->Team() != GetPlayerChar(i)->Team())
continue;
if (m_apPlayers[i]->m_Afk)
continue;
int ActVote = m_apPlayers[i]->m_Vote;
int ActVotePos = m_apPlayers[i]->m_VotePos;

View file

@ -42,6 +42,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
m_EyeEmote = true;
m_TimerType = g_Config.m_SvDefaultTimerType;
m_DefEmote = EMOTE_NORMAL;
m_Afk = false;
//New Year
if (g_Config.m_SvEvents)
@ -273,6 +274,8 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
{
if (AfkTimer(NewInput->m_TargetX, NewInput->m_TargetY))
return; // we must return if kicked, as player struct is already deleted
AfkVoteTimer(NewInput->m_TargetX, NewInput->m_TargetY);
if(NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING)
{
// skip the input if chat is active
@ -450,6 +453,29 @@ bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY)
return false;
}
void CPlayer::AfkVoteTimer(int NewTargetX, int NewTargetY)
{
if(g_Config.m_SvMaxAfkVoteTime == 0)
return;
if(NewTargetX != m_LastTarget_x || NewTargetY != m_LastTarget_y)
{
m_LastPlaytime = time_get();
m_LastTarget_x = NewTargetX;
m_LastTarget_y = NewTargetY;
m_Sent1stAfkWarning = 0; // afk timer's 1st warning after 50% of sv_max_afk_time
m_Sent2ndAfkWarning = 0;
}
else if(m_LastPlaytime < time_get()-time_freq()*g_Config.m_SvMaxAfkVoteTime)
{
CServer* serv = (CServer*)m_pGameServer->Server();
m_Afk = true;
return;
}
m_Afk = false;
}
void CPlayer::ProcessPause()
{
char aBuf[128];

View file

@ -133,10 +133,12 @@ public:
int m_Authed;
bool m_IsUsingDDRaceClient;
bool m_ShowOthers;
bool m_Afk;
int m_ChatScore;
bool AfkTimer(int new_target_x, int new_target_y); //returns true if kicked
void AfkVoteTimer(int new_target_x, int new_target_y);
int64 m_LastPlaytime;
int64 m_LastEyeEmote;
int m_LastTarget_x;