summaryrefslogtreecommitdiff
path: root/unix.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
commitcda6efd9194876394f6ca9d7830517e23b1f01fb (patch)
tree02e6da519beebdef4edfbf70e4617febd8552b8e /unix.c
parenteceb9a0abe76ea48af01d6d88b7dfcb00c39052b (diff)
downloadopenttd-cda6efd9194876394f6ca9d7830517e23b1f01fb.tar.xz
(svn r2609) - Feature: remove extension from savegames/scenarios when browsing the folders.
Diffstat (limited to 'unix.c')
-rw-r--r--unix.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/unix.c b/unix.c
index f40783247..07585c926 100644
--- a/unix.c
+++ b/unix.c
@@ -62,10 +62,7 @@ int 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;
@@ -87,10 +84,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 in root already.
if (_fios_path[1] != '\0') {
@@ -151,8 +145,10 @@ FiosItem *FiosGetSavegameList(int *num, int mode)
fios = FiosAlloc();
fios->type = FIOS_TYPE_FILE;
fios->mtime = sb.st_mtime;
- fios->title[0] = '\0';
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
+
+ *t = '\0'; // strip extension
+ ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO) {
if (t != NULL && (
strcasecmp(t, ".ss1") == 0 ||
@@ -212,8 +208,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
fios->type = FIOS_TYPE_DIR;
fios->mtime = 0;
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
- snprintf(fios->title, lengthof(fios->title),
- "%s/ (Directory)", dirent->d_name);
+ snprintf(fios->title, lengthof(fios->title), "%s/ (Directory)", dirent->d_name);
}
}
closedir(dir);
@@ -232,8 +227,7 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
while ((dirent = readdir(dir)) != NULL) {
char *t;
- snprintf(filename, lengthof(filename), "%s/%s",
- _fios_path, dirent->d_name);
+ snprintf(filename, lengthof(filename), "%s/%s", _fios_path, dirent->d_name);
if (stat(filename, &sb) || S_ISDIR(sb.st_mode)) continue;
t = strrchr(dirent->d_name, '.');
@@ -241,8 +235,10 @@ FiosItem *FiosGetScenarioList(int *num, int mode)
fios = FiosAlloc();
fios->type = FIOS_TYPE_SCENARIO;
fios->mtime = sb.st_mtime;
- fios->title[0] = '\0';
ttd_strlcpy(fios->name, dirent->d_name, lengthof(fios->name));
+
+ *t = '\0'; // strip extension
+ ttd_strlcpy(fios->title, dirent->d_name, lengthof(fios->title));
} else if (mode == SLD_LOAD_GAME || mode == SLD_LOAD_SCENARIO ||
mode == SLD_NEW_GAME) {
if (t != NULL && (