mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-06 08:21:36 +07:00
Resolved #8044 - corner case where entire path to destination is full and destination is unenterable
This commit is contained in:
@ -124,10 +124,11 @@ class PopulationManager : IsPartOfGameInfoSerialization {
|
||||
|
||||
val currentCiv = cityInfo.civInfo
|
||||
|
||||
val tilesToEvaluate = cityInfo.getCenterTile().getTilesInDistance(3)
|
||||
.filter { it.getOwner() == currentCiv }.toList().asSequence()
|
||||
for (i in 1..getFreePopulation()) {
|
||||
//evaluate tiles
|
||||
val (bestTile, valueBestTile) = cityInfo.getCenterTile().getTilesInDistance(3)
|
||||
.filter { it.getOwner() == currentCiv }
|
||||
val (bestTile, valueBestTile) = tilesToEvaluate
|
||||
.filterNot { it.providesYield() }
|
||||
.associateWith { Automation.rankTileForCityWork(it, cityInfo, cityStats) }
|
||||
.maxByOrNull { it.value }
|
||||
|
@ -552,7 +552,12 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
&& (origin.isCityCenter() || finalTileReached.isCityCenter())
|
||||
&& unit.civInfo.hasUnique(UniqueType.UnitsInCitiesNoMaintenance)
|
||||
) unit.civInfo.updateStatsForNextTurn()
|
||||
if (needToFindNewRoute) moveToTile(destination, considerZoneOfControl)
|
||||
|
||||
// Under rare cases (see #8044), we can be headed to a tile and *the entire path* is blocked by other units, so we can't "enter" that tile.
|
||||
// If, in such conditions, the *destination tile* is unenterable, needToFindNewRoute will trigger, so we need to catch this situation to avoid infinite loop
|
||||
if (needToFindNewRoute && unit.currentTile != origin) {
|
||||
moveToTile(destination, considerZoneOfControl)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user