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.
This commit is contained in:
Exzap 2023-09-30 06:21:14 +02:00
parent ce34b95b82
commit 43976ca7eb
3 changed files with 25 additions and 13 deletions

View File

@ -27,17 +27,13 @@ public:
void SetBase(const TitleInfo& 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<TitleInfo> m_aoc;

View File

@ -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);

View File

@ -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