From 42256bc262bfabbfb8ceabe03deaeaa74682854a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Fri, 1 May 2020 17:31:44 +0200 Subject: [PATCH] Add an out of bounds check. --- .../Traits/Conditions/GrantConditionOnTerrain.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs index 8e3e783fe0..c66a62dbea 100644 --- a/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs +++ b/OpenRA.Mods.Common/Traits/Conditions/GrantConditionOnTerrain.cs @@ -50,13 +50,16 @@ namespace OpenRA.Mods.Common.Traits void ITick.Tick(Actor self) { - var loc = self.Location; + var cell = self.Location; + if (!self.World.Map.Contains(cell)) + return; + if (conditionManager == null) return; // The terrain type may change between ticks without the actor moving - var currentTerrain = loc.Layer == 0 ? self.World.Map.GetTerrainInfo(loc).Type : - tileSet[self.World.GetCustomMovementLayers()[loc.Layer].GetTerrainIndex(loc)].Type; + var currentTerrain = cell.Layer == 0 ? self.World.Map.GetTerrainInfo(cell).Type : + tileSet[self.World.GetCustomMovementLayers()[cell.Layer].GetTerrainIndex(cell)].Type; var wantsGranted = info.TerrainTypes.Contains(currentTerrain); if (currentTerrain != cachedTerrain)