]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix atmos NaN error (#26441)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Tue, 26 Mar 2024 04:44:56 +0000 (15:44 +1100)
committerGitHub <noreply@github.com>
Tue, 26 Mar 2024 04:44:56 +0000 (15:44 +1100)
* Fix atmos NAN error

* Remove redundant yaml entries

16 files changed:
Content.Server/Atmos/Components/AirtightComponent.cs
Content.Server/Atmos/EntitySystems/AirtightSystem.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.GridAtmosphere.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs
Content.Server/Atmos/EntitySystems/AtmosphereSystem.Utils.cs
Content.Server/Atmos/GasMixture.cs
Content.Server/Atmos/TileAtmosphere.cs
Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_structureairlocks.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/highsec.yml
Resources/Prototypes/Entities/Structures/Doors/Airlocks/shuttle.yml
Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml
Resources/Prototypes/Entities/Structures/Doors/MaterialDoors/material_doors.yml
Resources/Prototypes/Entities/Structures/Doors/SecretDoor/secret_door.yml
Resources/Prototypes/Entities/Structures/Doors/Shutter/shutters.yml
Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
Resources/Prototypes/Entities/Structures/plastic_flaps.yml

index ca107eafbe8a3191a0aa72fe6cfb92a6831e1606..69488a71307ee7a37558cfdd1159f76c01fddecc 100644 (file)
@@ -9,27 +9,53 @@ namespace Content.Server.Atmos.Components
     {
         public (EntityUid Grid, Vector2i Tile) LastPosition { get; set; }
 
+        /// <summary>
+        /// The directions in which this entity should block airflow, relative to its own reference frame.
+        /// </summary>
         [DataField("airBlockedDirection", customTypeSerializer: typeof(FlagSerializer<AtmosDirectionFlags>))]
         public int InitialAirBlockedDirection { get; set; } = (int) AtmosDirection.All;
 
+        /// <summary>
+        /// The directions in which the entity is currently blocking airflow, relative to the grid that the entity is on.
+        /// I.e., this is a variant of <see cref="InitialAirBlockedDirection"/> that takes into account the entity's
+        /// current rotation.
+        /// </summary>
         [ViewVariables]
         public int CurrentAirBlockedDirection;
 
-        [DataField("airBlocked")]
+        /// <summary>
+        /// Whether the airtight entity is currently blocking airflow.
+        /// </summary>
+        [DataField]
         public bool AirBlocked { get; set; } = true;
 
-        [DataField("fixVacuum")]
+        /// <summary>
+        /// If true, entities on this tile will attempt to draw air from surrounding tiles when they become unblocked
+        /// and currently have no air. This is generally only required when <see cref="NoAirWhenFullyAirBlocked"/> is
+        /// true, or if the entity is likely to occupy the same tile as another no-air airtight entity.
+        /// </summary>
+        [DataField]
         public bool FixVacuum { get; set; } = true;
+        // I think fixvacuum exists to ensure that repeatedly closing/opening air-blocking doors doesn't end up
+        // depressurizing a room. However it can also effectively be used as a means of generating gasses for free
+        // TODO ATMOS Mass conservation. Make it actually push/pull air from adjacent tiles instead of destroying & creating,
 
+
+        // TODO ATMOS Do we need these two fields?
         [DataField("rotateAirBlocked")]
         public bool RotateAirBlocked { get; set; } = true;
 
+        // TODO ATMOS remove this? What is this even for??
         [DataField("fixAirBlockedDirectionInitialize")]
         public bool FixAirBlockedDirectionInitialize { get; set; } = true;
 
-        [DataField("noAirWhenFullyAirBlocked")]
+        /// <summary>
+        /// If true, then the tile that this entity is on will have no air at all if all directions are blocked.
+        /// </summary>
+        [DataField]
         public bool NoAirWhenFullyAirBlocked { get; set; } = true;
 
+        /// <inheritdoc cref="CurrentAirBlockedDirection"/>
         [Access(Other = AccessPermissions.ReadWriteExecute)]
         public AtmosDirection AirBlockedDirection => (AtmosDirection)CurrentAirBlockedDirection;
     }
index 548d6a36926b76f8b9b3005290ecaf4d83468b3b..152fba8fc4d8fc23c6f87a7eafd22c5e473d361b 100644 (file)
@@ -85,8 +85,6 @@ namespace Content.Server.Atmos.EntitySystems
         private bool AirtightMove(Entity<AirtightComponent> ent, ref MoveEvent ev)
         {
             var (owner, airtight) = ent;
-            if (!airtight.RotateAirBlocked || airtight.InitialAirBlockedDirection == (int)AtmosDirection.Invalid)
-                return false;
 
             airtight.CurrentAirBlockedDirection = (int) Rotate((AtmosDirection)airtight.InitialAirBlockedDirection, ev.NewRotation);
             var pos = airtight.LastPosition;
index d43cc81b0f8be9fe265e6f401548aecd35f712e0..beddef4be7e1b622a10546fba1d59e90cc47c210 100644 (file)
@@ -399,10 +399,7 @@ public sealed partial class AtmosphereSystem
         args.Handled = true;
     }
 
-    private void GridFixTileVacuum(
-        Entity<GridAtmosphereComponent, GasTileOverlayComponent, MapGridComponent, TransformComponent> ent,
-        TileAtmosphere tile,
-        float volume)
+    private void GridFixTileVacuum(TileAtmosphere tile)
     {
         DebugTools.AssertNotNull(tile.Air);
         DebugTools.Assert(tile.Air?.Immutable == false );
@@ -416,6 +413,9 @@ public sealed partial class AtmosphereSystem
                 count++;
         }
 
+        if (count == 0)
+            return;
+
         var ratio = 1f / count;
         var totalTemperature = 0f;
 
index 1f3ca2145b9716623ca5527b7ca742070a03b4ce..eba398c182104a62744b7012efb9aa8ff0a12702 100644 (file)
@@ -272,7 +272,7 @@ namespace Content.Server.Atmos.EntitySystems
             tile.Air = new GasMixture(volume){Temperature = Atmospherics.T20C};
 
             if (data.FixVacuum)
-                GridFixTileVacuum(ent, tile, volume);
+                GridFixTileVacuum(tile);
         }
 
         private void QueueRunTiles(
index 9b0d0d9670d4a318200777c81b891af27a9ba4c5..67c6d5998dd544962a83e1457c9a85ec27e646b9 100644 (file)
@@ -78,12 +78,13 @@ public partial class AtmosphereSystem
             if (!_airtightQuery.TryGetComponent(ent, out var airtight))
                 continue;
 
+            fixVacuum |= airtight.FixVacuum;
+
             if(!airtight.AirBlocked)
                 continue;
 
             blockedDirs |= airtight.AirBlockedDirection;
             noAirWhenBlocked |= airtight.NoAirWhenFullyAirBlocked;
-            fixVacuum |= airtight.FixVacuum;
 
             if (blockedDirs == AtmosDirection.All && noAirWhenBlocked && fixVacuum)
                 break;
index 77fd7018333b032926dc81843f3f3e78065a165a..3d73a4d0b1636f10f6e92b3da869bc169090a81f 100644 (file)
@@ -62,9 +62,9 @@ namespace Content.Server.Atmos
             get => _temperature;
             set
             {
-                DebugTools.Assert(!float.IsNaN(_temperature));
-                if (Immutable) return;
-                _temperature = MathF.Min(MathF.Max(value, Atmospherics.TCMB), Atmospherics.Tmax);
+                DebugTools.Assert(!float.IsNaN(value));
+                if (!Immutable)
+                    _temperature = MathF.Min(MathF.Max(value, Atmospherics.TCMB), Atmospherics.Tmax);
             }
         }
 
@@ -91,6 +91,7 @@ namespace Content.Server.Atmos
             if (volume < 0)
                 volume = 0;
 
+            DebugTools.Assert(!float.IsNaN(temp));
             _temperature = temp;
             Moles = moles;
             Volume = volume;
index 0dd35a29e762760682ddaf1919baa6b44465e327..0026dbbf4f043ee4796ed6ec3fadc2be87db5a94 100644 (file)
@@ -28,6 +28,9 @@ namespace Content.Server.Atmos
         [ViewVariables]
         public TileAtmosphere? PressureSpecificTarget { get; set; }
 
+        /// <summary>
+        /// This is either the pressure difference, or the quantity of moles transferred if monstermos is enabled.
+        /// </summary>
         [ViewVariables]
         public float PressureDifference { get; set; }
 
index 5fca0819984247d5929f71bad730d79e05b37949..53a32e0f6fa5d477b0d76798840904194b5d8412 100644 (file)
     - key: enum.WiresUiKey.Key
       type: WiresBoundUserInterface
   - type: Airtight
-    fixVacuum: true
     noAirWhenFullyAirBlocked: false
   - type: RadiationBlocker
     resistance: 3
index 60ee2203ca5069c3aa28127f6b20800efc99ff77..a26226c957899d6c18449db9d4265fb222fcf457 100644 (file)
@@ -80,7 +80,6 @@
     - key: enum.WiresUiKey.Key
       type: WiresBoundUserInterface
   - type: Airtight
-    fixVacuum: true
   - type: Occluder
   - type: Damageable
     damageContainer: StructuralInorganic
index 21d485be0c89de47b7c7565f0f219dd6a18a2437..9771f633888b6fdc4b1119c59fdc2e9c958b1e19 100644 (file)
@@ -57,7 +57,6 @@
     denySound:
       path: /Audio/Machines/airlock_deny.ogg
   - type: Airtight
-    fixVacuum: true
     noAirWhenFullyAirBlocked: false
   - type: Tag
     tags:
index dccc76e96c1a10c733341ee82002be603ad3e1dc..e677ef185be6b0957e389269136925810baefe2d 100644 (file)
@@ -93,7 +93,6 @@
     - type: Physics
       canCollide: false
     - type: Airtight
-      fixVacuum: true
       airBlocked: false
       noAirWhenFullyAirBlocked: true
     - type: RadiationBlocker
       sprite: Structures/Doors/edge_door_hazard.rsi
       snapCardinals: false
     - type: Airtight
-      fixVacuum: true
       airBlocked: false
       noAirWhenFullyAirBlocked: false
       airBlockedDirection:
index 4b6f72de934b17c34d13b03f4c9fbe78ad74565a..8dfe2f62a51a2d8ee87601729e6c75fe97b63b7f 100644 (file)
@@ -40,7 +40,6 @@
       path: /Audio/Effects/stonedoor_openclose.ogg
   - type: Appearance
   - type: Airtight
-    fixVacuum: true
   - type: Damageable
     damageContainer: Inorganic
     damageModifierSet: Metallic
index 2c54d3cd41875e10adff4746242651cd83eb24c8..d6c087af0a5e3ac42f5770f40b4fc5ff654ad712 100644 (file)
@@ -38,7 +38,6 @@
   - type: Weldable
     time: 2
   - type: Airtight
-    fixVacuum: true
   - type: Damageable
     damageContainer: Inorganic
     damageModifierSet: Metallic
index e38ba1fd6674a8f3eaf8081ff31056d0cde6223b..1819c9d0ef2964949894cd0021604c2aec069e41 100644 (file)
@@ -59,7 +59,6 @@
     - key: enum.WiresUiKey.Key
       type: WiresBoundUserInterface
   - type: Airtight
-    fixVacuum: true
   - type: RadiationBlocker
     resistance: 2
   - type: Damageable
index 56167c178e2e28a05d5a1d5b56893db427fe35e2..d03765d4fc9e52dc7c823d9518003cb24406c3ad 100644 (file)
   - type: Appearance
   - type: WiresVisuals
   - type: Airtight
-    fixVacuum: true
     noAirWhenFullyAirBlocked: false
     airBlockedDirection:
       - South
index 8c53daf3b60db502759b242bdc0d18fa2a5dc39c..bf49eb1be35a8b7948ad48559900b717baa9062e 100644 (file)
@@ -83,7 +83,6 @@
       - !type:DoActsBehavior
         acts: ["Destruction"]
   - type: Airtight
-    fixVacuum: true
 
 - type: entity
   id: PlasticFlapsAirtightOpaque
       - !type:DoActsBehavior
         acts: ["Destruction"]
   - type: Airtight
-    fixVacuum: true