Add veto right for players with high time to stop map change votes

This commit is contained in:
def 2015-07-08 17:03:22 +02:00
parent 1f2b09303f
commit c79b4d3112
2 changed files with 26 additions and 6 deletions

View file

@ -194,6 +194,7 @@ MACRO_CONFIG_INT(SvVoteKickTimeDelay, sv_vote_kick_delay, 0, 0, 9999, CFGFLAG_SE
MACRO_CONFIG_INT(SvVoteYesPercentage, sv_vote_yes_percentage, 50, 1, 100, CFGFLAG_SERVER, "The percent of people that need to agree or deny for the vote to succeed/fail")
MACRO_CONFIG_INT(SvVoteMajority, sv_vote_majority, 0, 0, 1, CFGFLAG_SERVER, "Whether No. of Yes is compared to No. of No votes or to number of total Players ( Default is 0 Y compare N)")
MACRO_CONFIG_INT(SvVoteMaxTotal, sv_vote_max_total, 0, 0, MAX_CLIENTS, CFGFLAG_SERVER, "How many people can participate in a vote at max (0 = no limit by default)")
MACRO_CONFIG_INT(SvVoteVetoTime, sv_vote_veto_time, 20, 0, 1000, CFGFLAG_SERVER, "Minutes of game time until a player can veto map change votes (0 = disabled)")
MACRO_CONFIG_INT(SvSpectatorVotes, sv_spectator_votes, 1, 0, 1, CFGFLAG_SERVER, "Choose if spectators are allowed to start votes")
MACRO_CONFIG_INT(SvKillDelay, sv_kill_delay,3,0,9999,CFGFLAG_SERVER, "The minimum time in seconds between kills")
MACRO_CONFIG_INT(SvSuicidePenalty, sv_suicide_penalty,0,0,9999,CFGFLAG_SERVER, "The minimum time in seconds between kill or /kills and respawn")

View file

@ -612,6 +612,7 @@ void CGameContext::OnTick()
else
{
int Total = 0, Yes = 0, No = 0;
bool Veto = false, VetoStop = false;
if(m_VoteUpdate)
{
// count votes
@ -629,7 +630,7 @@ void CGameContext::OnTick()
aVoteChecked[i]) // don't count in votes by spectators if the admin doesn't want it
continue;
if(m_VoteKick && ((!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) ||
if((m_VoteKick || m_VoteSpec) && ((!m_apPlayers[i] || m_apPlayers[i]->GetTeam() == TEAM_SPECTATORS) ||
(GetPlayerChar(m_VoteCreator) && GetPlayerChar(i) &&
GetPlayerChar(m_VoteCreator)->Team() != GetPlayerChar(i)->Team())))
continue;
@ -659,24 +660,39 @@ void CGameContext::OnTick()
Yes++;
else if(ActVote < 0)
No++;
// veto right for players with much progress and who're not afk
if(!m_VoteKick && !m_VoteSpec && !m_apPlayers[i]->m_Afk &&
m_apPlayers[i]->GetTeam() != TEAM_SPECTATORS &&
m_apPlayers[i]->GetCharacter() &&
m_apPlayers[i]->GetCharacter()->m_DDRaceState == DDRACE_STARTED &&
g_Config.m_SvVoteVetoTime &&
(Server()->Tick() - m_apPlayers[i]->GetCharacter()->m_StartTime) / (Server()-(>TickSpeed() * 60) > g_Config.m_SvVoteVetoTime)
{
if(ActVote == 0)
Veto = true;
else if(ActVote < 0)
VetoStop = true;
}
}
if(g_Config.m_SvVoteMaxTotal && Total > g_Config.m_SvVoteMaxTotal &&
(m_VoteKick || m_VoteSpec))
Total = g_Config.m_SvVoteMaxTotal;
//if(Yes >= Total/2+1)
if(Yes > Total / (100.0 / g_Config.m_SvVoteYesPercentage))
if((Yes > Total / (100.0 / g_Config.m_SvVoteYesPercentage)) && !Veto)
m_VoteEnforce = VOTE_ENFORCE_YES;
//else if(No >= (Total+1)/2)
else if(No >= Total - Total / (100.0 / g_Config.m_SvVoteYesPercentage))
m_VoteEnforce = VOTE_ENFORCE_NO;
if(VetoStop)
m_VoteEnforce = VOTE_ENFORCE_NO;
m_VoteWillPass = Yes > (Yes + No) / (100.0 / g_Config.m_SvVoteYesPercentage);
}
if(time_get() > m_VoteCloseTime && !g_Config.m_SvVoteMajority)
m_VoteEnforce = (m_VoteWillPass) ? VOTE_ENFORCE_YES : VOTE_ENFORCE_NO;
m_VoteEnforce = (m_VoteWillPass && !Veto) ? VOTE_ENFORCE_YES : VOTE_ENFORCE_NO;
if(m_VoteEnforce == VOTE_ENFORCE_YES)
{
@ -708,7 +724,10 @@ void CGameContext::OnTick()
else if(m_VoteEnforce == VOTE_ENFORCE_NO || (time_get() > m_VoteCloseTime && g_Config.m_SvVoteMajority))
{
EndVote();
SendChat(-1, CGameContext::CHAT_ALL, "Vote failed");
if(VetoStop || (m_VoteWillPass && Veto))
SendChat(-1, CGameContext::CHAT_ALL, "Vote failed because of veto");
else
SendChat(-1, CGameContext::CHAT_ALL, "Vote failed");
}
else if(m_VoteUpdate)
{