diff options
author | tron <tron@openttd.org> | 2005-08-12 06:37:48 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2005-08-12 06:37:48 +0000 |
commit | 207700ac36d19ecaca83e59f40be1cc0cdf296df (patch) | |
tree | d795cddd9de5184d6299b06f8acf08ae30a64a32 /win32.c | |
parent | 92611f1df635869bade41bfb44f6801d3ddceee1 (diff) | |
download | openttd-207700ac36d19ecaca83e59f40be1cc0cdf296df.tar.xz |
(svn r2860) Fix some issues in the savegame/scenario list code:
-Fix: Sort the directories when making a scenario list
-Fix: Sort the directories when making a savegame list on Windows
-Fix: On OS/2 show the trailing \ if the current directory is a root directory
-Regression: On OS/2 the savegame list showed the scenario directory or crashed (probably introduced in r2609)
The rest is diff reduction between the 3 variants
Diffstat (limited to 'win32.c')
-rw-r--r-- | win32.c | 30 |
1 files changed, 22 insertions, 8 deletions
@@ -647,6 +647,14 @@ FiosItem *FiosGetSavegameList(int *num, int mode) FindClose(h); } + { + /* XXX ugly global variables ... */ + byte order = _savegame_sort_order; + _savegame_sort_order = 2; // sort ascending by name + qsort(_fios_items, _fios_count, sizeof(FiosItem), compare_FiosItems); + _savegame_sort_order = order; + } + // this is where to start sorting sort_start = _fios_count; @@ -672,7 +680,6 @@ FiosItem *FiosGetSavegameList(int *num, int mode) *t = '\0'; // strip extension ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title)); - } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) { if (t != NULL && ( strcasecmp(t, ".ss1") == 0 || @@ -754,6 +761,14 @@ FiosItem *FiosGetScenarioList(int *num, int mode) FindClose(h); } + { + /* XXX ugly global variables ... */ + byte order = _savegame_sort_order; + _savegame_sort_order = 2; // sort ascending by name + qsort(_fios_items, _fios_count, sizeof(FiosItem), compare_FiosItems); + _savegame_sort_order = order; + } + // this is where to start sorting sort_start = _fios_count; @@ -776,9 +791,8 @@ FiosItem *FiosGetScenarioList(int *num, int mode) fios->mtime = *(uint64*)&fd.ftLastWriteTime; ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); - *t = '\0'; // strip extension + *t = '\0'; // strip extension ttd_strlcpy(fios->title, fd.cFileName, lengthof(fios->title)); - } else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO || mode == SLD_NEW_GAME) { if (t != NULL && ( @@ -842,14 +856,14 @@ char *FiosBrowseTo(const FiosItem *item) case FIOS_TYPE_PARENT: s = strrchr(path, '\\'); - if (s != NULL) *s = '\0'; - if (path[2] == '\0' ) strcat(path, "\\"); + if (s != path + 2) + s[0] = '\0'; + else + s[1] = '\0'; break; case FIOS_TYPE_DIR: - s = strchr(item->name, '\\'); - if (s != NULL) *s = '\0'; - if (path[3] != '\0' ) strcat(path, "\\"); + if (path[3] != '\0') strcat(path, "\\"); strcat(path, item->name); break; |