diff options
Diffstat (limited to 'win32.c')
-rw-r--r-- | win32.c | 33 |
1 files changed, 15 insertions, 18 deletions
@@ -1579,10 +1579,7 @@ int CDECL compare_FiosItems(const void *a, const void *b) if (_savegame_sort_order < 2) // sort by date r = da->mtime < db->mtime ? -1 : 1; else - r = strcasecmp( - da->title[0] != '\0' ? da->title : da->name, - db->title[0] != '\0' ? db->title : db->name - ); + r = strcasecmp(da->title, db->title); if (_savegame_sort_order & 1) r = -r; return r; @@ -1602,10 +1599,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode) strcpy(_fios_save_path, _path.save_dir); } - if (_game_mode == GM_EDITOR) - _fios_path = _fios_scn_path; - else - _fios_path = _fios_save_path; + _fios_path = _fios_save_path; // Parent directory, only if not of the type C:\. if (_fios_path[3] != '\0') { @@ -1627,8 +1621,7 @@ FiosItem *FiosGetSavegameList(int *num, int mode) fios->type = FIOS_TYPE_DIR; fios->mtime = 0; ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); - snprintf(fios->title, lengthof(fios->title), - "%s\\ (Directory)", fd.cFileName); + snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", fd.cFileName); } } while (FindNextFile(h, &fd)); FindClose(h); @@ -1655,8 +1648,11 @@ FiosItem *FiosGetSavegameList(int *num, int mode) fios = FiosAlloc(); fios->type = FIOS_TYPE_FILE; fios->mtime = *(uint64*)&fd.ftLastWriteTime; - fios->title[0] = '\0'; ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); + + *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 || @@ -1706,9 +1702,8 @@ FiosItem *FiosGetScenarioList(int *num, int mode) HANDLE h; int sort_start; - if (mode == SLD_NEW_GAME || _fios_scn_path == NULL) { - if (_fios_scn_path == NULL) - _fios_scn_path = malloc(MAX_PATH); + if (_fios_scn_path == NULL) { + _fios_scn_path = malloc(MAX_PATH); strcpy(_fios_scn_path, _path.scenario_dir); } @@ -1733,8 +1728,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode) fios->type = FIOS_TYPE_DIR; fios->mtime = 0; ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); - snprintf(fios->title, lengthof(fios->title), - "%s\\ (Directory)", fd.cFileName); + snprintf(fios->title, lengthof(fios->title), "%s\\ (Directory)", fd.cFileName); } } while (FindNextFile(h, &fd)); FindClose(h); @@ -1760,8 +1754,11 @@ FiosItem *FiosGetScenarioList(int *num, int mode) fios = FiosAlloc(); fios->type = FIOS_TYPE_SCENARIO; fios->mtime = *(uint64*)&fd.ftLastWriteTime; - fios->title[0] = '\0'; ttd_strlcpy(fios->name, fd.cFileName, lengthof(fios->name)); + + *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 && ( @@ -2269,4 +2266,4 @@ void JoinOTTDThread(void) void CSleep(int milliseconds) { Sleep(milliseconds); -}
\ No newline at end of file +} |