diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index afc43fd302..5a5ce00b1d 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -786,7 +786,7 @@ namespace OpenRA public WPos CenterOfSubCell(CPos cell, SubCell subCell) { var index = (int)subCell; - if (index >= 0 && index <= Grid.SubCellOffsets.Length) + if (index >= 0 && index < Grid.SubCellOffsets.Length) return CenterOfCell(cell) + Grid.SubCellOffsets[index]; return CenterOfCell(cell); } diff --git a/OpenRA.Game/Map/MapGrid.cs b/OpenRA.Game/Map/MapGrid.cs index a48cddc0ef..5e2c643c16 100644 --- a/OpenRA.Game/Map/MapGrid.cs +++ b/OpenRA.Game/Map/MapGrid.cs @@ -168,7 +168,11 @@ namespace OpenRA if (subCell == SubCell.Invalid || subCell == SubCell.Any) return WVec.Zero; - return SubCellOffsets[(int)subCell]; + var index = (int)subCell; + if (index >= 0 && index < SubCellOffsets.Length) + return SubCellOffsets[index]; + + return WVec.Zero; } } }