diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 8b07cc7d0..d3983d0ae 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -1702,6 +1702,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) if(Length == 0 || (pMsg->m_pMessage[0] != '/' && (g_Config.m_SvSpamprotection && pPlayer->m_LastChat && pPlayer->m_LastChat + Server()->TickSpeed() * ((31 + Length) / 32) > Server()->Tick()))) return; + pPlayer->UpdatePlaytime(); + int GameTeam = ((CGameControllerDDRace *)m_pController)->m_Teams.m_Core.Team(pPlayer->GetCID()); if(Team) Team = ((pPlayer->GetTeam() == -1) ? CHAT_SPEC : GameTeam); @@ -1779,6 +1781,8 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) if(RateLimitPlayerVote(ClientID) || m_VoteCloseTime) return; + m_apPlayers[ClientID]->UpdatePlaytime(); + m_VoteType = VOTE_TYPE_UNKNOWN; char aChatmsg[512] = {0}; char aDesc[VOTE_DESC_LENGTH] = {0}; @@ -2035,6 +2039,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) int64 Now = Server()->Tick(); pPlayer->m_LastVoteTry = Now; + pPlayer->UpdatePlaytime(); CNetMsg_Cl_Vote *pMsg = (CNetMsg_Cl_Vote *)pRawMsg; if(!pMsg->m_Vote) @@ -2144,6 +2149,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) return; pPlayer->m_LastSetSpectatorMode = Server()->Tick(); + pPlayer->UpdatePlaytime(); if(pMsg->m_SpectatorID >= 0 && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS)) SendChatTarget(ClientID, "Invalid spectator id used"); else @@ -2162,6 +2168,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) return; } pPlayer->m_LastChangeInfo = Server()->Tick(); + pPlayer->UpdatePlaytime(); // set infos char aOldName[MAX_NAME_LENGTH]; @@ -2252,6 +2259,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID) return; pPlayer->m_LastEmote = Server()->Tick(); + pPlayer->UpdatePlaytime(); SendEmoticon(ClientID, pMsg->m_Emoticon); CCharacter *pChr = pPlayer->GetCharacter(); diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index a57502cf2..1546fa267 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -744,7 +744,7 @@ bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY) if(NewTargetX != m_LastTarget_x || NewTargetY != m_LastTarget_y) { - m_LastPlaytime = time_get(); + UpdatePlaytime(); m_LastTarget_x = NewTargetX; m_LastTarget_y = NewTargetY; m_Sent1stAfkWarning = 0; // afk timer's 1st warning after 50% of sv_max_afk_time @@ -783,6 +783,11 @@ bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY) return false; } +void CPlayer::UpdatePlaytime() +{ + m_LastPlaytime = time_get(); +} + void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget) { if(g_Config.m_SvMaxAfkVoteTime == 0) @@ -797,7 +802,7 @@ void CPlayer::AfkVoteTimer(CNetObj_PlayerInput *NewTarget) } else if(mem_comp(NewTarget, m_pLastTarget, sizeof(CNetObj_PlayerInput)) != 0) { - m_LastPlaytime = time_get(); + UpdatePlaytime(); mem_copy(m_pLastTarget, NewTarget, sizeof(CNetObj_PlayerInput)); } else if(m_LastPlaytime < time_get() - time_freq() * g_Config.m_SvMaxAfkVoteTime) diff --git a/src/game/server/player.h b/src/game/server/player.h index 9c88af166..4fcd01065 100644 --- a/src/game/server/player.h +++ b/src/game/server/player.h @@ -174,6 +174,7 @@ public: bool m_Moderating; bool AfkTimer(int new_target_x, int new_target_y); //returns true if kicked + void UpdatePlaytime(); void AfkVoteTimer(CNetObj_PlayerInput *NewTarget); int64 m_LastPlaytime; int64 m_LastEyeEmote;