Restart vote is now actually passable (#8194)

This commit is contained in:
metalgearsloth
2022-05-16 13:33:14 +10:00
committed by GitHub
parent 5128dd61ec
commit bb09d0ddc4
4 changed files with 13 additions and 12 deletions

View File

@@ -49,13 +49,14 @@ namespace Content.Server.Voting.Managers
Title = Loc.GetString("ui-vote-restart-title"),
Options =
{
(Loc.GetString("ui-vote-restart-yes"), true),
(Loc.GetString("ui-vote-restart-no"), false)
(Loc.GetString("ui-vote-restart-yes"), "yes"),
(Loc.GetString("ui-vote-restart-no"), "no"),
(Loc.GetString("ui-vote-restart-abstain"), "abstain")
},
Duration = alone
? TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerAlone))
: TimeSpan.FromSeconds(_cfg.GetCVar(CCVars.VoteTimerRestart)),
InitiatorTimeout = TimeSpan.FromMinutes(3)
InitiatorTimeout = TimeSpan.FromMinutes(5)
};
if (alone)
@@ -67,12 +68,12 @@ namespace Content.Server.Voting.Managers
vote.OnFinished += (_, _) =>
{
var votesYes = vote.VotesPerOption[true];
var votesNo = vote.VotesPerOption[false];
var votesYes = vote.VotesPerOption["yes"];
var votesNo = vote.VotesPerOption["no"];
var total = votesYes + votesNo;
var ratioRequired = _cfg.GetCVar(CCVars.VoteRestartRequiredRatio);
if (votesYes / (float) total >= ratioRequired)
if (total > 0 && votesYes / (float) total >= ratioRequired)
{
_chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-restart-succeeded"));
EntitySystem.Get<RoundEndSystem>().EndRound();
@@ -92,10 +93,10 @@ namespace Content.Server.Voting.Managers
foreach (var player in _playerManager.ServerSessions)
{
if (player != initiator && !_afkManager.IsAfk(player))
if (player != initiator)
{
// Everybody else defaults to a no vote.
vote.CastVote(player, 1);
// Everybody else defaults to an abstain vote to say they don't mind.
vote.CastVote(player, 2);
}
}
}