Mercurial > hg > openttd
changeset 15250:91e0e573c069 draft
(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
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 23 May 2010 12:21:22 +0000 |
parents | 82df7442d0db |
children | c75bfd4a1143 |
files | src/console_cmds.cpp |
diffstat | 1 files changed, 12 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -269,7 +269,18 @@ 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; }