diff --git a/Content.Server/Atmos/EntitySystems/AutomaticAtmosSystem.cs b/Content.Server/Atmos/EntitySystems/AutomaticAtmosSystem.cs index 76775638ee..60d7778f5f 100644 --- a/Content.Server/Atmos/EntitySystems/AutomaticAtmosSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AutomaticAtmosSystem.cs @@ -23,6 +23,9 @@ public sealed class AutomaticAtmosSystem : EntitySystem private void OnTileChanged(ref TileChangedEvent ev) { + if (_atmosphereSystem.HasAtmosphere(ev.Entity) || !TryComp(ev.Entity, out var physics)) + return; + foreach (var change in ev.Changes) { // Only if a atmos-holding tile has been added or removed. @@ -34,12 +37,10 @@ public sealed class AutomaticAtmosSystem : EntitySystem var newSpace = change.NewTile.IsSpace(_tileDefinitionManager); if (!(oldSpace && !newSpace || - !oldSpace && newSpace) || - _atmosphereSystem.HasAtmosphere(ev.Entity)) + !oldSpace && newSpace)) + { continue; - - if (!TryComp(ev.Entity, out var physics)) - return; + } // We can't actually count how many tiles there are efficiently, so instead estimate with the mass. if (physics.Mass / ShuttleSystem.TileMassMultiplier >= 7.0f) @@ -47,8 +48,10 @@ public sealed class AutomaticAtmosSystem : EntitySystem AddComp(ev.Entity); Log.Info($"Giving grid {ev.Entity} GridAtmosphereComponent."); } + // It's not super important to remove it should the grid become too small again. // If explosions ever gain the ability to outright shatter grids, do rethink this. + return; } } } diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index 2af95c7c23..690d24c2e4 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -160,18 +160,22 @@ namespace Content.Server.Decals private void OnTileChanged(ref TileChangedEvent args) { + if (!TryComp(args.Entity, out DecalGridComponent? grid)) + return; + + var toDelete = new HashSet(); + foreach (var change in args.Changes) { if (!change.NewTile.IsSpace(_tileDefMan)) - return; - - if (!TryComp(args.Entity, out DecalGridComponent? grid)) - return; + continue; var indices = GetChunkIndices(change.GridIndices); - var toDelete = new HashSet(); + if (!grid.ChunkCollection.ChunkCollection.TryGetValue(indices, out var chunk)) - return; + continue; + + toDelete.Clear(); foreach (var (uid, decal) in chunk.Decals) { @@ -183,7 +187,7 @@ namespace Content.Server.Decals } if (toDelete.Count == 0) - return; + continue; foreach (var decalId in toDelete) { diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs index 77def3abba..1b68338eca 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.GridMap.cs @@ -233,14 +233,14 @@ public sealed partial class ExplosionSystem /// private void OnTileChanged(ref TileChangedEvent ev) { + if (!TryComp(ev.Entity, out MapGridComponent? grid)) + return; + foreach (var change in ev.Changes) { // only need to update the grid-edge map if a tile was added or removed from the grid. if (!change.NewTile.IsEmpty && !change.OldTile.IsEmpty) - return; - - if (!TryComp(ev.Entity, out MapGridComponent? grid)) - return; + continue; if (!_gridEdges.TryGetValue(ev.Entity, out var edges)) { @@ -265,7 +265,7 @@ public sealed partial class ExplosionSystem } } - return; + continue; } // the tile is not empty space, but was previously. So update directly adjacent neighbours, which may no longer diff --git a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs index 3def3feedc..e36d3edda1 100644 --- a/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs +++ b/Content.Server/NPC/Pathfinding/PathfindingSystem.Grid.cs @@ -53,7 +53,7 @@ public sealed partial class PathfindingSystem foreach (var change in ev.Changes) { if (change.OldTile.IsEmpty == change.NewTile.IsEmpty) - return; + continue; DirtyChunk(ev.Entity, _maps.GridTileToLocal(ev.Entity, ev.Entity.Comp, change.GridIndices)); } diff --git a/Content.Server/Pinpointer/NavMapSystem.cs b/Content.Server/Pinpointer/NavMapSystem.cs index ffa048acd6..7511e60cde 100644 --- a/Content.Server/Pinpointer/NavMapSystem.cs +++ b/Content.Server/Pinpointer/NavMapSystem.cs @@ -101,10 +101,13 @@ public sealed partial class NavMapSystem : SharedNavMapSystem private void OnTileChanged(ref TileChangedEvent ev) { + if (!_navQuery.TryComp(ev.Entity, out var navMap)) + return; + foreach (var change in ev.Changes) { - if (!change.EmptyChanged || !_navQuery.TryComp(ev.Entity, out var navMap)) - return; + if (!change.EmptyChanged) + continue; var tile = change.GridIndices; var chunkOrigin = SharedMapSystem.GetChunkIndices(tile, ChunkSize); @@ -119,7 +122,7 @@ public sealed partial class NavMapSystem : SharedNavMapSystem { tileData = 0; if (PruneEmpty((ev.Entity, navMap), chunk)) - return; + continue; } else { diff --git a/Content.Server/Shuttles/Systems/ThrusterSystem.cs b/Content.Server/Shuttles/Systems/ThrusterSystem.cs index 294200af9a..42c249c9ab 100644 --- a/Content.Server/Shuttles/Systems/ThrusterSystem.cs +++ b/Content.Server/Shuttles/Systems/ThrusterSystem.cs @@ -98,7 +98,7 @@ public sealed class ThrusterSystem : EntitySystem { // If the old tile was space but the new one isn't then disable all adjacent thrusters if (change.NewTile.IsSpace(_tileDefManager) || !change.OldTile.IsSpace(_tileDefManager)) - return; + continue; var tilePos = change.GridIndices; var grid = Comp(uid); diff --git a/Content.Server/Tiles/RequiresTileSystem.cs b/Content.Server/Tiles/RequiresTileSystem.cs index aae07fa660..41e797e820 100644 --- a/Content.Server/Tiles/RequiresTileSystem.cs +++ b/Content.Server/Tiles/RequiresTileSystem.cs @@ -29,8 +29,6 @@ public sealed class RequiresTileSystem : EntitySystem foreach (var change in ev.Changes) { var anchored = _maps.GetAnchoredEntitiesEnumerator(ev.Entity, grid, change.GridIndices); - if (anchored.Equals(AnchoredEntitiesEnumerator.Empty)) - return; while (anchored.MoveNext(out var ent)) { diff --git a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs index 65d5e0adb2..812003aae8 100644 --- a/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SharedSubFloorHideSystem.cs @@ -125,10 +125,10 @@ namespace Content.Shared.SubFloor foreach (var change in args.Changes) { if (change.OldTile.IsEmpty) - return; // Nothing is anchored here anyways. + continue; // Nothing is anchored here anyways. if (change.NewTile.IsEmpty) - return; // Anything that was here will be unanchored anyways. + continue; // Anything that was here will be unanchored anyways. UpdateTile(args.Entity, args.Entity.Comp, change.GridIndices); }