mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Fix: ships being teleported into landlocked cities (#1718)
* Fix: ships being teleported into landlocked cities * Proposal: extend the city teleport to all owned tiles * Utilizing the existing method Co-authored-by: dumichno <57294813+dumichno@users.noreply.github.com>
This commit is contained in:
parent
014220c480
commit
7805f90dab
@ -188,6 +188,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
fun teleportToClosestMoveableTile(){
|
fun teleportToClosestMoveableTile(){
|
||||||
var allowedTile:TileInfo? = null
|
var allowedTile:TileInfo? = null
|
||||||
var distance=0
|
var distance=0
|
||||||
|
// When we didn't limit the allowed distance the game would sometimes spend a whole minute looking for a suitable tile.
|
||||||
while(allowedTile==null && distance<5){
|
while(allowedTile==null && distance<5){
|
||||||
distance++
|
distance++
|
||||||
allowedTile = unit.getTile().getTilesAtDistance(distance)
|
allowedTile = unit.getTile().getTilesAtDistance(distance)
|
||||||
@ -195,10 +196,9 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No tile within 4 spaces? move him to a city.
|
// 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){
|
if(allowedTile==null){
|
||||||
for(city in unit.civInfo.cities){
|
for(city in unit.civInfo.cities){
|
||||||
allowedTile = city.getCenterTile().getTilesInDistance(1)
|
allowedTile = city.getTiles()
|
||||||
.firstOrNull { canMoveTo(it) }
|
.firstOrNull { canMoveTo(it) }
|
||||||
if(allowedTile!=null) break
|
if(allowedTile!=null) break
|
||||||
}
|
}
|
||||||
@ -276,7 +276,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||||||
// because optimization on this function results in massive benefits!
|
// because optimization on this function results in massive benefits!
|
||||||
fun canPassThrough(tile: TileInfo):Boolean{
|
fun canPassThrough(tile: TileInfo):Boolean{
|
||||||
if(tile.getBaseTerrain().impassable) return false
|
if(tile.getBaseTerrain().impassable) return false
|
||||||
if(tile.isLand && unit.type.isWaterUnit() && !tile.isCityCenter())
|
if (tile.isLand
|
||||||
|
&& unit.type.isWaterUnit()
|
||||||
|
// Check that the tile is not a coastal city's center
|
||||||
|
&& !(tile.isCityCenter() && tile.isCoastalTile()))
|
||||||
return false
|
return false
|
||||||
|
|
||||||
if(tile.isWater && unit.type.isLandUnit()){
|
if(tile.isWater && unit.type.isLandUnit()){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user