mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r20038) -Change: move SafeSaveOrLoad a bit
This commit is contained in:
parent
cd3bc08071
commit
827a97a5ce
@ -853,6 +853,38 @@ void StartupCompanies();
|
|||||||
void StartupDisasters();
|
void StartupDisasters();
|
||||||
extern void StartupEconomy();
|
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.
|
* Start Scenario starts a new game based on a scenario.
|
||||||
* Eg 'New Game' --> select a preset scenario
|
* Eg 'New Game' --> select a preset scenario
|
||||||
@ -900,37 +932,6 @@ static void StartScenario()
|
|||||||
MarkWholeScreenDirty();
|
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)
|
void SwitchToMode(SwitchMode new_mode)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
Loading…
Reference in New Issue
Block a user