Skip to content

Commit 43976ca

Browse files
committed
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.
1 parent ce34b95 commit 43976ca

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

src/Cafe/TitleList/GameInfo.h

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,13 @@ class GameInfo2
2727

2828
void SetBase(const TitleInfo& titleInfo)
2929
{
30-
m_base = titleInfo;
30+
if (IsPrioritizedVersionOrFormat(m_base, titleInfo))
31+
m_base = titleInfo;
3132
}
3233

3334
void SetUpdate(const TitleInfo& titleInfo)
3435
{
35-
if (HasUpdate())
36-
{
37-
if (titleInfo.GetAppTitleVersion() > m_update.GetAppTitleVersion())
38-
m_update = titleInfo;
39-
}
40-
else
36+
if (IsPrioritizedVersionOrFormat(m_update, titleInfo))
4137
m_update = titleInfo;
4238
}
4339

@@ -53,7 +49,7 @@ class GameInfo2
5349
auto it = std::find_if(m_aoc.begin(), m_aoc.end(), [aocTitleId](const TitleInfo& rhs) { return rhs.GetAppTitleId() == aocTitleId; });
5450
if (it != m_aoc.end())
5551
{
56-
if(it->GetAppTitleVersion() >= aocVersion)
52+
if (!IsPrioritizedVersionOrFormat(*it, titleInfo))
5753
return;
5854
m_aoc.erase(it);
5955
}
@@ -126,6 +122,25 @@ class GameInfo2
126122
}
127123

128124
private:
125+
bool IsPrioritizedVersionOrFormat(const TitleInfo& currentTitle, const TitleInfo& newTitle)
126+
{
127+
if (!currentTitle.IsValid())
128+
return true; // always prefer a valid title over an invalid one
129+
// always prefer higher version
130+
if (newTitle.GetAppTitleVersion() > currentTitle.GetAppTitleVersion())
131+
return true;
132+
// never prefer lower version
133+
if (newTitle.GetAppTitleVersion() < currentTitle.GetAppTitleVersion())
134+
return false;
135+
// for users which have both NUS and non-NUS titles in their games folder we want to prioritize non-NUS formats
136+
// this is to stay consistent with previous Cemu versions which did not support NUS format at all
137+
TitleInfo::TitleDataFormat currentFormat = currentTitle.GetFormat();
138+
TitleInfo::TitleDataFormat newFormat = newTitle.GetFormat();
139+
if (currentFormat != newFormat && currentFormat == TitleInfo::TitleDataFormat::NUS)
140+
return true;
141+
return true;
142+
};
143+
129144
TitleInfo m_base;
130145
TitleInfo m_update;
131146
std::vector<TitleInfo> m_aoc;

src/Cafe/TitleList/TitleList.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,8 +633,7 @@ GameInfo2 CafeTitleList::GetGameInfo(TitleId titleId)
633633
uint64 baseTitleId;
634634
if (!FindBaseTitleId(titleId, baseTitleId))
635635
{
636-
cemuLog_logDebug(LogType::Force, "Failed to translate title id in GetGameInfo()");
637-
return gameInfo;
636+
cemu_assert_suspicious();
638637
}
639638
// determine if an optional update title id exists
640639
TitleIdParser tip(baseTitleId);

src/gui/components/wxTitleManagerList.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -953,9 +953,7 @@ wxString wxTitleManagerList::GetTitleEntryText(const TitleEntry& entry, ItemColu
953953
}
954954
case ColumnLocation:
955955
{
956-
const auto relative_mlc_path =
957-
entry.path.lexically_relative(ActiveSettings::GetMlcPath()).string();
958-
956+
const auto relative_mlc_path = _pathToUtf8(entry.path.lexically_relative(ActiveSettings::GetMlcPath()));
959957
if (relative_mlc_path.starts_with("usr") || relative_mlc_path.starts_with("sys"))
960958
return _("MLC");
961959
else

0 commit comments

Comments
 (0)