From 75856967a04b275eed7dd5c52a021da022565d28 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 23 May 2010 12:21:22 +0000 Subject: [PATCH] (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 --- src/console_cmds.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 7cb96d3d1a..769e459847 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; }