From: Winkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com> Date: Wed, 10 Sep 2025 13:56:18 +0000 (+0300) Subject: Fix emergency evac shuttle console early launch mispredict (#39751) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=ebfcddc62f5179865684a35311cab03d5c86400e;p=space-station-14.git Fix emergency evac shuttle console early launch mispredict (#39751) * Fix * Yes * Mess * Update * Like that? --- diff --git a/Content.Client/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Client/Shuttles/Systems/EmergencyShuttleSystem.cs new file mode 100644 index 0000000000..c2b8dc8c8d --- /dev/null +++ b/Content.Client/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.Shuttles.Systems; + +namespace Content.Client.Shuttles.Systems; + +public sealed partial class EmergencyShuttleSystem : SharedEmergencyShuttleSystem; diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index e07b522c5a..c8cdf17d30 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -9,9 +9,9 @@ using Content.Shared.DeviceNetwork; using Content.Shared.DeviceNetwork.Components; using Content.Shared.Popups; using Content.Shared.Shuttles.BUIStates; +using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Events; using Content.Shared.Shuttles.Systems; -using Content.Shared.UserInterface; using Robust.Shared.Map; using Robust.Shared.Player; using Robust.Shared.Prototypes; @@ -86,24 +86,13 @@ public sealed partial class EmergencyShuttleSystem private void InitializeEmergencyConsole() { - Subs.CVar(_configManager, CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime, true); - Subs.CVar(_configManager, CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime, true); - Subs.CVar(_configManager, CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true); + Subs.CVar(ConfigManager, CCVars.EmergencyShuttleMinTransitTime, SetMinTransitTime, true); + Subs.CVar(ConfigManager, CCVars.EmergencyShuttleMaxTransitTime, SetMaxTransitTime, true); + Subs.CVar(ConfigManager, CCVars.EmergencyShuttleAuthorizeTime, SetAuthorizeTime, true); SubscribeLocalEvent(OnEmergencyStartup); SubscribeLocalEvent(OnEmergencyAuthorize); SubscribeLocalEvent(OnEmergencyRepeal); SubscribeLocalEvent(OnEmergencyRepealAll); - SubscribeLocalEvent(OnEmergencyOpenAttempt); - } - - private void OnEmergencyOpenAttempt(EntityUid uid, EmergencyShuttleConsoleComponent component, ActivatableUIOpenAttemptEvent args) - { - // I'm hoping ActivatableUI checks it's open before allowing these messages. - if (!_configManager.GetCVar(CCVars.EmergencyEarlyLaunchAllowed)) - { - args.Cancel(); - _popup.PopupEntity(Loc.GetString("emergency-shuttle-console-no-early-launches"), uid, args.User); - } } private void SetAuthorizeTime(float obj) @@ -248,7 +237,7 @@ public sealed partial class EmergencyShuttleSystem if (!_reader.FindAccessTags(player).Contains(EmergencyRepealAllAccess)) { - _popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player, PopupType.Medium); + Popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player, PopupType.Medium); return; } @@ -267,7 +256,7 @@ public sealed partial class EmergencyShuttleSystem if (!_idSystem.TryFindIdCard(player, out var idCard) || !_reader.IsAllowed(idCard, uid)) { - _popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player, PopupType.Medium); + Popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), player, PopupType.Medium); return; } @@ -288,7 +277,7 @@ public sealed partial class EmergencyShuttleSystem if (!_idSystem.TryFindIdCard(player, out var idCard) || !_reader.IsAllowed(idCard, uid)) { - _popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), args.Actor, PopupType.Medium); + Popup.PopupCursor(Loc.GetString("emergency-shuttle-console-denied"), args.Actor, PopupType.Medium); return; } diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index e0bbc9d090..1b2f343052 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -10,7 +10,6 @@ using Content.Server.DeviceNetwork.Systems; using Content.Server.GameTicking; using Content.Server.GameTicking.Events; using Content.Server.Pinpointer; -using Content.Server.Popups; using Content.Server.RoundEnd; using Content.Server.Screens.Components; using Content.Server.Shuttles.Components; @@ -26,11 +25,11 @@ using Content.Shared.GameTicking; using Content.Shared.Localizations; using Content.Shared.Shuttles.Components; using Content.Shared.Shuttles.Events; +using Content.Shared.Shuttles.Systems; using Content.Shared.Tag; using Content.Shared.Tiles; using Robust.Server.GameObjects; using Robust.Shared.Audio.Systems; -using Robust.Shared.Configuration; using Robust.Shared.EntitySerialization.Systems; using Robust.Shared.Map.Components; using Robust.Shared.Player; @@ -41,7 +40,7 @@ using Robust.Shared.Utility; namespace Content.Server.Shuttles.Systems; -public sealed partial class EmergencyShuttleSystem : EntitySystem +public sealed partial class EmergencyShuttleSystem : SharedEmergencyShuttleSystem { /* * Handles the escape shuttle + CentCom. @@ -49,7 +48,6 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly IAdminLogManager _logger = default!; [Dependency] private readonly IAdminManager _admin = default!; - [Dependency] private readonly IConfigurationManager _configManager = default!; [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedMapSystem _mapSystem = default!; @@ -63,7 +61,6 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly NavMapSystem _navMap = default!; [Dependency] private readonly MapLoaderSystem _loader = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; - [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly RoundEndSystem _roundEnd = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly ShuttleSystem _shuttle = default!; @@ -79,9 +76,11 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem public override void Initialize() { - _emergencyShuttleEnabled = _configManager.GetCVar(CCVars.EmergencyShuttleEnabled); + base.Initialize(); + + _emergencyShuttleEnabled = ConfigManager.GetCVar(CCVars.EmergencyShuttleEnabled); // Don't immediately invoke as roundstart will just handle it. - Subs.CVar(_configManager, CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled); + Subs.CVar(ConfigManager, CCVars.EmergencyShuttleEnabled, SetEmergencyShuttleEnabled); SubscribeLocalEvent(OnRoundStart); SubscribeLocalEvent(OnRoundCleanup); @@ -229,7 +228,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem /// private void OnEmergencyFTLComplete(EntityUid uid, EmergencyShuttleComponent component, ref FTLCompletedEvent args) { - var countdownTime = TimeSpan.FromSeconds(_configManager.GetCVar(CCVars.RoundRestartTime)); + var countdownTime = TimeSpan.FromSeconds(ConfigManager.GetCVar(CCVars.RoundRestartTime)); var shuttle = args.Entity; if (TryComp(shuttle, out var net)) { @@ -440,7 +439,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem return; } - _consoleAccumulator = _configManager.GetCVar(CCVars.EmergencyShuttleDockTime); + _consoleAccumulator = ConfigManager.GetCVar(CCVars.EmergencyShuttleDockTime); EmergencyShuttleArrived = true; var query = AllEntityQuery(); @@ -459,9 +458,9 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem var worstResult = dockResults.Max(x => x.ResultType); var multiplier = worstResult switch { - ShuttleDockResultType.OtherDock => _configManager.GetCVar( + ShuttleDockResultType.OtherDock => ConfigManager.GetCVar( CCVars.EmergencyShuttleDockTimeMultiplierOtherDock), - ShuttleDockResultType.NoDock => _configManager.GetCVar( + ShuttleDockResultType.NoDock => ConfigManager.GetCVar( CCVars.EmergencyShuttleDockTimeMultiplierNoDock), // GoodLuck doesn't get a multiplier. // Quite frankly at that point the round is probably so fucked that you'd rather it be over ASAP. diff --git a/Content.Shared/CCVar/CCVars.Shuttle.cs b/Content.Shared/CCVar/CCVars.Shuttle.cs index eb6e70579c..28ed146eaf 100644 --- a/Content.Shared/CCVar/CCVars.Shuttle.cs +++ b/Content.Shared/CCVar/CCVars.Shuttle.cs @@ -117,7 +117,7 @@ public sealed partial class CCVars /// Is the emergency shuttle allowed to be early launched. /// public static readonly CVarDef EmergencyEarlyLaunchAllowed = - CVarDef.Create("shuttle.emergency_early_launch_allowed", false, CVar.SERVERONLY); + CVarDef.Create("shuttle.emergency_early_launch_allowed", false, CVar.SERVER | CVar.REPLICATED); /// /// How long the emergency shuttle remains docked with the station, in seconds. diff --git a/Content.Server/Shuttles/Components/EmergencyShuttleConsoleComponent.cs b/Content.Shared/Shuttles/Components/EmergencyShuttleConsoleComponent.cs similarity index 81% rename from Content.Server/Shuttles/Components/EmergencyShuttleConsoleComponent.cs rename to Content.Shared/Shuttles/Components/EmergencyShuttleConsoleComponent.cs index 6379a76f55..d851056208 100644 --- a/Content.Server/Shuttles/Components/EmergencyShuttleConsoleComponent.cs +++ b/Content.Shared/Shuttles/Components/EmergencyShuttleConsoleComponent.cs @@ -1,6 +1,8 @@ -namespace Content.Server.Shuttles.Components; +using Robust.Shared.GameStates; -[RegisterComponent] +namespace Content.Shared.Shuttles.Components; + +[RegisterComponent, NetworkedComponent] public sealed partial class EmergencyShuttleConsoleComponent : Component { // TODO: Okay doing it by string is kinda suss but also ID card tracking doesn't seem to be robust enough diff --git a/Content.Shared/Shuttles/Systems/SharedEmergencyShuttleSystem.cs b/Content.Shared/Shuttles/Systems/SharedEmergencyShuttleSystem.cs new file mode 100644 index 0000000000..7f818767ea --- /dev/null +++ b/Content.Shared/Shuttles/Systems/SharedEmergencyShuttleSystem.cs @@ -0,0 +1,34 @@ +using Content.Shared.CCVar; +using Content.Shared.Popups; +using Content.Shared.Shuttles.Components; +using Content.Shared.UserInterface; +using Robust.Shared.Configuration; + +namespace Content.Shared.Shuttles.Systems; + +public abstract class SharedEmergencyShuttleSystem : EntitySystem +{ + [Dependency] protected readonly IConfigurationManager ConfigManager = default!; + [Dependency] protected readonly SharedPopupSystem Popup = default!; + + private bool _emergencyEarlyLaunchAllowed; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnEmergencyOpenAttempt); + + Subs.CVar(ConfigManager, CCVars.EmergencyEarlyLaunchAllowed, value => _emergencyEarlyLaunchAllowed = value, true); + } + + private void OnEmergencyOpenAttempt(Entity ent, ref ActivatableUIOpenAttemptEvent args) + { + // I'm hoping ActivatableUI checks it's open before allowing these messages. + if (_emergencyEarlyLaunchAllowed) + return; + + args.Cancel(); + Popup.PopupClient(Loc.GetString("emergency-shuttle-console-no-early-launches"), ent, args.User); + } +}