From 6e39c0336c50df3f93de556c98c5a0002285ee84 Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Tue, 6 Jun 2023 17:41:13 +0200 Subject: [PATCH] Handle non-string RefIds when displaying a class image --- apps/openmw/mwgui/class.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 1e7dafe92d..300683472f 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -889,14 +889,21 @@ namespace MWGui void setClassImage(MyGUI::ImageBox* imageBox, const ESM::RefId& classId) { - const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); - std::string classImage - = Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + classId.getRefIdString() + ".dds", vfs); - if (!vfs->exists(classImage)) + std::string_view fallback = "textures\\levelup\\warrior.dds"; + std::string classImage; + if (const auto* id = classId.getIf()) { - Log(Debug::Warning) << "No class image for " << classId << ", falling back to default"; - classImage = "textures\\levelup\\warrior.dds"; + const VFS::Manager* const vfs = MWBase::Environment::get().getResourceSystem()->getVFS(); + classImage + = Misc::ResourceHelpers::correctTexturePath("textures\\levelup\\" + id->getValue() + ".dds", vfs); + if (!vfs->exists(classImage)) + { + Log(Debug::Warning) << "No class image for " << classId << ", falling back to default"; + classImage = fallback; + } } + else + classImage = fallback; imageBox->setImageTexture(classImage); }