aboutsummaryrefslogtreecommitdiff
path: root/engines/mortevielle
diff options
context:
space:
mode:
authorStrangerke2013-08-21 08:13:59 +0200
committerStrangerke2013-08-21 08:37:55 +0200
commit972cdf0e129759e109aa53876b72ed4df03c229b (patch)
tree8f59207324ff60baff360ec3599717a6e813698c /engines/mortevielle
parent00992c1e68444a8123ffc89a971751cecf7287ed (diff)
downloadscummvm-rg350-972cdf0e129759e109aa53876b72ed4df03c229b.tar.gz
scummvm-rg350-972cdf0e129759e109aa53876b72ed4df03c229b.tar.bz2
scummvm-rg350-972cdf0e129759e109aa53876b72ed4df03c229b.zip
MORTEVIELLE: Avoid erroring out when the user tries to load a missing save game
Diffstat (limited to 'engines/mortevielle')
-rw-r--r--engines/mortevielle/saveload.cpp28
-rw-r--r--engines/mortevielle/saveload.h2
2 files changed, 17 insertions, 13 deletions
diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index 651ed07b65..c14a03cd60 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -72,15 +72,16 @@ void SavegameManager::sync_save(Common::Serializer &sz) {
* Inner code for loading a saved game
* @remarks Originally called 'takesav'
*/
-void SavegameManager::loadSavegame(const Common::String &filename) {
+bool SavegameManager::loadSavegame(const Common::String &filename) {
// Try loading first from the save area
Common::SeekableReadStream *stream = g_system->getSavefileManager()->openForLoading(filename);
Common::File f;
if (stream == NULL) {
- if (!f.open(filename))
- error("Unable to open save file '%s'", filename.c_str());
-
+ if (!f.open(filename)) {
+ warning("Unable to open save file '%s'", filename.c_str());
+ return false;
+ }
stream = f.readStream(f.size());
f.close();
}
@@ -107,6 +108,8 @@ void SavegameManager::loadSavegame(const Common::String &filename) {
// Close the stream
delete stream;
+
+ return true;
}
/**
@@ -115,14 +118,15 @@ void SavegameManager::loadSavegame(const Common::String &filename) {
Common::Error SavegameManager::loadGame(const Common::String &filename) {
g_vm->_mouse.hideMouse();
g_vm->displayEmptyHand();
- loadSavegame(filename);
-
- /* Initialization */
- g_vm->charToHour();
- g_vm->initGame();
- g_vm->gameLoaded();
- g_vm->_mouse.showMouse();
- return Common::kNoError;
+ if (loadSavegame(filename)) {
+ /* Initialization */
+ g_vm->charToHour();
+ g_vm->initGame();
+ g_vm->gameLoaded();
+ g_vm->_mouse.showMouse();
+ return Common::kNoError;
+ } else
+ return Common::kUnknownError;
}
/**
diff --git a/engines/mortevielle/saveload.h b/engines/mortevielle/saveload.h
index 0121a04d8e..79747e6889 100644
--- a/engines/mortevielle/saveload.h
+++ b/engines/mortevielle/saveload.h
@@ -57,7 +57,7 @@ private:
void sync_save(Common::Serializer &sz);
public:
void setParent(MortevielleEngine *vm);
- void loadSavegame(const Common::String &filename);
+ bool loadSavegame(const Common::String &filename);
Common::Error loadGame(const Common::String &filename);
Common::Error saveGame(int n, const Common::String &saveName);
Common::Error loadGame(int slot);