Reduce Map.Contains(CPos) cost in legacy mods

If a mod uses rectangular maps and no height levels,
checking if the CPos is within Bounds
should be enough and cheaper than the whole ToMPos
conversion and checks.
This commit is contained in:
reaperrr
2019-07-21 15:39:46 +02:00
committed by abcdefg30
parent 8ffd8ae822
commit b0a7865cfa

View File

@@ -752,6 +752,11 @@ namespace OpenRA
if (Grid.Type == MapGridType.RectangularIsometric && cell.X < cell.Y)
return false;
// If the mod uses flat & rectangular maps, ToMPos and Contains(MPos) create unnecessary cost.
// Just check if CPos is within map bounds.
if (Grid.MaximumTerrainHeight == 0 && Grid.Type == MapGridType.Rectangular)
return Bounds.Contains(cell.X, cell.Y);
return Contains(cell.ToMPos(this));
}