From 48bbed9fad258bb055fcf955c8c322d680b30c15 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Tue, 15 Feb 2022 10:47:47 +0200 Subject: [PATCH] Resolved #6164 - transported units reveal tiles as if they passed through the path of the transporting unit --- core/src/com/unciv/logic/map/MapUnit.kt | 1 - .../com/unciv/logic/map/UnitMovementAlgorithms.kt | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/logic/map/MapUnit.kt b/core/src/com/unciv/logic/map/MapUnit.kt index bde7da410a..696669784e 100644 --- a/core/src/com/unciv/logic/map/MapUnit.kt +++ b/core/src/com/unciv/logic/map/MapUnit.kt @@ -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() } diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index da4d1b7286..6bfacacdc7 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -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)