From 1316271ac694de7a3269f06342dc769732771cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Dufour?= Date: Sun, 17 Dec 2023 21:02:45 +0100 Subject: [PATCH] avoid initializing with terrain that shouldn't be naturally generated (#10756) * avoid initializing with terrain that shouldn't be naturally generated * add space * fix partial generation freeze * one-liner unique check --- .../com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt b/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt index 8bb21fee82..93b0f9bff7 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt @@ -7,6 +7,7 @@ import com.unciv.logic.map.TileMap import com.unciv.logic.map.tile.Tile import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.tile.TerrainType +import com.unciv.models.ruleset.unique.UniqueType import kotlin.math.abs import kotlin.math.max import kotlin.math.min @@ -28,7 +29,7 @@ class MapLandmassGenerator(val ruleset: Ruleset, val randomness: MapGenerationRa companion object { // this is called from TileMap constructors as well internal fun getInitializationTerrain(ruleset: Ruleset, type: TerrainType) = - ruleset.terrains.values.firstOrNull { it.type == type }?.name + ruleset.terrains.values.firstOrNull { it.type == type && !it.hasUnique(UniqueType.NoNaturalGeneration) }?.name ?: throw Exception("Cannot create map - no $type terrains found!") } @@ -157,6 +158,7 @@ class MapLandmassGenerator(val ruleset: Ruleset, val randomness: MapGenerationRa var elevation = randomness.getPerlinNoise(tile, elevationSeed) elevation = elevation * (3 / 4f) + getEllipticContinent(tile, tileMap) / 4 spawnLandOrWater(tile, elevation) + tile.setTerrainTransients() // necessary for assignContinents } tileMap.assignContinents(TileMap.AssignContinentsMode.Reassign)