From b8d011f8f400a75a9cd21777f891c171fba9c617 Mon Sep 17 00:00:00 2001 From: vulppine Date: Mon, 22 Aug 2022 18:06:41 -0700 Subject: [PATCH] checks for validity now ensure that an alarm is reset to normal - only if it was known beforehand --- .../Monitor/Systems/AtmosAlarmableSystem.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs b/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs index 74a191b042..c2ce6453b1 100644 --- a/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs +++ b/Content.Server/Atmos/Monitor/Systems/AtmosAlarmableSystem.cs @@ -88,26 +88,30 @@ namespace Content.Server.Atmos.Monitor.Systems // the maximum alarm state at all times. if (!args.Data.TryGetValue(DeviceNetworkConstants.CmdSetState, out AtmosMonitorAlarmType state)) { - return; + break; } if (args.Data.TryGetValue(AlertTypes, out HashSet? types) && component.MonitorAlertTypes != null) { isValid = types.Any(type => component.MonitorAlertTypes.Contains(type)); - - if (!isValid) - { - break; - } } if (!component.NetworkAlarmStates.ContainsKey(args.SenderAddress)) { + if (!isValid) + { + break; + } + component.NetworkAlarmStates.Add(args.SenderAddress, state); } else { - component.NetworkAlarmStates[args.SenderAddress] = state; + // This is because if the alert is no longer valid, + // it may mean that the threshold we need to look at has + // been removed from the threshold types passed: + // basically, we need to reset this state to normal here. + component.NetworkAlarmStates[args.SenderAddress] = isValid ? state : AtmosMonitorAlarmType.Normal; } if (!TryGetHighestAlert(uid, out var netMax, component))