Skip to content

Commit

Permalink
Fix SubCell indexing in Map.CenterOfSubCell and MapGrid.OffsetOfSubCell
Browse files Browse the repository at this point in the history
  • Loading branch information
phrohdoh authored and pchote committed Nov 2, 2018
1 parent 8f1d8a6 commit 5899636
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion OpenRA.Game/Map/Map.cs
Expand Up @@ -786,7 +786,7 @@ public WPos CenterOfCell(CPos cell)
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);
}
Expand Down
6 changes: 5 additions & 1 deletion OpenRA.Game/Map/MapGrid.cs
Expand Up @@ -168,7 +168,11 @@ public WVec OffsetOfSubCell(SubCell subCell)
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;
}
}
}

0 comments on commit 5899636

Please sign in to comment.