diff options
author | rubidium <rubidium@openttd.org> | 2010-05-23 12:21:22 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-05-23 12:21:22 +0000 |
commit | 75856967a04b275eed7dd5c52a021da022565d28 (patch) | |
tree | b10edb71ddfbcaf86601f9817b1c67564ee03245 /src | |
parent | 45440063b57f792da3afef603e621befa1c1bfcd (diff) | |
download | openttd-75856967a04b275eed7dd5c52a021da022565d28.tar.xz |
(svn r19885) -Fix [FS#3761]: allow loading savegames from the console without specifying the ".sav" extension, i.e. make it consistent with saving savegames from the console
Diffstat (limited to 'src')
-rw-r--r-- | src/console_cmds.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 7cb96d3d1..769e45984 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -269,7 +269,18 @@ static const FiosItem *GetFiosItem(const char *file) int i = strtol(file, &endptr, 10); if (file == endptr || *endptr != '\0') i = -1; - return IsInsideMM(i, 0, _fios_items.Length()) ? _fios_items.Get(i) : NULL; + if (IsInsideMM(i, 0, _fios_items.Length())) return _fios_items.Get(i); + + /* As a last effort assume it is an OpenTTD savegame and + * that the ".sav" part was not given. */ + char long_file[MAX_PATH]; + seprintf(long_file, lastof(long_file), "%s.sav", file); + for (const FiosItem *item = _fios_items.Begin(); item != _fios_items.End(); item++) { + if (strcmp(long_file, item->name) == 0) return item; + if (strcmp(long_file, item->title) == 0) return item; + } + + return NULL; } |