From 41a124d29e0d8803d47c9ef1a39f021ceccac140 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 28 Apr 2024 13:21:16 +0300 Subject: [PATCH] RISKY - *actually* move units into tiles along the path - this should solve the "ruins bonus generates units that then block path" as well as giving correct LOS reveals for intermediate tiles when units are escorted This also makes the code a lot simpler, but may reveal unintended side effects, so we should be on the lookout --- .../logic/map/mapunit/movement/UnitMovement.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt index a65f5cfa45..12991d6ebc 100644 --- a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt +++ b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt @@ -450,7 +450,6 @@ class UnitMovement(val unit: MapUnit) { needToFindNewRoute = true break // If you ever remove this break, remove the `assumeCanPassThrough` param below } - unit.moveThroughTile(tile) // This fixes a bug where tiles in the fog of war would always only cost 1 mp if (!unit.civ.gameInfo.gameParameters.godMode) @@ -461,6 +460,13 @@ class UnitMovement(val unit: MapUnit) { if (unit.movement.canMoveTo(tile, assumeCanPassThrough = true)) { lastReachedEnterableTile = tile unit.useMovementPoints(passingMovementSpent) + unit.putInTile(tile) // Required for ruins, + + if (escortUnit != null) { + escortUnit.movement.moveToTile(tile) + unit.startEscorting() // Need to re-apply this + } + passingMovementSpent = 0f } @@ -479,9 +485,6 @@ class UnitMovement(val unit: MapUnit) { unit.currentMovement = 0f - if (!unit.isDestroyed) - 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 val payloadUnits = origin.getUnits().filter { it.isTransported && unit.canTransport(it) }.toList() @@ -496,10 +499,6 @@ class UnitMovement(val unit: MapUnit) { payload.isTransported = true // restore the flag to not leave the payload in the city payload.mostRecentMoveType = UnitMovementMemoryType.UnitMoved } - if (escortUnit != null) { - escortUnit.movement.moveToTile(finalTileReached) - unit.startEscorting() // Need to re-apply this - } // Unit maintenance changed if (unit.canGarrison()