diff --git a/OpenRA.Game/Map/CellLayer.cs b/OpenRA.Game/Map/CellLayer.cs index 311c47c21f..6825ecb439 100644 --- a/OpenRA.Game/Map/CellLayer.cs +++ b/OpenRA.Game/Map/CellLayer.cs @@ -127,6 +127,12 @@ namespace OpenRA public bool Contains(CPos cell) { + // .ToMPos() returns the same result if the X and Y coordinates + // are switched. X < Y is invalid in the Diamond coordinate system, + // so we pre-filter these to avoid returning the wrong result + if (Shape == TileShape.Diamond && cell.X < cell.Y) + return false; + return Contains(cell.ToMPos(Shape)); } diff --git a/OpenRA.Game/Map/Map.cs b/OpenRA.Game/Map/Map.cs index a3d1fb7c7f..c733e3d90e 100644 --- a/OpenRA.Game/Map/Map.cs +++ b/OpenRA.Game/Map/Map.cs @@ -630,6 +630,12 @@ namespace OpenRA public bool Contains(CPos cell) { + // .ToMPos() returns the same result if the X and Y coordinates + // are switched. X < Y is invalid in the Diamond coordinate system, + // so we pre-filter these to avoid returning the wrong result + if (TileShape == TileShape.Diamond && cell.X < cell.Y) + return false; + return Contains(cell.ToMPos(this)); }