From 99e6f8f0bc4de828b6afc6477259f7d10eef91ab Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 17 Jul 2023 01:41:22 +1000 Subject: [PATCH] Add FTL fallback (#16644) --- .../Systems/ShuttleSystem.FasterThanLight.cs | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index ddb046167a..1c0f715520 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -10,6 +10,7 @@ using Robust.Shared.Player; using Robust.Shared.Utility; using System.Diagnostics.CodeAnalysis; using System.Numerics; +using System.Linq; using Content.Server.Shuttles.Events; using Content.Shared.Body.Components; using Content.Shared.Buckle.Components; @@ -309,12 +310,25 @@ public sealed partial class ShuttleSystem if (comp.TargetUid != null && shuttle != null) { - if (comp.Dock) - TryFTLDock(uid, shuttle, comp.TargetUid.Value, comp.PriorityTag); - else - TryFTLProximity(uid, shuttle, comp.TargetUid.Value); + if (!Deleted(comp.TargetUid)) + { + if (comp.Dock) + TryFTLDock(uid, shuttle, comp.TargetUid.Value, comp.PriorityTag); + else + TryFTLProximity(uid, shuttle, comp.TargetUid.Value); - mapId = Transform(comp.TargetUid.Value).MapID; + mapId = Transform(comp.TargetUid.Value).MapID; + } + // oh boy, fallback time + else + { + // Pick earliest map? + var maps = EntityQuery().Select(o => o.MapId).ToList(); + var map = maps.Min(o => o.GetHashCode()); + + mapId = new MapId(map); + TryFTLProximity(uid, shuttle, _mapManager.GetMapEntityId(mapId)); + } } else {