From 2ab4e406aac0b832fdb20b6c988a2eeb16cf6d8b Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Wed, 21 Nov 2018 16:31:14 +0200 Subject: [PATCH] Fixed bug where auto-assigned population in cities could work tiles outside of 3-tile range --- core/src/com/unciv/logic/city/PopulationManager.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/logic/city/PopulationManager.kt b/core/src/com/unciv/logic/city/PopulationManager.kt index 373ba42afb..e4b3478ef7 100644 --- a/core/src/com/unciv/logic/city/PopulationManager.kt +++ b/core/src/com/unciv/logic/city/PopulationManager.kt @@ -78,6 +78,7 @@ class PopulationManager { internal fun autoAssignPopulation() { if(getFreePopulation()==0) return val toWork: TileInfo? = cityInfo.getTiles() + .filter { it.arialDistanceTo(cityInfo.getCenterTile()) <= 3 } .filterNot { cityInfo.workedTiles.contains(it.position) || cityInfo.location==it.position} .maxBy { Automation().rankTile(it,cityInfo.civInfo) } if (toWork != null) // This is when we've run out of tiles! @@ -85,9 +86,12 @@ class PopulationManager { } fun unassignExtraPopulation() { - for(tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) - if(tile.getCity()!=cityInfo) + for(tile in cityInfo.workedTiles.map { cityInfo.tileMap[it] }) { + if (tile.getCity() != cityInfo) cityInfo.workedTiles.remove(tile.position) + if(tile.arialDistanceTo(cityInfo.getCenterTile()) > 3) // AutoAssignPopulation used to assign pop outside of allowed range, fixed as of 2.10.4 + cityInfo.workedTiles.remove(tile.position) + } while (cityInfo.workedTiles.size > population) { val lowestRankedWorkedTile = cityInfo.workedTiles