- do not sort level names in the statistics output when saving.

Instead do this when creating the data to avoid trashing manual edits. The old sorter resorted all data loaded from the old file as well.
This commit is contained in:
Christoph Oelckers 2021-03-13 13:11:03 +01:00
parent fa0be28af1
commit f0ddc063b0

View file

@ -205,14 +205,6 @@ int compare_episode_names(const void *a, const void *b)
return strnatcasecmp(A->epi_header, B->epi_header);
}
int compare_level_names(const void *a, const void *b)
{
FLevelStatistics *A = (FLevelStatistics*)a;
FLevelStatistics *B = (FLevelStatistics*)b;
return strnatcasecmp(A->name, B->name);
}
int compare_dates(const void *a, const void *b)
{
FLevelStatistics *A = (FLevelStatistics*)a;
@ -275,8 +267,6 @@ static void SaveStatistics(const char *fn, TArray<FStatistics> &statlist)
{
fw->Printf("\t{\n");
qsort(&ls[0], ls.Size(), sizeof(ls[0]), compare_level_names);
for(unsigned k=0;k<ls.Size ();k++)
{
fw->Printf("\t\t%-8s \"%-33s\" %02d:%02d:%02d\n", ls[k].name, ls[k].info,
@ -390,6 +380,15 @@ void STAT_StartNewGame(const char *mapname)
//
//==========================================================================
int compare_level_names(const void* a, const void* b)
{
OneLevel* A = (OneLevel*)a;
OneLevel* B = (OneLevel*)b;
return strnatcasecmp(A->Levelname, B->Levelname);
}
static void StoreLevelStats(FLevelLocals *Level)
{
unsigned int i;
@ -427,6 +426,8 @@ static void StoreLevelStats(FLevelLocals *Level)
}
if (mc == 0) LevelData[i].killcount = LevelData[i].totalkills;
}
// sort level names alphabetically to bring the newly added level to its proper place when playing a hub.
qsort(&LevelData[0], LevelData.Size(), sizeof(LevelData[0]), compare_level_names);
}
//==========================================================================