From 9b5ded43d4c1e17e92777a881e9818b08c6b91d1 Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Sat, 4 Nov 2023 23:55:47 +0200 Subject: [PATCH] Mods with atlases that reference non-existent files will no longer cause crashes --- core/src/com/unciv/ui/images/ImageGetter.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/ui/images/ImageGetter.kt b/core/src/com/unciv/ui/images/ImageGetter.kt index 567a94fb8f..d297882b33 100644 --- a/core/src/com/unciv/ui/images/ImageGetter.kt +++ b/core/src/com/unciv/ui/images/ImageGetter.kt @@ -103,9 +103,14 @@ object ImageGetter { val extraAtlas = if (mod.isEmpty()) fileName else if (fileName == "game") mod else "$mod/$fileName" var tempAtlas = atlases[extraAtlas] // fetch if cached if (tempAtlas == null) { - debug("Loading %s = %s", extraAtlas, file.path()) - tempAtlas = TextureAtlas(file) // load if not - atlases[extraAtlas] = tempAtlas // cache the freshly loaded + try { + debug("Loading %s = %s", extraAtlas, file.path()) + tempAtlas = TextureAtlas(file) // load if not + atlases[extraAtlas] = tempAtlas // cache the freshly loaded + } catch (ex: Exception){ + debug("Could not load file $file") + continue + } } for (region in tempAtlas.regions) { if (region.name.startsWith("Skins")) {