Fixed a rare bug where unit would try to "walk" to a conquered city even though it was already in it

This commit is contained in:
Yair Morgenstern
2018-06-09 22:59:23 +03:00
parent 088583bd9d
commit b31e7ccc3d
2 changed files with 2 additions and 1 deletions

View File

@ -164,7 +164,7 @@ class Battle(val gameInfo:GameInfo=UnCivGame.Current.gameInfo) {
conquerCity((defender as CityCombatant).city, attacker)
}
if (attacker.isMelee() && (defender.isDefeated() || defender.getCivilization()==attacker.getCivilization() )) {
else if (attacker.isMelee() && (defender.isDefeated() || defender.getCivilization()==attacker.getCivilization() )) {
if(attackedTile.civilianUnit!=null)
captureCivilianUnit(attacker,MapUnitCombatant(attackedTile.civilianUnit!!))
(attacker as MapUnitCombatant).unit.moveToTile(attackedTile)

View File

@ -90,6 +90,7 @@ class MapUnit {
}
fun moveToTile(otherTile: TileInfo) {
if(otherTile==getTile()) return // already here!
val distanceToTiles = getDistanceToTiles()
if (!distanceToTiles.containsKey(otherTile))
throw Exception("You can't get there from here!")