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
1 changed files with 6 additions and 3 deletions
|
@ -188,6 +188,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||
fun teleportToClosestMoveableTile(){
|
||||
var allowedTile:TileInfo? = null
|
||||
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){
|
||||
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.
|
||||
// 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)
|
||||
allowedTile = city.getTiles()
|
||||
.firstOrNull { canMoveTo(it) }
|
||||
if(allowedTile!=null) break
|
||||
}
|
||||
|
@ -276,7 +276,10 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
|||
// because optimization on this function results in massive benefits!
|
||||
fun canPassThrough(tile: TileInfo):Boolean{
|
||||
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
|
||||
|
||||
if(tile.isWater && unit.type.isLandUnit()){
|
||||
|
|
Loading…
Reference in a new issue