Merge remote-tracking branch 'origin/Saturn-Next' into lugstuff

This commit is contained in:
Alug committed 2025-07-06 15:05:54 +02:00
commit 2cb029a4f8
1 file changed
+28
+28
View File
@@ -6872,6 +6872,32 @@ static void M_HutCheckReplays(size_t maxnum)
}
}
static int ReplayListSortComparator(const void *entry1, const void *entry2)
{
const menudemo_t *demo1 = (const menudemo_t*)entry1;
const menudemo_t *demo2 = (const menudemo_t*)entry2;
char filepath1[sizeof(demo1->filepath)];
char filepath2[sizeof(demo2->filepath)];
// First check for directories, they always should be at the top
if (demo1->type == MD_SUBDIR && demo2->type != MD_SUBDIR)
return -1;
else if (demo2->type == MD_SUBDIR && demo1->type != MD_SUBDIR)
return 1;
else if (demo1->type == MD_SUBDIR && demo2->type == MD_SUBDIR)
return 0;
memcpy(filepath1, demo1->filepath, sizeof(filepath1));
memcpy(filepath2, demo2->filepath, sizeof(filepath2));
nameonly(filepath1);
nameonly(filepath2);
// Comparing in opposite order to move new replays to the top
return strncmp(filepath2, filepath1, sizeof(filepath1));
}
static void PrepReplayList(boolean reset)
{
size_t i;
@@ -6915,6 +6941,8 @@ static void PrepReplayList(boolean reset)
}
}
qs22j(demolist_all, sizedirmenu, sizeof(menudemo_t), ReplayListSortComparator);
Unlock_search_state();
LoadReplayNames();