From dd03612d8032050e4d60b8ac7fffae4d5911d422 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 6 Apr 2024 09:49:44 +1100 Subject: [PATCH] Alerts crash fix (#26602) - If the client tries to call ShowAlert while applying gamestates (e.g. initialising an entity) then this will cause problems. I need to double-check the initial PR before I'd be comfortable with this being merged. --- Content.Shared/Alert/AlertsSystem.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Content.Shared/Alert/AlertsSystem.cs b/Content.Shared/Alert/AlertsSystem.cs index d8737a717aae81..5b888e30c4c72d 100644 --- a/Content.Shared/Alert/AlertsSystem.cs +++ b/Content.Shared/Alert/AlertsSystem.cs @@ -80,6 +80,10 @@ public bool TryGetAlertState(EntityUid euid, AlertKey key, out AlertState alertS /// if true, the cooldown will be visibly shown over the alert icon public void ShowAlert(EntityUid euid, AlertType alertType, short? severity = null, (TimeSpan, TimeSpan)? cooldown = null, bool autoRemove = false, bool showCooldown = true ) { + // This should be handled as part of networking. + if (_timing.ApplyingState) + return; + if (!TryComp(euid, out AlertsComponent? alertsComponent)) return; @@ -148,6 +152,9 @@ public void ClearAlertCategory(EntityUid euid, AlertCategory category) /// public void ClearAlert(EntityUid euid, AlertType alertType) { + if (_timing.ApplyingState) + return; + if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent)) return;