cellSaveData: fix "Your comparator is not a valid strict-weak ordering"

This commit is contained in:
oltolm 2026-02-22 01:59:55 +01:00 committed by Elad
parent 6bfb33279f
commit 3585881a6c

View File

@ -876,39 +876,42 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
// Sort the entries // Sort the entries
{ {
const u32 order = setList->sortOrder;
const u32 type = setList->sortType; const u32 type = setList->sortType;
std::sort(save_entries.begin(), save_entries.end(), [order, type](const SaveDataEntry& entry1, const SaveDataEntry& entry2) -> bool auto comp = [type](const SaveDataEntry& entry1, const SaveDataEntry& entry2) -> bool
{ {
const bool mtime_lower = entry1.mtime < entry2.mtime; const bool mtime_lower = entry1.mtime < entry2.mtime;
const bool mtime_equal = entry1.mtime == entry2.mtime; const bool mtime_equal = entry1.mtime == entry2.mtime;
const bool subtitle_lower = entry1.subtitle < entry2.subtitle; const bool subtitle_lower = entry1.subtitle < entry2.subtitle;
const bool subtitle_equal = entry1.subtitle == entry2.subtitle; const bool subtitle_equal = entry1.subtitle == entry2.subtitle;
const bool revert_order = order == CELL_SAVEDATA_SORTORDER_DESCENT;
if (type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME) if (type == CELL_SAVEDATA_SORTTYPE_MODIFIEDTIME)
{ {
if (mtime_equal) if (mtime_equal)
{ {
return subtitle_lower != revert_order; return subtitle_lower;
} }
return mtime_lower != revert_order; return mtime_lower;
} }
else if (type == CELL_SAVEDATA_SORTTYPE_SUBTITLE) else if (type == CELL_SAVEDATA_SORTTYPE_SUBTITLE)
{ {
if (subtitle_equal) if (subtitle_equal)
{ {
return mtime_lower != revert_order; return mtime_lower;
} }
return subtitle_lower != revert_order; return subtitle_lower;
} }
ensure(false); ensure(false);
return true; return true;
}); };
if (setList->sortOrder == CELL_SAVEDATA_SORTORDER_ASCENT)
std::sort(save_entries.begin(), save_entries.end(), comp);
else
std::sort(save_entries.rbegin(), save_entries.rend(), comp);
} }
// Fill the listGet->dirList array // Fill the listGet->dirList array