From 20f68d156e6f946522122721effc73594bf6ca77 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Mon, 17 Oct 2022 04:50:11 +1300 Subject: [PATCH] Add some atmos logs for debugging (#11970) --- .../AtmosphereSystem.Monstermos.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs index c054946b41..2b4978ccc3 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.Monstermos.cs @@ -7,6 +7,7 @@ using Robust.Shared.Map; using Robust.Shared.Physics.Components; using Robust.Shared.Random; using Robust.Shared.Utility; +using System.Linq; namespace Content.Server.Atmos.EntitySystems { @@ -582,9 +583,24 @@ namespace Content.Server.Atmos.EntitySystems DebugTools.AssertNotNull(tile); DebugTools.Assert(tile.AdjacentBits.IsFlagSet(direction)); DebugTools.Assert(tile.AdjacentTiles[direction.ToIndex()] != null); - tile.MonstermosInfo[direction] += amount; // Every call to this method already ensures that the adjacent tile won't be null. - tile.AdjacentTiles[direction.ToIndex()]!.MonstermosInfo[direction.GetOpposite()] -= amount; + + // Turns out: no they don't. Temporary debug checks to figure out which caller is causing problems: + if (tile == null) + { + Logger.Error($"Encountered null-tile in {nameof(AdjustEqMovement)}. Trace: {Environment.StackTrace}"); + return; + } + var adj = tile.AdjacentTiles[direction.ToIndex()]; + if (adj == null) + { + var nonNull = tile.AdjacentTiles.Where(x => x != null).Count(); + Logger.Error($"Encountered null adjacent tile in {nameof(AdjustEqMovement)}. Dir: {direction}, Tile: {tile.Tile}, non-null adj count: {nonNull}, Trace: {Environment.StackTrace}"); + return; + } + + tile.MonstermosInfo[direction] += amount; + adj.MonstermosInfo[direction.GetOpposite()] -= amount; } private void HandleDecompressionFloorRip(IMapGrid mapGrid, TileAtmosphere tile, float sum)