Reorder bounds check & rotation swap

Closes #529
This commit is contained in:
Kurt
2021-11-08 15:21:36 -08:00
parent 3e7bacb80b
commit bb2ea75f58

View File

@@ -121,11 +121,6 @@ public PlacedItemPermission IsOccupied(Item tile, in int x, in int y)
var w = type.GetWidth();
var h = type.GetHeight();
if (x + w - 1 >= MaxWidth)
return PlacedItemPermission.OutOfBounds;
if (y + h - 1 >= MaxHeight)
return PlacedItemPermission.OutOfBounds;
if ((tile.Rotation & 1) == 1)
{
var tmp = w;
@@ -133,6 +128,11 @@ public PlacedItemPermission IsOccupied(Item tile, in int x, in int y)
h = tmp;
}
if (x + w - 1 >= MaxWidth)
return PlacedItemPermission.OutOfBounds;
if (y + h - 1 >= MaxHeight)
return PlacedItemPermission.OutOfBounds;
for (byte ix = 0; ix < w; ix++)
{
for (byte iy = 0; iy < h; iy++)