diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 0aca54a134..1951fbb17e 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -663,7 +663,8 @@ open class TileInfo { } } - fun isAdjacentToRiver() = neighbors.any { isConnectedByRiver(it) } + private val isAdjacentToRiverLazy by lazy { neighbors.any { isConnectedByRiver(it) } } + fun isAdjacentToRiver() = isAdjacentToRiverLazy /** * @returns whether units of [civInfo] can pass through this tile, considering only civ-wide filters. diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index a743778b88..3a1a1af6d9 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -40,7 +40,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { return RoadStatus.Railroad.movement + extraCost val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo) - val areConnectedByRiver = from.isConnectedByRiver(to) + val areConnectedByRiver = from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to) if (areConnectedByRoad && (!areConnectedByRiver || civInfo.tech.roadsConnectAcrossRivers)) return unit.civInfo.tech.movementSpeedOnRoads + extraCost diff --git a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt index 8cea9c8032..34302c89e9 100644 --- a/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt +++ b/core/src/com/unciv/models/ruleset/unit/BaseUnit.kt @@ -577,7 +577,8 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction { fun isMilitary() = isRanged() || isMelee() fun isCivilian() = !isMilitary() - fun isLandUnit() = getType().isLandUnit() + val isLandUnitInternal by lazy { getType().isLandUnit() } + fun isLandUnit() = isLandUnitInternal fun isWaterUnit() = getType().isWaterUnit() fun isAirUnit() = getType().isAirUnit()