Skip to content

Commit

Permalink
Prioritize non-NUS format over NUS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Exzap committed Sep 30, 2023
1 parent ce34b95 commit 43976ca
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
31 changes: 23 additions & 8 deletions src/Cafe/TitleList/GameInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,13 @@ class GameInfo2

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;
}

Expand All @@ -53,7 +49,7 @@ class GameInfo2
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);
}
Expand Down Expand Up @@ -126,6 +122,25 @@ class GameInfo2
}

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;
Expand Down
3 changes: 1 addition & 2 deletions src/Cafe/TitleList/TitleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions src/gui/components/wxTitleManagerList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43976ca

Please sign in to comment.