]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Prevent really latejoins from being T (#14866)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 26 Mar 2023 13:17:38 +0000 (00:17 +1100)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2023 13:17:38 +0000 (08:17 -0500)
AKA if they're still on arrivals and either padded time or got lucky with timing.

Content.Server/GameTicking/Rules/TraitorRuleSystem.cs

index 735bf3cb767915dae3ce2ce0c0e0e3daa086b93f..e005357f1f43093549b405cdcdf87288b18f8dee 100644 (file)
@@ -6,6 +6,7 @@ using Content.Server.Roles;
 using Content.Server.Traitor;
 using Content.Server.Traitor.Uplink;
 using Content.Server.NPC.Systems;
+using Content.Server.Shuttles.Components;
 using Content.Shared.CCVar;
 using Content.Shared.Dataset;
 using Content.Shared.Preferences;
@@ -171,9 +172,23 @@ public sealed class TraitorRuleSystem : GameRuleSystem
 
     public List<IPlayerSession> FindPotentialTraitors(in Dictionary<IPlayerSession, HumanoidCharacterProfile> candidates)
     {
-        var list = new List<IPlayerSession>(candidates.Keys).Where(x =>
-            x.Data.ContentData()?.Mind?.AllRoles.All(role => role is not Job { CanBeAntag: false }) ?? false
-        ).ToList();
+        var list = new List<IPlayerSession>();
+        var pendingQuery = GetEntityQuery<PendingClockInComponent>();
+
+        foreach (var player in candidates.Keys)
+        {
+            // Role prevents antag.
+            if (!(player.Data.ContentData()?.Mind?.AllRoles.All(role => role is not Job { CanBeAntag: false }) ?? false))
+            {
+                continue;
+            }
+
+            // Latejoin
+            if (player.AttachedEntity != null && pendingQuery.HasComponent(player.AttachedEntity.Value))
+                continue;
+
+            list.Add(player);
+        }
 
         var prefList = new List<IPlayerSession>();