mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 03:23:17 -04:00
Fixed crash when settler didn't find a good city spot within 5 tiles
This commit is contained in:
parent
96a0961130
commit
ec760e660f
@ -21,8 +21,8 @@ android {
|
|||||||
applicationId "com.unciv.game"
|
applicationId "com.unciv.game"
|
||||||
minSdkVersion 14
|
minSdkVersion 14
|
||||||
targetSdkVersion 26
|
targetSdkVersion 26
|
||||||
versionCode 52
|
versionCode 54
|
||||||
versionName "2.1.2"
|
versionName "2.1.4"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
@ -133,9 +133,16 @@ class UnitAutomation{
|
|||||||
// This is to improve performance - instead of ranking each tile in the area up to 19 times, do it once.
|
// This is to improve performance - instead of ranking each tile in the area up to 19 times, do it once.
|
||||||
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
val nearbyTileRankings = unit.getTile().getTilesInDistance(7)
|
||||||
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
.associateBy ( {it},{ Automation().rankTile(it,unit.civInfo) })
|
||||||
val bestCityLocation = unit.getTile().getTilesInDistance(5)
|
var bestCityLocation = unit.getTile().getTilesInDistance(5)
|
||||||
.minus(tilesNearCities)
|
.minus(tilesNearCities)
|
||||||
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }!!
|
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }
|
||||||
|
|
||||||
|
if(bestCityLocation==null) { // We got a badass over here, all tiles within 5 are taken? SEARCH EVERYWHERE
|
||||||
|
bestCityLocation = unit.civInfo.getViewableTiles()
|
||||||
|
.minus(tilesNearCities)
|
||||||
|
.maxBy { rankTileAsCityCenter(it, nearbyTileRankings) }
|
||||||
|
}
|
||||||
|
bestCityLocation!!
|
||||||
|
|
||||||
if (unit.getTile() == bestCityLocation)
|
if (unit.getTile() == bestCityLocation)
|
||||||
UnitActions().getUnitActions(unit, UnCivGame.Current.worldScreen!!).first { it.name == "Found city" }.action()
|
UnitActions().getUnitActions(unit, UnCivGame.Current.worldScreen!!).first { it.name == "Found city" }.action()
|
||||||
|
@ -122,7 +122,7 @@ class CivStatsTable(val screen: WorldScreen) : Table() {
|
|||||||
|
|
||||||
val turnsToNextPolicy = (civInfo.policies.getCultureNeededForNextPolicy() - civInfo.policies.storedCulture) / nextTurnStats.culture
|
val turnsToNextPolicy = (civInfo.policies.getCultureNeededForNextPolicy() - civInfo.policies.storedCulture) / nextTurnStats.culture
|
||||||
var cultureString = "+" + Math.round(nextTurnStats.culture)
|
var cultureString = "+" + Math.round(nextTurnStats.culture)
|
||||||
if(turnsToNextPolicy>0) cultureString+= " ("+ ceil(turnsToNextPolicy)+")"
|
if(turnsToNextPolicy>0) cultureString+= " ("+ ceil(turnsToNextPolicy).toInt()+")"
|
||||||
else cultureString += " (!)"
|
else cultureString += " (!)"
|
||||||
cultureLabel.setText(cultureString)
|
cultureLabel.setText(cultureString)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user