From d06b18a8f048e8b4b934781051f449b5fa8faf7b Mon Sep 17 00:00:00 2001 From: Quantum-cross <7065792+Quantum-cross@users.noreply.github.com> Date: Mon, 12 Jan 2026 17:17:27 -0500 Subject: [PATCH] Allow late join from arrivals to be considered for antagonist. (#39837) * 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 --- Content.Server/Antag/AntagSelectionSystem.cs | 16 +++++++++--- .../Shuttles/Systems/ArrivalsSystem.cs | 25 +++++++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 15ba636a93..367885a04a 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -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 + /// Attempt to make this player be a late-join antag. + /// + /// The session to attempt to make antag. + 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(entity)) + if (_arrivals.IsOnArrivals((entity.Value, null))) return false; if (!def.AllowNonHumans && !HasComp(entity)) diff --git a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs index 20976ca019..af0e1240ad 100644 --- a/Content.Server/Shuttles/Systems/ArrivalsSystem.cs +++ b/Content.Server/Shuttles/Systems/ArrivalsSystem.cs @@ -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 _pendingQuery; private EntityQuery _blacklistQuery; @@ -273,6 +275,9 @@ public sealed class ArrivalsSystem : EntitySystem if (ArrivalsGodmode) RemCompDeferred(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; } + /// + /// Check if an entity is on the arrivals grid. + /// + /// Entity to check. + /// True if the entity is on the arrivals grid. Returns false if not on arrivals, or there is no arrivals grid. + public bool IsOnArrivals(Entity 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(); -- 2.52.0