From 5910e52407ac8e9d6f01c9369f823599365970c5 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Sat, 13 Nov 2021 22:33:55 +0200 Subject: [PATCH] Catching out of memory errors when updating tiles with a catch-all popup --- core/src/com/unciv/ui/worldscreen/WorldScreen.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index d0f23f92ed..f981261506 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -396,8 +396,13 @@ class WorldScreen(val gameInfo: GameInfo, val viewingCiv:CivilizationInfo) : Cam // if we use the clone, then when we update viewable tiles // it doesn't update the explored tiles of the civ... need to think about that harder // it causes a bug when we move a unit to an unexplored tile (for instance a cavalry unit which can move far) - if (fogOfWar) mapHolder.updateTiles(selectedCiv) - else mapHolder.updateTiles(viewingCiv) + + try { // Most memory errors occur here, so this is a sort of catch-all + if (fogOfWar) mapHolder.updateTiles(selectedCiv) + else mapHolder.updateTiles(viewingCiv) + } catch (outOfMemoryError: OutOfMemoryError) { + ToastPopup("Not enough memory on phone to load game!", this) + } topBar.update(selectedCiv)