(svn r3055) Give the savegame/scenarion sort order flags symbolic names

This commit is contained in:
tron
2005-10-17 19:57:00 +00:00
parent b85da4fef2
commit 23ecc82ad3
6 changed files with 47 additions and 25 deletions

13
win32.c
View File

@@ -644,12 +644,13 @@ int CDECL compare_FiosItems(const void *a, const void *b)
const FiosItem *db = (const FiosItem *)b;
int r;
if (_savegame_sort_order < 2) // sort by date
r = da->mtime < db->mtime ? -1 : 1;
else
if (_savegame_sort_order & SORT_BY_NAME) {
r = strcasecmp(da->title, db->title);
} else {
r = da->mtime < db->mtime ? -1 : 1;
}
if (_savegame_sort_order & 1) r = -r;
if (_savegame_sort_order & SORT_DESCENDING) r = -r;
return r;
}
@@ -698,7 +699,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
{
/* XXX ugly global variables ... */
byte order = _savegame_sort_order;
_savegame_sort_order = 2; // sort ascending by name
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
qsort(_fios_items, _fios_count, sizeof(FiosItem), compare_FiosItems);
_savegame_sort_order = order;
}
@@ -812,7 +813,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
{
/* XXX ugly global variables ... */
byte order = _savegame_sort_order;
_savegame_sort_order = 2; // sort ascending by name
_savegame_sort_order = SORT_BY_NAME | SORT_ASCENDING;
qsort(_fios_items, _fios_count, sizeof(FiosItem), compare_FiosItems);
_savegame_sort_order = order;
}