Fix SubCell indexing in Map.CenterOfSubCell and MapGrid.OffsetOfSubCell

This commit is contained in:
Taryn Hill
2018-11-01 11:17:14 -05:00
committed by Paul Chote
parent 8f1d8a67cc
commit 5899636e10
2 changed files with 6 additions and 2 deletions

View File

@@ -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);
}

View File

@@ -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;
}
}
}