]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed players without headrevs ticked being picked anyway (#20895)
authorVasilis <vasilis@pikachu.systems>
Thu, 19 Oct 2023 03:48:55 +0000 (05:48 +0200)
committerGitHub <noreply@github.com>
Thu, 19 Oct 2023 03:48:55 +0000 (23:48 -0400)
* Fixy fix fix uwu merge pwease

* admin message to inform them

* oop

Content.Server/Antag/AntagSelectionSystem.cs
Content.Server/GameTicking/Rules/Components/RevolutionaryRuleComponent.cs
Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl

index f1ca18175695120de832160a352bc5c5bcf11684..5e323f5ab8eb2da3a07cd592dcf14f78b94dadfe 100644 (file)
@@ -116,14 +116,13 @@ public sealed class AntagSelectionSystem : GameRuleSystem<GameRuleComponent>
         var antags = Math.Clamp(allPlayers.Count / antagsPerPlayer, 1, maxAntags);
         for (var antag = 0; antag < antags; antag++)
         {
-            IPlayerSession chosenPlayer;
+            IPlayerSession chosenPlayer = null!;
             if (prefList.Count == 0)
             {
                 if (playerList.Count == 0)
                 {
                     break;
                 }
-                chosenPlayer = _random.PickAndTake(playerList);
             }
             else
             {
index f015f8bd573eb9eb77b29db90cfed694a6b1cfe2..7d036c615ba68be457536fea4df90eac3b7ca977 100644 (file)
@@ -29,6 +29,9 @@ public sealed partial class RevolutionaryRuleComponent : Component
     [DataField]
     public Dictionary<string, EntityUid> HeadRevs = new();
 
+    [DataField]
+    public ProtoId<AntagPrototype> HeadRevPrototypeId = "HeadRev";
+
     [DataField]
     public ProtoId<AntagPrototype> RevPrototypeId = "Rev";
 
index d6195aaa5403380807ded1567848710ca8815cd9..54b45f59e940938adba5e9009bde2241877108e8 100644 (file)
@@ -142,9 +142,14 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
         var query = QueryActiveRules();
         while (query.MoveNext(out _, out var comp, out _))
         {
-            _antagSelection.EligiblePlayers(comp.RevPrototypeId, comp.MaxHeadRevs, comp.PlayersPerHeadRev, comp.HeadRevStartSound,
+            _antagSelection.EligiblePlayers(comp.HeadRevPrototypeId, comp.MaxHeadRevs, comp.PlayersPerHeadRev, comp.HeadRevStartSound,
                 "head-rev-role-greeting", "#5e9cff", out var chosen);
-            GiveHeadRev(chosen, comp.RevPrototypeId, comp);
+            if (!chosen.Any())
+                GiveHeadRev(chosen, comp.RevPrototypeId, comp);
+            else
+            {
+                _chatManager.SendAdminAnnouncement(Loc.GetString("rev-no-heads"));
+            }
         }
     }
 
index 8bcdc2497759680412304ce8acac3caf52c67045..8958802161896aebcf88ec26eb528fd235ef05d6 100644 (file)
@@ -46,6 +46,7 @@ rev-description = Revolutionaries are among us.
 
 rev-not-enough-ready-players = Not enough players readied up for the game. There were {$readyPlayersCount} players readied up out of {$minimumPlayers} needed. Can't start a Revolution.
 rev-no-one-ready = No players readied up! Can't start a Revolution.
+rev-no-heads = There were no Head Revolutionaries to be selected. Can't start a Revolution.
 
 rev-all-heads-dead = All the heads are dead, now finish up the rest of the crew!