From 1b01247c5f23fc29bc1ed89830db8d171489b39d Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Thu, 11 Nov 2021 16:15:14 +0100 Subject: [PATCH] Fixes that annoying atmos zero pressure bug I've constantly been pinged and nagged about for like the past few days. --- .../Atmos/EntitySystems/AirtightSystem.cs | 14 ++++++-------- .../Atmos/EntitySystems/AtmosphereSystem.Grid.cs | 7 +++++++ .../EntitySystems/AtmosphereSystem.Processing.cs | 1 - .../Doors/Components/ServerDoorComponent.cs | 9 ++++++++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs index 284a930e10..8ae5bcb748 100644 --- a/Content.Server/Atmos/EntitySystems/AirtightSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AirtightSystem.cs @@ -42,12 +42,7 @@ namespace Content.Server.Atmos.EntitySystems { SetAirblocked(airtight, false); - InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); - - if (airtight.FixVacuum) - { - _atmosphereSystem.FixVacuum(airtight.LastPosition.Item1, airtight.LastPosition.Item2); - } + InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum); } private void OnMapInit(EntityUid uid, AirtightComponent airtight, MapInitEvent args) @@ -89,16 +84,19 @@ namespace Content.Server.Atmos.EntitySystems var grid = _mapManager.GetGrid(airtight.Owner.Transform.GridID); airtight.LastPosition = (airtight.Owner.Transform.GridID, grid.TileIndicesFor(airtight.Owner.Transform.Coordinates)); - InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2); + InvalidatePosition(airtight.LastPosition.Item1, airtight.LastPosition.Item2, airtight.FixVacuum && !airtight.AirBlocked); } - public void InvalidatePosition(GridId gridId, Vector2i pos) + public void InvalidatePosition(GridId gridId, Vector2i pos, bool fixVacuum = false) { if (!gridId.IsValid()) return; _atmosphereSystem.UpdateAdjacent(gridId, pos); _atmosphereSystem.InvalidateTile(gridId, pos); + + if(fixVacuum) + _atmosphereSystem.FixVacuum(gridId, pos); } private AtmosDirection Rotate(AtmosDirection myDirection, Angle myAngle) diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs index 24cef3fa78..91fd9ce573 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Grid.cs @@ -988,6 +988,7 @@ namespace Content.Server.Atmos.EntitySystems private void UpdateAdjacent(IMapGrid mapGrid, GridAtmosphereComponent gridAtmosphere, TileAtmosphere tileAtmosphere) { tileAtmosphere.AdjacentBits = AtmosDirection.Invalid; + tileAtmosphere.BlockedAirflow = GetBlockedDirections(mapGrid, tileAtmosphere.GridIndices); for (var i = 0; i < Atmospherics.Directions; i++) { @@ -1006,6 +1007,9 @@ namespace Content.Server.Atmos.EntitySystems tileAtmosphere.AdjacentBits |= direction; } } + + if (!tileAtmosphere.AdjacentBits.IsFlagSet(tileAtmosphere.MonstermosInfo.CurrentTransferDirection)) + tileAtmosphere.MonstermosInfo.CurrentTransferDirection = AtmosDirection.Invalid; } /// @@ -1071,6 +1075,9 @@ namespace Content.Server.Atmos.EntitySystems { tile.AdjacentBits &= ~direction; } + + if (!tile.AdjacentBits.IsFlagSet(tile.MonstermosInfo.CurrentTransferDirection)) + tile.MonstermosInfo.CurrentTransferDirection = AtmosDirection.Invalid; } #endregion diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs index 86d981b33b..0d5aaf65a4 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Processing.cs @@ -65,7 +65,6 @@ namespace Content.Server.Atmos.EntitySystems var isAirBlocked = IsTileAirBlocked(mapGrid, indices); - tile.BlockedAirflow = GetBlockedDirections(mapGrid, indices); UpdateAdjacent(mapGrid, atmosphere, tile); if (IsTileSpace(mapGrid, indices) && !isAirBlocked) diff --git a/Content.Server/Doors/Components/ServerDoorComponent.cs b/Content.Server/Doors/Components/ServerDoorComponent.cs index 232b3d230f..46596ce67b 100644 --- a/Content.Server/Doors/Components/ServerDoorComponent.cs +++ b/Content.Server/Doors/Components/ServerDoorComponent.cs @@ -366,6 +366,11 @@ namespace Content.Server.Doors.Components occluder.Enabled = false; } + if (Owner.TryGetComponent(out AirtightComponent? airtight)) + { + EntitySystem.Get().SetAirblocked(airtight, false); + } + _stateChangeCancelTokenSource?.Cancel(); _stateChangeCancelTokenSource = new(); @@ -387,11 +392,13 @@ namespace Content.Server.Doors.Components protected override void OnPartialOpen() { + base.OnPartialOpen(); + if (Owner.TryGetComponent(out AirtightComponent? airtight)) { EntitySystem.Get().SetAirblocked(airtight, false); } - base.OnPartialOpen(); + Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new AccessReaderChangeMessage(Owner, false)); }