aboutsummaryrefslogtreecommitdiff
path: root/engines/mortevielle/saveload.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/mortevielle/saveload.cpp')
-rw-r--r--engines/mortevielle/saveload.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/engines/mortevielle/saveload.cpp b/engines/mortevielle/saveload.cpp
index 651ed07b65..77a9a6371e 100644
--- a/engines/mortevielle/saveload.cpp
+++ b/engines/mortevielle/saveload.cpp
@@ -37,7 +37,7 @@ namespace Mortevielle {
static const char SAVEGAME_ID[4] = { 'M', 'O', 'R', 'T' };
-void SavegameManager::setParent(MortevielleEngine *vm) {
+SavegameManager::SavegameManager(MortevielleEngine *vm) {
_vm = vm;
}
@@ -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,22 +108,25 @@ void SavegameManager::loadSavegame(const Common::String &filename) {
// Close the stream
delete stream;
+
+ return true;
}
/**
* Load a saved game
*/
Common::Error SavegameManager::loadGame(const Common::String &filename) {
- g_vm->_mouse.hideMouse();
+ 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;
}
/**
@@ -132,7 +136,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) {
Common::OutSaveFile *f;
int i;
- g_vm->_mouse.hideMouse();
+ g_vm->_mouse->hideMouse();
g_vm->hourToChar();
for (i = 0; i <= 389; ++i)
@@ -161,7 +165,7 @@ Common::Error SavegameManager::saveGame(int n, const Common::String &saveName) {
// Skipped: dialog asking to swap floppy
- g_vm->_mouse.showMouse();
+ g_vm->_mouse->showMouse();
return Common::kNoError;
}
@@ -187,7 +191,7 @@ void SavegameManager::writeSavegameHeader(Common::OutSaveFile *out, const Common
// Create a thumbnail and save it
Graphics::Surface *thumb = new Graphics::Surface();
- Graphics::Surface s = g_vm->_screenSurface.lockArea(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
+ Graphics::Surface s = g_vm->_screenSurface->lockArea(Common::Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT));
::createThumbnail(thumb, (const byte *)s.getPixels(), SCREEN_WIDTH, SCREEN_HEIGHT, thumbPalette);
Graphics::saveThumbnail(*out, *thumb);