diff --git a/android/build.gradle b/android/build.gradle index 655c9de09a..b961fc4475 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -20,9 +20,9 @@ android { defaultConfig { applicationId "com.unciv.game" minSdkVersion 14 - targetSdkVersion 27 - versionCode 172 - versionName "2.10.9" + targetSdkVersion 28 + versionCode 173 + versionName "2.10.10" } // Had to add this crap for Travis to build, it wanted to sign the app diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index bee0867858..6884854293 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -183,13 +183,24 @@ class UnitMovementAlgorithms(val unit:MapUnit) { fun teleportToClosestMoveableTile(){ var allowedTile:TileInfo? = null var distance=0 - while(allowedTile==null){ + while(allowedTile==null && distance<5){ distance++ allowedTile = unit.getTile().getTilesAtDistance(distance) .firstOrNull{unit.canMoveTo(it)} } + + // No tile within 4 spaces? move him to a city. + // When we didn't limit the allowed distance the game would sometimes spend a whole minute looking for a suitable tile. + if(allowedTile==null){ + for(city in unit.civInfo.cities){ + allowedTile = city.getCenterTile().getTilesInDistance(1) + .firstOrNull { unit.canMoveTo(it) } + if(allowedTile!=null) break + } + } unit.removeFromTile() // we "teleport" them away - unit.putInTile(allowedTile) + if(allowedTile!=null) // it's possible that there is no close tile, and all the guy's cities are full. Screw him then. + unit.putInTile(allowedTile) } } \ No newline at end of file