Skip to content

Commit

Permalink
Alerts crash fix (space-wizards#26602)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
metalgearsloth committed Apr 5, 2024
1 parent 34980ef commit dd03612
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Content.Shared/Alert/AlertsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public bool TryGetAlertState(EntityUid euid, AlertKey key, out AlertState alertS
/// <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;

Expand Down Expand Up @@ -148,6 +152,9 @@ public void ClearAlertCategory(EntityUid euid, AlertCategory category)
/// </summary>
public void ClearAlert(EntityUid euid, AlertType alertType)
{
if (_timing.ApplyingState)
return;

if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
return;

Expand Down

0 comments on commit dd03612

Please sign in to comment.