Resolved #6164 - transported units reveal tiles as if they passed through the path of the transporting unit

This commit is contained in:
Yair Morgenstern 2022-02-15 10:47:47 +02:00
parent 1e44b1a235
commit 48bbed9fad
2 changed files with 9 additions and 4 deletions

View File

@ -403,7 +403,6 @@ class MapUnit {
viewableTiles = if (hasUnique(UniqueType.SixTilesAlwaysVisible))
getTile().getTilesInDistance(6).toHashSet() // it's that simple
else HashSet(0) // bomber units don't do recon
return
} else {
viewableTiles = getTile().getViewableTilesList(getVisibilityRange()).toHashSet()
}

View File

@ -485,6 +485,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
break
}
}
val finalTileReached = lastReachedEnterableTile
// Silly floats which are almost zero
if (unit.currentMovement < Constants.minimumMovementEpsilon)
@ -492,20 +494,24 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
if (!unit.isDestroyed)
unit.putInTile(lastReachedEnterableTile)
unit.putInTile(finalTileReached)
// The .toList() here is because we have a sequence that's running on the units in the tile,
// then if we move one of the units we'll get a ConcurrentModificationException, se we save them all to a list
for (payload in origin.getUnits().filter { it.isTransported && unit.canTransport(it) }.toList()) { // bring along the payloads
payload.removeFromTile()
payload.putInTile(lastReachableTile)
for (tile in pathToLastReachableTile){
payload.moveThroughTile(tile)
if (tile == finalTileReached) break // this is the final tile the transport reached
}
payload.putInTile(finalTileReached)
payload.isTransported = true // restore the flag to not leave the payload in the cit
payload.mostRecentMoveType = UnitMovementMemoryType.UnitMoved
}
// Unit maintenance changed
if (unit.canGarrison()
&& (origin.isCityCenter() || lastReachableTile.isCityCenter())
&& (origin.isCityCenter() || finalTileReached.isCityCenter())
&& unit.civInfo.hasUnique(UniqueType.UnitsInCitiesNoMaintenance)
) unit.civInfo.updateStatsForNextTurn()
if (needToFindNewRoute) moveToTile(destination, considerZoneOfControl)