]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Alerts crash fix (#26602)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 5 Apr 2024 22:49:44 +0000 (09:49 +1100)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2024 22:49:44 +0000 (00:49 +0200)
- 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

index d8737a717aae81bd06eefcea15d1d752820c93fd..5b888e30c4c72d4ce790c68bf41757c3cad7b40f 100644 (file)
@@ -80,6 +80,10 @@ public abstract class AlertsSystem : EntitySystem
     /// <param name="showCooldown">if true, the cooldown will be visibly shown over the alert icon</param>
     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 abstract class AlertsSystem : EntitySystem
     /// </summary>
     public void ClearAlert(EntityUid euid, AlertType alertType)
     {
+        if (_timing.ApplyingState)
+            return;
+
         if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
             return;