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:
@@ -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>
|
/// <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 )
|
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))
|
if (!TryComp(euid, out AlertsComponent? alertsComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -148,6 +152,9 @@ public abstract class AlertsSystem : EntitySystem
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearAlert(EntityUid euid, AlertType alertType)
|
public void ClearAlert(EntityUid euid, AlertType alertType)
|
||||||
{
|
{
|
||||||
|
if (_timing.ApplyingState)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
|
if (!EntityManager.TryGetComponent(euid, out AlertsComponent? alertsComponent))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user