From 551c204a9f81b814fc1297a04e474de5c3889f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Fri, 7 Aug 2020 02:33:08 +0200 Subject: [PATCH] Fix GetGridAtmosphere crash --- Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs index 46d90d7640..4faabfe44b 100644 --- a/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AtmosphereSystem.cs @@ -33,8 +33,11 @@ namespace Content.Server.GameObjects.EntitySystems public IGridAtmosphereComponent? GetGridAtmosphere(GridId gridId) { + // TODO Return space grid atmosphere for invalid grids or grids with no atmos var grid = _mapManager.GetGrid(gridId); - var gridEnt = _entityManager.GetEntity(grid.GridEntityId); + + if (!_entityManager.TryGetEntity(grid.GridEntityId, out var gridEnt)) return null; + return gridEnt.TryGetComponent(out IGridAtmosphereComponent atmos) ? atmos : null; }