Resolved #8044 - corner case where entire path to destination is full and destination is unenterable

This commit is contained in:
Yair Morgenstern
2022-11-24 09:53:31 +02:00
parent 002dcd763b
commit 4fff3a395e
2 changed files with 9 additions and 3 deletions

View File

@ -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 }

View File

@ -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)
}
}
/**