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.
This commit is contained in:
metalgearsloth
2024-04-06 09:49:44 +11:00
committed by GitHub
parent 34980efdb5
commit dd03612d80

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;