From f917c18ff8fcec90f8007809b124e1e628476e83 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Date: Wed, 26 Jan 2022 00:37:34 +0100 Subject: [PATCH] Fix air alarm system keeping deleted entity UIDs around. (#6307) --- .../Atmos/Monitor/Systems/AirAlarmSystem.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs index e50a2ff90d..b0004927d9 100644 --- a/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AirAlarmSystem.cs @@ -166,6 +166,7 @@ namespace Content.Server.Atmos.Monitor.Systems SubscribeLocalEvent(OnUpdateThreshold); SubscribeLocalEvent(OnUpdateDeviceData); SubscribeLocalEvent(OnClose); + SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnInteract); } @@ -186,6 +187,11 @@ namespace Content.Server.Atmos.Monitor.Systems RemoveActiveInterface(uid); } + private void OnShutdown(EntityUid uid, AirAlarmComponent component, ComponentShutdown args) + { + _activeUserInterfaces.Remove(uid); + } + private void OnInteract(EntityUid uid, AirAlarmComponent component, InteractHandEvent args) { if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target)) @@ -310,6 +316,7 @@ namespace Content.Server.Atmos.Monitor.Systems _atmosMonitorSystem.SetThreshold(uid, type, threshold, gas); + // TODO: Use BUI states instead... _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateAlarmThresholdMessage(type, threshold, gas)); } @@ -353,6 +360,7 @@ namespace Content.Server.Atmos.Monitor.Systems controller.CurrentModeUpdater = null; // controller.SendMessage(new AirAlarmUpdateAlarmModeMessage(mode)); + // TODO: Use BUI states instead... _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateAlarmModeMessage(mode)); @@ -444,6 +452,7 @@ namespace Content.Server.Atmos.Monitor.Systems { if (!Resolve(uid, ref netConn)) return; + // TODO: Use BUI states instead... _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmSetAddressMessage(netConn.Address)); } @@ -468,6 +477,7 @@ namespace Content.Server.Atmos.Monitor.Systems var airData = new AirAlarmAirData(monitor.TileGas.Pressure, monitor.TileGas.Temperature, monitor.TileGas.TotalMoles, monitor.LastAlarmState, gases); + // TODO: Use BUI states instead... _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateAirDataMessage(airData)); } } @@ -480,6 +490,7 @@ namespace Content.Server.Atmos.Monitor.Systems if (!Resolve(uid, ref monitor, ref power, ref controller) || !power.Powered) return; + // TODO: Use BUI states instead... _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateAlarmModeMessage(controller.CurrentMode)); } @@ -496,6 +507,7 @@ namespace Content.Server.Atmos.Monitor.Systems && monitor.GasThresholds == null) return; + // TODO: Use BUI states instead... if (monitor.PressureThreshold != null) { _uiSystem.TrySendUiMessage(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUpdateAlarmThresholdMessage(AtmosMonitorThresholdType.Pressure, monitor.PressureThreshold)); @@ -530,6 +542,7 @@ namespace Content.Server.Atmos.Monitor.Systems _timer = 0f; foreach (var uid in _activeUserInterfaces) { + // TODO: Awful idea, use BUI states instead... SendAirData(uid); _uiSystem.TrySetUiState(uid, SharedAirAlarmInterfaceKey.Key, new AirAlarmUIState()); }