From 967b76483a687b06b5bb3764ccd82ec6ae330de1 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Fri, 30 Apr 2021 01:11:16 +0200 Subject: [PATCH] Fix rendering tree system crash involving nullspace. Nullspace is a valid map, so we need to account for that! --- .../EntitySystems/RenderingTreeSystem.cs | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/Robust.Client/GameObjects/EntitySystems/RenderingTreeSystem.cs b/Robust.Client/GameObjects/EntitySystems/RenderingTreeSystem.cs index dfd858576..6580a95b9 100644 --- a/Robust.Client/GameObjects/EntitySystems/RenderingTreeSystem.cs +++ b/Robust.Client/GameObjects/EntitySystems/RenderingTreeSystem.cs @@ -144,6 +144,7 @@ namespace Robust.Client.GameObjects // Nullspace is a valid map ID for stuff to have but we also aren't gonna bother indexing it. // So that's why there's a GetValueOrDefault. var oldMapTrees = _gridTrees.GetValueOrDefault(ev.OldMapId); + var newMapTrees = _gridTrees.GetValueOrDefault(ev.Entity.Transform.MapID); // TODO: MMMM probably a better way to do this. if (ev.Entity.TryGetComponent(out SpriteComponent? sprite)) @@ -160,17 +161,10 @@ namespace Robust.Client.GameObjects foreach (var gridId in _mapManager.FindGridIdsIntersecting(ev.Entity.Transform.MapID, bounds, true)) { - Box2 gridBounds; + var gridBounds = gridId == GridId.Invalid + ? bounds : bounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); - if (gridId == GridId.Invalid) - { - gridBounds = bounds; - } - else - { - gridBounds = bounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); - } - _gridTrees[ev.Entity.Transform.MapID][gridId].SpriteTree.AddOrUpdate(sprite, gridBounds); + newMapTrees?[gridId].SpriteTree.AddOrUpdate(sprite, gridBounds); } } @@ -188,17 +182,10 @@ namespace Robust.Client.GameObjects foreach (var gridId in _mapManager.FindGridIdsIntersecting(ev.Entity.Transform.MapID, bounds, true)) { - Box2 gridBounds; + var gridBounds = gridId == GridId.Invalid + ? bounds : bounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); - if (gridId == GridId.Invalid) - { - gridBounds = bounds; - } - else - { - gridBounds = bounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); - } - _gridTrees[ev.Entity.Transform.MapID][gridId].LightTree.AddOrUpdate(light, gridBounds); + newMapTrees?[gridId].LightTree.AddOrUpdate(light, gridBounds); } } }