Fix map setTransients throwing exception from map generator on some map sizes (#5084)

This commit is contained in:
SomeTroglodyte
2021-09-04 20:27:13 +02:00
committed by GitHub
parent 60abae5d1a
commit 84f7d4f56b

View File

@ -367,8 +367,8 @@ class TileMap {
} }
} else { } else {
// Yes the map generator calls this repeatedly, and we don't want to end up with an oversized tileMatrix // Yes the map generator calls this repeatedly, and we don't want to end up with an oversized tileMatrix
// rightX is -leftX or -leftX + 1 // rightX is -leftX or -leftX + 1 or -leftX + 2
if (tileMatrix.size != 1 - 2 * leftX && tileMatrix.size != 2 - 2 * leftX) if (tileMatrix.size !in (1 - 2 * leftX)..(3 - 2 * leftX))
throw(IllegalStateException("TileMap.setTransients called on existing tileMatrix of different size")) throw(IllegalStateException("TileMap.setTransients called on existing tileMatrix of different size"))
} }