mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-24 03:53:12 -04:00
Raise error if tilemap has no tiles
This commit is contained in:
parent
0abcd22728
commit
9c4e9f8877
@ -497,12 +497,13 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
|||||||
fun setTransients(ruleset: Ruleset? = null, setUnitCivTransients: Boolean = true) {
|
fun setTransients(ruleset: Ruleset? = null, setUnitCivTransients: Boolean = true) {
|
||||||
if (ruleset != null) this.ruleset = ruleset
|
if (ruleset != null) this.ruleset = ruleset
|
||||||
check(this.ruleset != null) { "TileMap.setTransients called without ruleset" }
|
check(this.ruleset != null) { "TileMap.setTransients called without ruleset" }
|
||||||
|
check(tileList.isNotEmpty()) { "No tiles were found in the save?!" }
|
||||||
|
|
||||||
if (tileMatrix.isEmpty()) {
|
if (tileMatrix.isEmpty()) {
|
||||||
val topY = tileList.asSequence().map { it.position.y.toInt() }.maxOrNull()!!
|
val topY = tileList.asSequence().map { it.position.y.toInt() }.max()
|
||||||
bottomY = tileList.asSequence().map { it.position.y.toInt() }.minOrNull()!!
|
bottomY = tileList.asSequence().map { it.position.y.toInt() }.min()
|
||||||
val rightX = tileList.asSequence().map { it.position.x.toInt() }.maxOrNull()!!
|
val rightX = tileList.asSequence().map { it.position.x.toInt() }.max()
|
||||||
leftX = tileList.asSequence().map { it.position.x.toInt() }.minOrNull()!!
|
leftX = tileList.asSequence().map { it.position.x.toInt() }.min()
|
||||||
|
|
||||||
// Initialize arrays with enough capacity to avoid re-allocations (+Arrays.copyOf).
|
// Initialize arrays with enough capacity to avoid re-allocations (+Arrays.copyOf).
|
||||||
// We have just calculated the dimensions above, so we know the final size.
|
// We have just calculated the dimensions above, so we know the final size.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user