From 387693512cf1c60045792964c8dd7e7fdcb9efb7 Mon Sep 17 00:00:00 2001 From: GGGuenni Date: Thu, 1 Apr 2021 13:36:05 +0200 Subject: [PATCH] Fixed roads not getting wrapped correctly (#3752) --- core/src/com/unciv/logic/map/TileInfo.kt | 4 ++-- core/src/com/unciv/ui/tilegroups/TileGroup.kt | 10 +++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/map/TileInfo.kt b/core/src/com/unciv/logic/map/TileInfo.kt index 8f6035a654..9851dd37b1 100644 --- a/core/src/com/unciv/logic/map/TileInfo.kt +++ b/core/src/com/unciv/logic/map/TileInfo.kt @@ -443,9 +443,9 @@ open class TileInfo { return when (tileMap.getNeighborTileClockPosition(this, otherTile)) { 2 -> otherTile.hasBottomLeftRiver // we're to the bottom-left of it - 4 -> hasBottomRightRiver // we're to the top-right of it + 4 -> hasBottomRightRiver // we're to the top-left of it 6 -> hasBottomRiver // we're directly above it - 8 -> hasBottomLeftRiver // we're to the top-left of it + 8 -> hasBottomLeftRiver // we're to the top-right of it 10 -> otherTile.hasBottomRightRiver // we're to the bottom-right of it 12 -> otherTile.hasBottomRiver // we're directly below it else -> throw Exception("Should never call this function on a non-neighbor!") diff --git a/core/src/com/unciv/ui/tilegroups/TileGroup.kt b/core/src/com/unciv/ui/tilegroups/TileGroup.kt index 25bbd2912f..081e9d999a 100644 --- a/core/src/com/unciv/ui/tilegroups/TileGroup.kt +++ b/core/src/com/unciv/ui/tilegroups/TileGroup.kt @@ -581,7 +581,15 @@ open class TileGroup(var tileInfo: TileInfo, var tileSetStrings:TileSetStrings) else ImageGetter.getImage(tileSetStrings.railroad) roadImage.image = image - val relativeHexPosition = tileInfo.position.cpy().sub(neighbor.position) + val relativeHexPosition = when (tileInfo.tileMap.getNeighborTileClockPosition(neighbor, tileInfo)){ + 2 -> Vector2(0f,1f) + 4 -> Vector2(-1f,0f) + 6 -> Vector2(-1f,-1f) + 8 -> Vector2(0f,-1f) + 10 -> Vector2(1f,0f) + 12 -> Vector2(1f,1f) + else -> Vector2.Zero + } val relativeWorldPosition = HexMath.hex2WorldCoords(relativeHexPosition) // This is some crazy voodoo magic so I'll explain.