mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 23:08:35 +07:00
Add null check for connect road cross-version saves (#10699)
* Add null checks to fix #10691 * Issue reference unnecessary
This commit is contained in:
@ -139,6 +139,7 @@ class WorkerAutomation(
|
||||
fun automateConnectRoad(unit: MapUnit, tilesWhereWeWillBeCaptured: Set<Tile>){
|
||||
if (actualBestRoadAvailable == RoadStatus.None) return
|
||||
|
||||
|
||||
var currentTile = unit.getTile()
|
||||
|
||||
/** Reset side effects from automation, return worker to non-automated state*/
|
||||
@ -150,6 +151,11 @@ class WorkerAutomation(
|
||||
currentTile.stopWorkingOnImprovement()
|
||||
}
|
||||
|
||||
if (unit.automatedRoadConnectionDestination == null){
|
||||
stopAndCleanAutomation()
|
||||
return
|
||||
}
|
||||
|
||||
/** Conditions for whether it is acceptable to build a road on this tile */
|
||||
fun shouldBuildRoadOnTile(tile: Tile): Boolean {
|
||||
return !tile.isCityCenter() // Can't build road on city tiles
|
||||
|
@ -791,6 +791,7 @@ class WorldMapHolder(
|
||||
// Z-Layer: 4
|
||||
// Highlight road path for workers currently connecting roads
|
||||
if (unit.isAutomatingRoadConnection()) {
|
||||
if (unit.automatedRoadConnectionPath == null) return
|
||||
val currTileIndex = unit.automatedRoadConnectionPath!!.indexOf(unit.currentTile.position)
|
||||
if (currTileIndex != -1) {
|
||||
val futureTiles = unit.automatedRoadConnectionPath!!.filterIndexed { index, _ ->
|
||||
|
Reference in New Issue
Block a user