summaryrefslogtreecommitdiff
path: root/src/openttd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-06-30 20:20:15 +0000
committerrubidium <rubidium@openttd.org>2010-06-30 20:20:15 +0000
commit827a97a5ce8248675ee770c1f349b0dc5a01844f (patch)
tree8e8e07a3423a8ad82a1d8ad0c5feca084f2c64ec /src/openttd.cpp
parentcd3bc080711a070d251e2f293842a8b3996dd2d5 (diff)
downloadopenttd-827a97a5ce8248675ee770c1f349b0dc5a01844f.tar.xz
(svn r20038) -Change: move SafeSaveOrLoad a bit
Diffstat (limited to 'src/openttd.cpp')
-rw-r--r--src/openttd.cpp63
1 files changed, 32 insertions, 31 deletions
diff --git a/src/openttd.cpp b/src/openttd.cpp
index b49e36c55..0d37c2a8e 100644
--- a/src/openttd.cpp
+++ b/src/openttd.cpp
@@ -854,6 +854,38 @@ void StartupDisasters();
extern void StartupEconomy();
/**
+ * Load the specified savegame but on error do different things.
+ * If loading fails due to corrupt savegame, bad version, etc. go back to
+ * a previous correct state. In the menu for example load the intro game again.
+ * @param filename file to be loaded
+ * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD
+ * @param newgm switch to this mode of loading fails due to some unknown error
+ * @param subdir default directory to look for filename, set to 0 if not needed
+ */
+bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir)
+{
+ GameMode ogm = _game_mode;
+
+ _game_mode = newgm;
+ assert(mode == SL_LOAD || mode == SL_OLD_LOAD);
+ switch (SaveOrLoad(filename, mode, subdir)) {
+ case SL_OK: return true;
+
+ case SL_REINIT:
+ switch (ogm) {
+ default:
+ case GM_MENU: LoadIntroGame(); break;
+ case GM_EDITOR: MakeNewEditorWorld(); break;
+ }
+ return false;
+
+ default:
+ _game_mode = ogm;
+ return false;
+ }
+}
+
+/**
* Start Scenario starts a new game based on a scenario.
* Eg 'New Game' --> select a preset scenario
* This starts a scenario based on your current difficulty settings
@@ -900,37 +932,6 @@ static void StartScenario()
MarkWholeScreenDirty();
}
-/** Load the specified savegame but on error do different things.
- * If loading fails due to corrupt savegame, bad version, etc. go back to
- * a previous correct state. In the menu for example load the intro game again.
- * @param filename file to be loaded
- * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD
- * @param newgm switch to this mode of loading fails due to some unknown error
- * @param subdir default directory to look for filename, set to 0 if not needed
- */
-bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir)
-{
- GameMode ogm = _game_mode;
-
- _game_mode = newgm;
- assert(mode == SL_LOAD || mode == SL_OLD_LOAD);
- switch (SaveOrLoad(filename, mode, subdir)) {
- case SL_OK: return true;
-
- case SL_REINIT:
- switch (ogm) {
- default:
- case GM_MENU: LoadIntroGame(); break;
- case GM_EDITOR: MakeNewEditorWorld(); break;
- }
- return false;
-
- default:
- _game_mode = ogm;
- return false;
- }
-}
-
void SwitchToMode(SwitchMode new_mode)
{
#ifdef ENABLE_NETWORK