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.

(cherry picked from commit dd03612d80)
This commit is contained in:
metalgearsloth
2024-04-07 14:36:00 +02:00
committed by NullWanderer
parent e1b2189bf7
commit b0cf1237c7
+7
View 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;