diff --git a/core/src/com/unciv/ui/saves/LoadGameScreen.kt b/core/src/com/unciv/ui/saves/LoadGameScreen.kt index 1c78d5b4ae..45f73d4360 100644 --- a/core/src/com/unciv/ui/saves/LoadGameScreen.kt +++ b/core/src/com/unciv/ui/saves/LoadGameScreen.kt @@ -80,7 +80,9 @@ class LoadGameScreen(previousScreen:CameraStageBaseScreen) : PickerScreen(disabl loadFromClipboardButton.onClick { try { val clipboardContentsString = Gdx.app.clipboard.contents.trim() - val decoded = Gzip.unzip(clipboardContentsString) + val decoded = + if (clipboardContentsString.startsWith("{")) clipboardContentsString + else Gzip.unzip(clipboardContentsString) val loadedGame = GameSaver.gameInfoFromString(decoded) UncivGame.Current.loadGame(loadedGame) } catch (ex: Exception) { diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index ba2bc64bc9..6f91561466 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -320,13 +320,21 @@ object UnitActions { return UnitAction(UnitActionType.Upgrade, title = "Upgrade to [${upgradedUnit.name}] ([$goldCostOfUpgrade] gold)", action = { - unit.civInfo.addGold(-goldCostOfUpgrade) val unitTile = unit.getTile() unit.destroy() - val newUnit = unit.civInfo.placeUnitNearTile(unitTile.position, upgradedUnit.name)!! - unit.copyStatisticsTo(newUnit) - - newUnit.currentMovement = 0f + val newUnit = unit.civInfo.placeUnitNearTile(unitTile.position, upgradedUnit.name) + + /** We were UNABLE to place the new unit, which means that the unit failed to upgrade! + * The only known cause of this currently is "land units upgrading to water units" which fail to be placed. + */ + if (newUnit == null) { + val readdedUnit = unit.civInfo.placeUnitNearTile(unitTile.position, unit.name) + unit.copyStatisticsTo(readdedUnit!!) + } else { // Managed to upgrade + unit.civInfo.addGold(-goldCostOfUpgrade) + unit.copyStatisticsTo(newUnit) + newUnit.currentMovement = 0f + } }.takeIf { isFree || (