mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-12 10:59:55 +07:00
Fixed crashing bug where map generation would try to have rivers going off-map
This commit is contained in:
parent
22fd10498e
commit
9496c4523e
@ -52,13 +52,12 @@ class RiverGenerator(val randomness: MapGenerationRandomness){
|
||||
|
||||
while(getAdjacentTiles(riverCoordinate,map).none { it.isWater }){
|
||||
val possibleCoordinates = riverCoordinate.getAdjacentPositions()
|
||||
.filter { map.contains(it.position) }
|
||||
if(possibleCoordinates.none()) return // end of the line
|
||||
val newCoordinate = possibleCoordinates
|
||||
// .sortedBy { numberOfConnectedRivers(it,map) }
|
||||
.groupBy { getAdjacentTiles(it,map).map { it.aerialDistanceTo(endPosition) }.min()!! }
|
||||
.minBy { it.key }!!
|
||||
.component2().random(randomness.RNG)
|
||||
// .minBy { getAdjacentTiles(it,map).map { it.aerialDistanceTo(endPosition) }.min()!! }!!
|
||||
|
||||
// set new rivers in place
|
||||
val riverCoordinateTile = map[riverCoordinate.position]
|
||||
|
@ -110,14 +110,16 @@ class NewGameScreen(previousScreen:CameraStageBaseScreen, _gameSetupInfo: GameSe
|
||||
}
|
||||
}
|
||||
} catch (exception: Exception) {
|
||||
val cantMakeThatMapPopup = Popup(this)
|
||||
cantMakeThatMapPopup.addGoodSizedLabel("It looks like we can't make a map with the parameters you requested!".tr()).row()
|
||||
cantMakeThatMapPopup.addGoodSizedLabel("Maybe you put too many players into too small a map?".tr()).row()
|
||||
cantMakeThatMapPopup.addCloseButton()
|
||||
cantMakeThatMapPopup.open()
|
||||
Gdx.input.inputProcessor = stage
|
||||
rightSideButton.enable()
|
||||
rightSideButton.setText("Start game!".tr())
|
||||
Gdx.app.postRunnable {
|
||||
val cantMakeThatMapPopup = Popup(this)
|
||||
cantMakeThatMapPopup.addGoodSizedLabel("It looks like we can't make a map with the parameters you requested!".tr()).row()
|
||||
cantMakeThatMapPopup.addGoodSizedLabel("Maybe you put too many players into too small a map?".tr()).row()
|
||||
cantMakeThatMapPopup.addCloseButton()
|
||||
cantMakeThatMapPopup.open()
|
||||
Gdx.input.inputProcessor = stage
|
||||
rightSideButton.enable()
|
||||
rightSideButton.setText("Start game!".tr())
|
||||
}
|
||||
}
|
||||
Gdx.graphics.requestRendering()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user