From 77b0b582aed6cbc88e8375a3a1c50a8df6b25826 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Thu, 21 Jul 2022 22:31:44 +0300 Subject: [PATCH] Disabled autosave when resizing worldScreen --- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 55a4be75c9..3fdaac9d34 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -29,7 +29,6 @@ import com.unciv.models.ruleset.unique.UniqueType import com.unciv.ui.cityscreen.CityScreen import com.unciv.ui.civilopedia.CivilopediaScreen import com.unciv.ui.images.ImageGetter -import com.unciv.ui.multiplayer.MultiplayerHelpers import com.unciv.ui.overviewscreen.EmpireOverviewScreen import com.unciv.ui.pickerscreens.DiplomaticVotePickerScreen import com.unciv.ui.pickerscreens.DiplomaticVoteResultScreen @@ -748,7 +747,7 @@ class WorldScreen( override fun resize(width: Int, height: Int) { if (stage.viewport.screenWidth != width || stage.viewport.screenHeight != height) { - startNewScreenJob(gameInfo) // start over + startNewScreenJob(gameInfo, true) // start over } } @@ -826,7 +825,7 @@ class WorldScreen( } /** This exists so that no reference to the current world screen remains, so the old world screen can get garbage collected during [UncivGame.loadGame]. */ -private fun startNewScreenJob(gameInfo: GameInfo) { +private fun startNewScreenJob(gameInfo: GameInfo, autosaveDisabled:Boolean = false) { Concurrency.run { val newWorldScreen = try { UncivGame.Current.loadGame(gameInfo) @@ -838,7 +837,8 @@ private fun startNewScreenJob(gameInfo: GameInfo) { return@run } - val shouldAutoSave = gameInfo.turns % UncivGame.Current.settings.turnsBetweenAutosaves == 0 + val shouldAutoSave = !autosaveDisabled + && gameInfo.turns % UncivGame.Current.settings.turnsBetweenAutosaves == 0 if (shouldAutoSave) { newWorldScreen.autoSave() }