From 79ff8c2ecf3ce65df110d2272627a45ba8e245c4 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sun, 28 Jun 2020 20:48:51 +0300 Subject: [PATCH] Fixed broken tests due to 'impassible' changes --- android/assets/jsons/translations/template.properties | 1 + core/src/com/unciv/MainMenuScreen.kt | 6 +++++- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 8 +++++--- .../com/unciv/logic/map/UnitMovementAlgorithmsTests.kt | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index c211a76bff..f97c1236c9 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -560,6 +560,7 @@ Load game = Main menu = Resume = Cannot resume game! = +Not enough memory on phone to load game! = Quickstart = Victory status = Social policies = diff --git a/core/src/com/unciv/MainMenuScreen.kt b/core/src/com/unciv/MainMenuScreen.kt index f9beaac5c6..6a60fe93b5 100644 --- a/core/src/com/unciv/MainMenuScreen.kt +++ b/core/src/com/unciv/MainMenuScreen.kt @@ -155,7 +155,11 @@ class MainMenuScreen: CameraStageBaseScreen() { private fun autoLoadGame() { try { game.loadGame(autosave) - } catch (ex: Exception) { // silent fail if we can't read the autosave + } + catch (outOfMemory:OutOfMemoryError){ + ResponsePopup("Not enough memory on phone to load game!", this) + } + catch (ex: Exception) { // silent fail if we can't read the autosave ResponsePopup("Cannot resume game!", this) } } diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index bc718c0113..8b15b15e71 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -327,15 +327,17 @@ class UnitMovementAlgorithms(val unit:MapUnit) { // so multiple callees of this function have been optimized, // because optimization on this function results in massive benefits! fun canPassThrough(tile: TileInfo): Boolean { - if (tile.isImpassible()) return false + if (tile.isImpassible()){ + // special exception - ice tiles are technically impassible, but somme units can move through them anyway + if (!(tile.terrainFeature == Constants.ice && unit.canEnterIceTiles)) + return false + } 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.terrainFeature == Constants.ice && !unit.canEnterIceTiles) - return false if (tile.isWater && unit.type.isLandUnit()) { if (!unit.civInfo.tech.unitsCanEmbark) return false diff --git a/tests/src/com/unciv/logic/map/UnitMovementAlgorithmsTests.kt b/tests/src/com/unciv/logic/map/UnitMovementAlgorithmsTests.kt index 75133bd7e1..fd70f009f8 100644 --- a/tests/src/com/unciv/logic/map/UnitMovementAlgorithmsTests.kt +++ b/tests/src/com/unciv/logic/map/UnitMovementAlgorithmsTests.kt @@ -116,7 +116,7 @@ class UnitMovementAlgorithmsTests { @Test fun canNOTEnterNaturalWonder() { tile.baseTerrain = Constants.plains - tile.naturalWonder = "Wonder Thunder" + tile.naturalWonder = "Mount Fuji" tile.setTransients() for (type in UnitType.values()) {