mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-04 23:40:01 +07:00
perf(memory): Don't store city distances intermediately
This commit is contained in:
@ -647,13 +647,17 @@ object NextTurnAutomation {
|
||||
fun getClosestCities(civ1: Civilization, civ2: Civilization): CityDistance? {
|
||||
if (civ1.cities.isEmpty() || civ2.cities.isEmpty())
|
||||
return null
|
||||
|
||||
var minDistance: CityDistance? = null
|
||||
|
||||
val cityDistances = arrayListOf<CityDistance>()
|
||||
for (civ1city in civ1.cities)
|
||||
for (civ2city in civ2.cities)
|
||||
cityDistances += CityDistance(civ1city, civ2city,
|
||||
for (civ2city in civ2.cities){
|
||||
val currentDistance = CityDistance(civ1city, civ2city,
|
||||
civ1city.getCenterTile().aerialDistanceTo(civ2city.getCenterTile()))
|
||||
if (minDistance == null || currentDistance.aerialDistance < minDistance.aerialDistance)
|
||||
minDistance = currentDistance
|
||||
}
|
||||
|
||||
return cityDistances.minByOrNull { it.aerialDistance }!!
|
||||
return minDistance
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ class WorkerAutomation(
|
||||
if (tile.hasViewableResource(civInfo)) valueOfFort -= 1
|
||||
|
||||
// if this place is not perfect, let's see if there is a better one
|
||||
val nearestTiles = tile.getTilesInDistance(1).filter { it.owningCity?.civ == civInfo }.toList()
|
||||
val nearestTiles = tile.getTilesInDistance(1).filter { it.owningCity?.civ == civInfo }
|
||||
for (closeTile in nearestTiles) {
|
||||
// don't build forts too close to the cities
|
||||
if (closeTile.isCityCenter()) {
|
||||
|
@ -54,7 +54,7 @@ class TileLayerTerrain(tileGroup: TileGroup, size: Float) : TileLayer(tileGroup,
|
||||
|
||||
val baseHexagon = if (strings().tileSetConfig.useColorAsBaseTerrain)
|
||||
listOf(strings().hexagon)
|
||||
else listOf()
|
||||
else emptyList()
|
||||
|
||||
val tile = tileGroup.tile
|
||||
|
||||
|
Reference in New Issue
Block a user