From 41f36d06733ebadb495d4383de9944bf5a6a3521 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 24 Sep 2020 12:22:29 +1000 Subject: [PATCH] GameList: Fix cover search from game serial/code --- src/frontend-common/game_list.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/frontend-common/game_list.cpp b/src/frontend-common/game_list.cpp index f1607a7fb..26a52b251 100644 --- a/src/frontend-common/game_list.cpp +++ b/src/frontend-common/game_list.cpp @@ -1118,16 +1118,22 @@ std::string GameList::GetCoverImagePathForEntry(const GameListEntry* entry) for (const char* extension : extensions) { // try the title - cover_path.Format("%s" FS_OSPATH_SEPARATOR_STR "covers" FS_OSPATH_SEPARATOR_STR "%s.%s", - g_host_interface->GetUserDirectory().c_str(), entry->title.c_str(), extension); - if (FileSystem::FileExists(cover_path)) - return std::string(cover_path.GetCharArray()); + if (!entry->title.empty()) + { + cover_path.Format("%s" FS_OSPATH_SEPARATOR_STR "covers" FS_OSPATH_SEPARATOR_STR "%s.%s", + g_host_interface->GetUserDirectory().c_str(), entry->title.c_str(), extension); + if (FileSystem::FileExists(cover_path)) + return std::string(cover_path.GetCharArray()); + } // then the code - cover_path.Format("%s" FS_OSPATH_SEPARATOR_STR "covers" FS_OSPATH_SEPARATOR_STR "%s.%s", - g_host_interface->GetUserDirectory().c_str(), entry->title.c_str(), extension); - if (FileSystem::FileExists(cover_path)) - return std::string(cover_path.GetCharArray()); + if (!entry->code.empty()) + { + cover_path.Format("%s" FS_OSPATH_SEPARATOR_STR "covers" FS_OSPATH_SEPARATOR_STR "%s.%s", + g_host_interface->GetUserDirectory().c_str(), entry->code.c_str(), extension); + if (FileSystem::FileExists(cover_path)) + return std::string(cover_path.GetCharArray()); + } // and the file title if it differs const std::string_view file_title = GetFileNameFromPath(entry->path.c_str());