From 43976ca7ebbc91fc4eb6cd4822ae240301095b53 Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Sat, 30 Sep 2023 06:21:14 +0200 Subject: [PATCH] Prioritize non-NUS format over NUS If a title exists multiple times in the game folder in different formats, then prefer and use non-NUS format if one is available. This is so we match previous Cemu behavior where Cemu would pick non-NUS simply due the fact that NUS format wasn't supported yet. --- src/Cafe/TitleList/GameInfo.h | 31 +++++++++++++++++------ src/Cafe/TitleList/TitleList.cpp | 3 +-- src/gui/components/wxTitleManagerList.cpp | 4 +-- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Cafe/TitleList/GameInfo.h b/src/Cafe/TitleList/GameInfo.h index d1c557ab..8836d1e4 100644 --- a/src/Cafe/TitleList/GameInfo.h +++ b/src/Cafe/TitleList/GameInfo.h @@ -27,17 +27,13 @@ public: void SetBase(const TitleInfo& titleInfo) { - m_base = titleInfo; + if (IsPrioritizedVersionOrFormat(m_base, titleInfo)) + m_base = titleInfo; } void SetUpdate(const TitleInfo& titleInfo) { - if (HasUpdate()) - { - if (titleInfo.GetAppTitleVersion() > m_update.GetAppTitleVersion()) - m_update = titleInfo; - } - else + if (IsPrioritizedVersionOrFormat(m_update, titleInfo)) m_update = titleInfo; } @@ -53,7 +49,7 @@ public: auto it = std::find_if(m_aoc.begin(), m_aoc.end(), [aocTitleId](const TitleInfo& rhs) { return rhs.GetAppTitleId() == aocTitleId; }); if (it != m_aoc.end()) { - if(it->GetAppTitleVersion() >= aocVersion) + if (!IsPrioritizedVersionOrFormat(*it, titleInfo)) return; m_aoc.erase(it); } @@ -126,6 +122,25 @@ public: } private: + bool IsPrioritizedVersionOrFormat(const TitleInfo& currentTitle, const TitleInfo& newTitle) + { + if (!currentTitle.IsValid()) + return true; // always prefer a valid title over an invalid one + // always prefer higher version + if (newTitle.GetAppTitleVersion() > currentTitle.GetAppTitleVersion()) + return true; + // never prefer lower version + if (newTitle.GetAppTitleVersion() < currentTitle.GetAppTitleVersion()) + return false; + // for users which have both NUS and non-NUS titles in their games folder we want to prioritize non-NUS formats + // this is to stay consistent with previous Cemu versions which did not support NUS format at all + TitleInfo::TitleDataFormat currentFormat = currentTitle.GetFormat(); + TitleInfo::TitleDataFormat newFormat = newTitle.GetFormat(); + if (currentFormat != newFormat && currentFormat == TitleInfo::TitleDataFormat::NUS) + return true; + return true; + }; + TitleInfo m_base; TitleInfo m_update; std::vector m_aoc; diff --git a/src/Cafe/TitleList/TitleList.cpp b/src/Cafe/TitleList/TitleList.cpp index 03fd0855..1cc084b8 100644 --- a/src/Cafe/TitleList/TitleList.cpp +++ b/src/Cafe/TitleList/TitleList.cpp @@ -633,8 +633,7 @@ GameInfo2 CafeTitleList::GetGameInfo(TitleId titleId) uint64 baseTitleId; if (!FindBaseTitleId(titleId, baseTitleId)) { - cemuLog_logDebug(LogType::Force, "Failed to translate title id in GetGameInfo()"); - return gameInfo; + cemu_assert_suspicious(); } // determine if an optional update title id exists TitleIdParser tip(baseTitleId); diff --git a/src/gui/components/wxTitleManagerList.cpp b/src/gui/components/wxTitleManagerList.cpp index ea0cc3d3..d6ad8118 100644 --- a/src/gui/components/wxTitleManagerList.cpp +++ b/src/gui/components/wxTitleManagerList.cpp @@ -953,9 +953,7 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu } case ColumnLocation: { - const auto relative_mlc_path = - entry.path.lexically_relative(ActiveSettings::GetMlcPath()).string(); - + const auto relative_mlc_path = _pathToUtf8(entry.path.lexically_relative(ActiveSettings::GetMlcPath())); if (relative_mlc_path.starts_with("usr") || relative_mlc_path.starts_with("sys")) return _("MLC"); else