]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow late join from arrivals to be considered for antagonist. (#39837)
authorQuantum-cross <7065792+Quantum-cross@users.noreply.github.com>
Mon, 12 Jan 2026 22:17:27 +0000 (17:17 -0500)
committerGitHub <noreply@github.com>
Mon, 12 Jan 2026 22:17:27 +0000 (22:17 +0000)
* Allow late join from arrivals to be considered for antagonist.

* Don't use `PendingClockInComponent` to block late join antag selection, instead do an arrivals grid transform check with new helper function `IsOnArrivals`.

* Minor formatting fixes

* missing using

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Content.Server/Antag/AntagSelectionSystem.cs
Content.Server/Shuttles/Systems/ArrivalsSystem.cs

index 15ba636a93a8fe0afd4c8f4e3d62a52340937a42..367885a04a5ab03b58db1b0e7184cf07bb540682 100644 (file)
@@ -13,7 +13,7 @@ using Content.Server.Players.PlayTimeTracking;
 using Content.Server.Preferences.Managers;
 using Content.Server.Roles;
 using Content.Server.Roles.Jobs;
-using Content.Server.Shuttles.Components;
+using Content.Server.Shuttles.Systems;
 using Content.Shared.Administration.Logs;
 using Content.Shared.Antag;
 using Content.Shared.Clothing;
@@ -54,6 +54,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
     [Dependency] private readonly TransformSystem _transform = default!;
     [Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+    [Dependency] private readonly ArrivalsSystem _arrivals = default!;
 
     // arbitrary random number to give late joining some mild interest.
     public const float LateJoinRandomChance = 0.5f;
@@ -168,6 +169,15 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
         if (!args.LateJoin)
             return;
 
+        TryMakeLateJoinAntag(args.Player);
+    }
+
+    /// <summary>
+    /// Attempt to make this player be a late-join antag.
+    /// </summary>
+    /// <param name="session">The session to attempt to make antag.</param>
+    public void TryMakeLateJoinAntag(ICommonSession session)
+    {
         // TODO: this really doesn't handle multiple latejoin definitions well
         // eventually this should probably store the players per definition with some kind of unique identifier.
         // something to figure out later.
@@ -197,7 +207,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
             if (!TryGetNextAvailableDefinition((uid, antag), out var def, players))
                 continue;
 
-            if (TryMakeAntag((uid, antag), args.Player, def.Value))
+            if (TryMakeAntag((uid, antag), session, def.Value))
                 break;
         }
     }
@@ -572,7 +582,7 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem<AntagSelection
         if (entity == null)
             return true;
 
-        if (HasComp<PendingClockInComponent>(entity))
+        if (_arrivals.IsOnArrivals((entity.Value, null)))
             return false;
 
         if (!def.AllowNonHumans && !HasComp<HumanoidAppearanceComponent>(entity))
index 20976ca0195f9ef0e57fbadefc6c0a57b69640cb..af0e1240adbae3730e58443f18df24032e142d5b 100644 (file)
@@ -1,6 +1,7 @@
 using System.Linq;
 using System.Numerics;
 using Content.Server.Administration;
+using Content.Server.Antag;
 using Content.Server.Chat.Managers;
 using Content.Server.DeviceNetwork.Systems;
 using Content.Server.GameTicking;
@@ -61,6 +62,7 @@ public sealed class ArrivalsSystem : EntitySystem
     [Dependency] private readonly ShuttleSystem _shuttles = default!;
     [Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
     [Dependency] private readonly StationSystem _station = default!;
+    [Dependency] private readonly AntagSelectionSystem _antag = default!;
 
     private EntityQuery<PendingClockInComponent> _pendingQuery;
     private EntityQuery<ArrivalsBlacklistComponent> _blacklistQuery;
@@ -273,6 +275,9 @@ public sealed class ArrivalsSystem : EntitySystem
 
             if (ArrivalsGodmode)
                 RemCompDeferred<GodmodeComponent>(pUid);
+
+            if (_actor.TryGetSession(pUid, out var session) && session is not null)
+                _antag.TryMakeLateJoinAntag(session);
         }
     }
 
@@ -443,6 +448,26 @@ public sealed class ArrivalsSystem : EntitySystem
         return false;
     }
 
+    /// <summary>
+    /// Check if an entity is on the arrivals grid.
+    /// </summary>
+    /// <param name="entity">Entity to check.</param>
+    /// <returns>True if the entity is on the arrivals grid. Returns false if not on arrivals, or there is no arrivals grid.</returns>
+    public bool IsOnArrivals(Entity<TransformComponent?> entity)
+    {
+        if (!Resolve(entity, ref entity.Comp))
+            return false;
+
+        if (!TryGetArrivals(out var arrivals))
+            return false;
+
+        var arrivalsGridUid = Transform(arrivals).GridUid;
+        if (!arrivalsGridUid.HasValue)
+            return false;
+
+        return entity.Comp.GridUid == Transform(arrivals).GridUid;
+    }
+
     public TimeSpan? NextShuttleArrival()
     {
         var query = EntityQueryEnumerator<ArrivalsShuttleComponent>();