Map.Contains check grid type once.
This commit is contained in:
@@ -788,16 +788,21 @@ namespace OpenRA
|
|||||||
|
|
||||||
public bool Contains(CPos cell)
|
public bool Contains(CPos cell)
|
||||||
{
|
{
|
||||||
// .ToMPos() returns the same result if the X and Y coordinates
|
if (Grid.Type == MapGridType.RectangularIsometric)
|
||||||
// are switched. X < Y is invalid in the RectangularIsometric coordinate system,
|
{
|
||||||
// so we pre-filter these to avoid returning the wrong result
|
// .ToMPos() returns the same result if the X and Y coordinates
|
||||||
if (Grid.Type == MapGridType.RectangularIsometric && cell.X < cell.Y)
|
// are switched. X < Y is invalid in the RectangularIsometric coordinate system,
|
||||||
return false;
|
// so we pre-filter these to avoid returning the wrong result
|
||||||
|
if (cell.X < cell.Y)
|
||||||
// If the mod uses flat & rectangular maps, ToMPos and Contains(MPos) create unnecessary cost.
|
return false;
|
||||||
// Just check if CPos is within map bounds.
|
}
|
||||||
if (Grid.MaximumTerrainHeight == 0 && Grid.Type == MapGridType.Rectangular)
|
else
|
||||||
return Bounds.Contains(cell.X, cell.Y);
|
{
|
||||||
|
// 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)
|
||||||
|
return Bounds.Contains(cell.X, cell.Y);
|
||||||
|
}
|
||||||
|
|
||||||
return Contains(cell.ToMPos(this));
|
return Contains(cell.ToMPos(this));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user