]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
change the restart vote to have no effect with admins online (#22945)
authorLankLTE <135308300+LankLTE@users.noreply.github.com>
Mon, 25 Dec 2023 07:55:56 +0000 (23:55 -0800)
committerGitHub <noreply@github.com>
Mon, 25 Dec 2023 07:55:56 +0000 (23:55 -0800)
* Change the vote and cvar

* Only denies successful votes

* Add comments because I'm a good coder, I swear

* I added a space to the first line of ccvars it's so over

Content.Server/Voting/Managers/VoteManager.DefaultVotes.cs
Content.Server/Voting/Managers/VoteManager.cs
Content.Shared/CCVar/CCVars.cs

index e1bffa769da5f61e2b5b75fd9934cd220f492a73..3800d7f02c421891c79ae80915a78e5d40aecc87 100644 (file)
@@ -81,10 +81,18 @@ namespace Content.Server.Voting.Managers
                 var ratioRequired = _cfg.GetCVar(CCVars.VoteRestartRequiredRatio);
                 if (total > 0 && votesYes / (float) total >= ratioRequired)
                 {
-                    _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Restart vote succeeded: {votesYes}/{votesNo}");
-                    _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-restart-succeeded"));
-                    var roundEnd = _entityManager.EntitySysManager.GetEntitySystem<RoundEndSystem>();
-                    roundEnd.EndRound();
+                    // Check if an admin is online, and ignore the passed vote if the cvar is enabled
+                    if (_cfg.GetCVar(CCVars.VoteRestartNotAllowedWhenAdminOnline) && _adminMgr.ActiveAdmins.Count() != 0)
+                    {
+                        _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Restart vote attempted to pass, but an admin was online. {votesYes}/{votesNo}");
+                    } 
+                    else // If the cvar is disabled or there's no admins on, proceed as normal
+                    {
+                        _adminLogger.Add(LogType.Vote, LogImpact.Medium, $"Restart vote succeeded: {votesYes}/{votesNo}");
+                        _chatManager.DispatchServerAnnouncement(Loc.GetString("ui-vote-restart-succeeded"));
+                        var roundEnd = _entityManager.EntitySysManager.GetEntitySystem<RoundEndSystem>();
+                        roundEnd.EndRound();
+                    }
                 }
                 else
                 {
index 4fb022fad0ec8a746c6d0de17eeb0b6b8ae09d54..d57d3e74ffc13bd14dd3627661d10f41a4b6a842 100644 (file)
@@ -338,10 +338,6 @@ namespace Content.Server.Voting.Managers
             if (voteType != null && _standardVoteTimeout.TryGetValue(voteType.Value, out timeSpan))
                 return false;
 
-            // No, seriously, stop spamming the restart vote!
-            if (voteType == StandardVoteType.Restart && _cfg.GetCVar(CCVars.VoteRestartNotAllowedWhenAdminOnline) && _adminMgr.ActiveAdmins.Count() != 0)
-                return false;
-
             // If only one Preset available thats not really a vote
             // Still allow vote if availbable one is different from current one
             if (voteType == StandardVoteType.Preset)
index fb6626c150c10852d11f5428a24e0844b6a476ee..b18ab14262387f96108a1243f268b05d34a80ee4 100644 (file)
@@ -1223,7 +1223,7 @@ namespace Content.Shared.CCVar
             CVarDef.Create("vote.restart_required_ratio", 0.85f, CVar.SERVERONLY);
 
         /// <summary>
-        /// Whether or not to restrict the restart vote when there's online admins.
+        /// Whether or not to prevent the restart vote from having any effect when there is an online admin
         /// </summary>
         public static readonly CVarDef<bool> VoteRestartNotAllowedWhenAdminOnline =
             CVarDef.Create("vote.restart_not_allowed_when_admin_online", true, CVar.SERVERONLY);