summaryrefslogtreecommitdiff
path: root/unix.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-10-17 19:57:00 +0000
committertron <tron@openttd.org>2005-10-17 19:57:00 +0000
commit23ecc82ad31b29dbf2adc3dd0f6f7550b3ac3e69 (patch)
tree55174ff380184f8b141b398364301899461e7fb6 /unix.c
parentb85da4fef2897039e198da97f524f1ca9c6bf913 (diff)
downloadopenttd-23ecc82ad31b29dbf2adc3dd0f6f7550b3ac3e69.tar.xz
(svn r3055) Give the savegame/scenarion sort order flags symbolic names
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/unix.c b/unix.c
index 3496a6452..3fb95569f 100644
--- a/unix.c
+++ b/unix.c
@@ -70,12 +70,13 @@ int 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;
}
@@ -128,7 +129,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;
}
@@ -229,7 +230,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;
}