mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 22:06:05 -04:00
Solved bug where land units that upgrade to water units would attempt to upgrade where the upgraded unit could not be placed.
This was such a cool idea that I decided to let it live :)
This commit is contained in:
parent
b87a3b9ace
commit
367e0b940d
@ -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) {
|
||||
|
@ -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 ||
|
||||
(
|
||||
|
Loading…
x
Reference in New Issue
Block a user