summaryrefslogtreecommitdiff
path: root/win32.c
diff options
context:
space:
mode:
authorDarkvater <darkvater@openttd.org>2005-07-17 15:58:47 +0000
committerDarkvater <darkvater@openttd.org>2005-07-17 15:58:47 +0000
commit80aa8c868b3ec9ca5d484ae637efd5917ca33465 (patch)
tree02e6da519beebdef4edfbf70e4617febd8552b8e /win32.c
parentd355aa11a53bf65071d475ad47f22b2b3e06b114 (diff)
downloadopenttd-80aa8c868b3ec9ca5d484ae637efd5917ca33465.tar.xz
(svn r2609) - Feature: remove extension from savegames/scenarios when browsing the folders.
Diffstat (limited to 'win32.c')
-rw-r--r--win32.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/win32.c b/win32.c
index c84a85066..9fb8ca0a5 100644
--- a/win32.c
+++ b/win32.c
@@ -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
+}