]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Stop AtmosphereSystem from logging errors if an atmosphere gets deleted. (#22761)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Wed, 20 Dec 2023 00:57:29 +0000 (19:57 -0500)
committerGitHub <noreply@github.com>
Wed, 20 Dec 2023 00:57:29 +0000 (11:57 +1100)
Stop AtmosphereSystem from logging errors if a atmosphere gets deleted.

Content.Server/Atmos/EntitySystems/AtmosphereSystem.GridAtmosphere.cs

index 3eb38296f6a0aba3e8dd3e4ac343e560a355675c..5891d64d4d7d538ececef571ad6f995ca920d3e7 100644 (file)
@@ -14,6 +14,7 @@ public sealed partial class AtmosphereSystem
     private void InitializeGridAtmosphere()
     {
         SubscribeLocalEvent<GridAtmosphereComponent, ComponentInit>(OnGridAtmosphereInit);
+        SubscribeLocalEvent<GridAtmosphereComponent, ComponentRemove>(OnAtmosphereRemove);
         SubscribeLocalEvent<GridAtmosphereComponent, GridSplitEvent>(OnGridSplit);
 
         #region Atmos API Subscriptions
@@ -42,6 +43,19 @@ public sealed partial class AtmosphereSystem
         #endregion
     }
 
+    private void OnAtmosphereRemove(EntityUid uid, GridAtmosphereComponent component, ComponentRemove args)
+    {
+        for (var i = 0; i < _currentRunAtmosphere.Count; i++)
+        {
+            if (_currentRunAtmosphere[i].Owner != uid)
+                continue;
+
+            _currentRunAtmosphere.RemoveAt(i);
+            if (_currentRunAtmosphereIndex >= i)
+                _currentRunAtmosphereIndex--;
+        }
+    }
+
     private void OnGridAtmosphereInit(EntityUid uid, GridAtmosphereComponent gridAtmosphere, ComponentInit args)
     {
         base.Initialize();