From 20f5672337175bd0c46b5ef92e9d421036a7a023 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 13 Mar 2021 23:02:57 +0200 Subject: [PATCH] Resolved #3686 - world wrapped 'continents' map now separates continents properly --- .../map/mapgenerator/MapLandmassGenerator.kt | 10 +++++++++- .../logic/map/mapgenerator/RiverGenerator.kt | 19 +++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt b/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt index d392605596..0d681ef08e 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/MapLandmassGenerator.kt @@ -89,8 +89,16 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) { } private fun getTwoContinentsTransform(tileInfo: TileInfo, tileMap: TileMap): Double { + // The idea here is to create a water area separating the two land areas. + // So what we do it create a line of water in the middle - where longitude is close to 0. val randomScale = randomness.RNG.nextDouble() - val longitudeFactor = abs(tileInfo.longitude) / tileMap.maxLongitude + var longitudeFactor = abs(tileInfo.longitude) / tileMap.maxLongitude + + // If this is a world wrap, we want it to be separated on both sides - + // so we make the actual strip of water thinner, but we put it both in the middle of the map and on the edges of the map + if (tileMap.mapParameters.worldWrap) + longitudeFactor = min(longitudeFactor, + (tileMap.maxLongitude - abs(tileInfo.longitude)) / tileMap.maxLongitude) * 1.5f return min(0.2, -1.0 + (5.0 * longitudeFactor.pow(0.6f) + randomScale) / 3.0) } diff --git a/core/src/com/unciv/logic/map/mapgenerator/RiverGenerator.kt b/core/src/com/unciv/logic/map/mapgenerator/RiverGenerator.kt index fd0529fd5a..5694aaea5f 100644 --- a/core/src/com/unciv/logic/map/mapgenerator/RiverGenerator.kt +++ b/core/src/com/unciv/logic/map/mapgenerator/RiverGenerator.kt @@ -50,27 +50,26 @@ class RiverGenerator(val randomness: MapGenerationRandomness){ RiverCoordinate.BottomRightOrLeft.values().random(randomness.RNG)) - while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }){ + while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }) { val possibleCoordinates = riverCoordinate.getAdjacentPositions() .filter { map.contains(it.position) } - if(possibleCoordinates.none()) return // end of the line + if (possibleCoordinates.none()) return // end of the line val newCoordinate = possibleCoordinates - .groupBy { getAdjacentTiles(it,map).map { it.aerialDistanceTo(endPosition) }.min()!! } + .groupBy { getAdjacentTiles(it, map).map { it.aerialDistanceTo(endPosition) }.min()!! } .minBy { it.key }!! .component2().random(randomness.RNG) // set new rivers in place val riverCoordinateTile = map[riverCoordinate.position] - if(newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left - riverCoordinateTile.hasBottomRiver=true - else if(riverCoordinate.bottomRightOrLeft== RiverCoordinate.BottomRightOrLeft.BottomRight){ - if(getAdjacentTiles(newCoordinate,map).contains(riverCoordinateTile)) // moved from our 5 O'Clock to our 3 O'Clock + if (newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left + riverCoordinateTile.hasBottomRiver = true + else if (riverCoordinate.bottomRightOrLeft == RiverCoordinate.BottomRightOrLeft.BottomRight) { + if (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 5 O'Clock to our 3 O'Clock riverCoordinateTile.hasBottomRightRiver = true else // moved from our 5 O'Clock down in the 5 O'Clock direction - this is the 8 O'Clock river of the tile to our 4 O'Clock! map[newCoordinate.position].hasBottomLeftRiver = true - } - else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left - if(getAdjacentTiles(newCoordinate,map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock + } else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left + if (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock riverCoordinateTile.hasBottomLeftRiver = true else // moved from our 7 O'Clock down in the 7 O'Clock direction map[newCoordinate.position].hasBottomRightRiver = true