mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-20 09:17:47 +07:00
Solved a super-rare bug where the game would get stuck if you expanded the city onto a tile with an enemy that couldn't be teleported anywhere else - kudos Groundless Name!
This commit is contained in:
parent
c12906f63b
commit
bc1b1e7672
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user