Merge pull request #7491 from furo321/fix-lastkickvote

Fix some issues with `sv_vote_kick_delay`.
This commit is contained in:
Dennis Felsing 2023-11-18 12:31:35 +00:00 committed by GitHub
commit 8ab9e72240
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2187,21 +2187,18 @@ void CGameContext::OnCallVoteNetMessage(const CNetMsg_Cl_CallVote *pMsg, int Cli
else if(str_comp_nocase(pMsg->m_pType, "kick") == 0) else if(str_comp_nocase(pMsg->m_pType, "kick") == 0)
{ {
int Authed = Server()->GetAuthedState(ClientID); int Authed = Server()->GetAuthedState(ClientID);
if(!Authed && time_get() < m_apPlayers[ClientID]->m_Last_KickVote + (time_freq() * 5))
if(!g_Config.m_SvVoteKick && !Authed) // allow admins to call kick votes even if they are forbidden
{
SendChatTarget(ClientID, "Server does not allow voting to kick players");
return; return;
else if(!Authed && time_get() < m_apPlayers[ClientID]->m_Last_KickVote + (time_freq() * g_Config.m_SvVoteKickDelay)) }
if(!Authed && time_get() < m_apPlayers[ClientID]->m_Last_KickVote + (time_freq() * g_Config.m_SvVoteKickDelay))
{ {
str_format(aChatmsg, sizeof(aChatmsg), "There's a %d second wait time between kick votes for each player please wait %d second(s)", str_format(aChatmsg, sizeof(aChatmsg), "There's a %d second wait time between kick votes for each player please wait %d second(s)",
g_Config.m_SvVoteKickDelay, g_Config.m_SvVoteKickDelay,
(int)(((m_apPlayers[ClientID]->m_Last_KickVote + (m_apPlayers[ClientID]->m_Last_KickVote * time_freq())) / time_freq()) - (time_get() / time_freq()))); (int)((m_apPlayers[ClientID]->m_Last_KickVote + g_Config.m_SvVoteKickDelay * time_freq() - time_get()) / time_freq()));
SendChatTarget(ClientID, aChatmsg); SendChatTarget(ClientID, aChatmsg);
m_apPlayers[ClientID]->m_Last_KickVote = time_get();
return;
}
else if(!g_Config.m_SvVoteKick && !Authed) // allow admins to call kick votes even if they are forbidden
{
SendChatTarget(ClientID, "Server does not allow voting to kick players");
m_apPlayers[ClientID]->m_Last_KickVote = time_get();
return; return;
} }
@ -2263,7 +2260,6 @@ void CGameContext::OnCallVoteNetMessage(const CNetMsg_Cl_CallVote *pMsg, int Cli
if(KickedAuthed > Authed) if(KickedAuthed > Authed)
{ {
SendChatTarget(ClientID, "You can't kick authorized players"); SendChatTarget(ClientID, "You can't kick authorized players");
m_apPlayers[ClientID]->m_Last_KickVote = time_get();
char aBufKick[128]; char aBufKick[128];
str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID)); str_format(aBufKick, sizeof(aBufKick), "'%s' called for vote to kick you", Server()->ClientName(ClientID));
SendChatTarget(KickID, aBufKick); SendChatTarget(KickID, aBufKick);
@ -2274,7 +2270,6 @@ void CGameContext::OnCallVoteNetMessage(const CNetMsg_Cl_CallVote *pMsg, int Cli
if(!GetPlayerChar(ClientID) || !GetPlayerChar(KickID) || GetDDRaceTeam(ClientID) != GetDDRaceTeam(KickID)) if(!GetPlayerChar(ClientID) || !GetPlayerChar(KickID) || GetDDRaceTeam(ClientID) != GetDDRaceTeam(KickID))
{ {
SendChatTarget(ClientID, "You can kick only your team member"); SendChatTarget(ClientID, "You can kick only your team member");
m_apPlayers[ClientID]->m_Last_KickVote = time_get();
return; return;
} }