diff options
Diffstat (limited to 'engines/kyra/saveload_mr.cpp')
-rw-r--r-- | engines/kyra/saveload_mr.cpp | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/engines/kyra/saveload_mr.cpp b/engines/kyra/saveload_mr.cpp index 0db82863ab..f2f10d635a 100644 --- a/engines/kyra/saveload_mr.cpp +++ b/engines/kyra/saveload_mr.cpp @@ -32,14 +32,14 @@ namespace Kyra { -void KyraEngine_MR::saveGame(const char *fileName, const char *saveName, const Graphics::Surface *thumb) { - debugC(9, kDebugLevelMain, "KyraEngine_LoK::saveGame('%s', '%s', %p)", fileName, saveName, (const void *)thumb); +Common::Error KyraEngine_MR::saveGameState(int slot, const char *saveName, const Graphics::Surface *thumb) { + debugC(9, kDebugLevelMain, "KyraEngine_MR::saveGame(%d, '%s', %p)", slot, saveName, (const void *)thumb); + + const char *fileName = getSavegameFilename(slot); Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb); - if (!out) { - warning("Can't open file '%s', game not loadable", fileName); - return; - } + if (!out) + return _saveFileMan->getError(); _timer->saveDataToFile(*out); @@ -112,23 +112,28 @@ void KyraEngine_MR::saveGame(const char *fileName, const char *saveName, const G out->finalize(); // check for errors - if (out->err()) + if (out->err()) { warning("Can't write file '%s'. (Disk full?)", fileName); - else + return Common::kUnknownError; + } else { debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName); + } delete out; + return Common::kNoError; } -void KyraEngine_MR::loadGame(const char *fileName) { - debugC(9, kDebugLevelMain, "KyraEngine_MR::loadGame('%s')", fileName); +Common::Error KyraEngine_MR::loadGameState(int slot) { + debugC(9, kDebugLevelMain, "KyraEngine_MR::loadGame(%d)", slot); + + const char *fileName = getSavegameFilename(slot); SaveHeader header; Common::InSaveFile *saveFile = openSaveForReading(fileName, header); if (!saveFile) { showMessageFromCCode(17, 0xB3, 0); snd_playSoundEffect(0x0D, 0xC8); - return; + return Common::kUnknownError; } if (header.originalSave) @@ -283,10 +288,12 @@ void KyraEngine_MR::loadGame(const char *fileName) { _sceneExit3 = in.readUint16(); _sceneExit4 = in.readUint16(); - if (saveFile->err() || saveFile->eos()) - error("Load failed ('%s', '%s').", fileName, header.description.c_str()); - else + if (saveFile->err() || saveFile->eos()) { + warning("Load failed ('%s', '%s').", fileName, header.description.c_str()); + return Common::kUnknownError; + } else { debugC(1, kDebugLevelMain, "Loaded savegame '%s.'", header.description.c_str()); + } _loadingState = true; updateCharacterAnim(0); @@ -321,6 +328,8 @@ void KyraEngine_MR::loadGame(const char *fileName) { // We didn't explicitly set the walk speed, but it's saved as part of // the _timers array, so we need to re-sync it with _configWalkspeed. setWalkspeed(_configWalkspeed); + + return Common::kNoError; } } // end of namespace Kyra |