From 9931fb6a443571f104109f0c8a4116d892648a09 Mon Sep 17 00:00:00 2001 From: Kari Salminen Date: Mon, 3 Aug 2009 17:18:18 +0000 Subject: Fix for bug #2828333 (AGI: KQ1: Greensleeves always plays): - Made all savegame loading in AGI do the same pre-load and post-load stuff. - Moved load/saveGameState from AgiBase to AgiEngine - Added rudimentary error handling to load/saveGameState - Incidentally also fixes the hanging note from bug #2798797. svn-id: r43025 --- engines/agi/agi.h | 4 ++-- engines/agi/detection.cpp | 14 -------------- engines/agi/saveload.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/engines/agi/agi.h b/engines/agi/agi.h index 14e1fd448b..ab572b0dd0 100644 --- a/engines/agi/agi.h +++ b/engines/agi/agi.h @@ -760,8 +760,6 @@ public: void initVersion(void); void setVersion(uint16 version); - Common::Error loadGameState(int slot); - Common::Error saveGameState(int slot, const char *desc); bool canLoadGameStateCurrently(); bool canSaveGameStateCurrently(); }; @@ -785,6 +783,8 @@ public: return _gameId; } + Common::Error loadGameState(int slot); + Common::Error saveGameState(int slot, const char *desc); private: diff --git a/engines/agi/detection.cpp b/engines/agi/detection.cpp index 6bd46ea812..553e42f88e 100644 --- a/engines/agi/detection.cpp +++ b/engines/agi/detection.cpp @@ -1290,20 +1290,6 @@ const ADGameDescription *AgiMetaEngine::fallbackDetect(const Common::FSList &fsl namespace Agi { -Common::Error AgiBase::loadGameState(int slot) { - static char saveLoadSlot[12]; - sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), slot); - loadGame(saveLoadSlot); - return Common::kNoError; // TODO: return success/failure -} - -Common::Error AgiBase::saveGameState(int slot, const char *desc) { - static char saveLoadSlot[12]; - sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), slot); - saveGame(saveLoadSlot, desc); - return Common::kNoError; // TODO: return success/failure -} - bool AgiBase::canLoadGameStateCurrently() { return (!(getGameType() == GType_PreAGI) && getflag(fMenusWork) && !_noSaveLoadAllowed); } diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 7220dbd162..50b329c0b6 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -972,6 +972,9 @@ void AgiEngine::checkQuickLoad() { snprintf (saveNameBuffer, 256, "%s.%03d", _targetName.c_str(), ConfMan.getInt("save_slot")); + _sprites->eraseBoth(); + _sound->stopSound(); + if (loadGame(saveNameBuffer, false) == errOK) { // Do not check game id _game.exitAllLogics = 1; _menu->enableAll(); @@ -979,4 +982,29 @@ void AgiEngine::checkQuickLoad() { } } +Common::Error AgiEngine::loadGameState(int slot) { + static char saveLoadSlot[12]; + sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), slot); + + _sprites->eraseBoth(); + _sound->stopSound(); + + if (loadGame(saveLoadSlot) == errOK) { + _game.exitAllLogics = 1; + _menu->enableAll(); + return Common::kNoError; + } else { + return Common::kUnknownError; + } +} + +Common::Error AgiEngine::saveGameState(int slot, const char *desc) { + static char saveLoadSlot[12]; + sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), slot); + if (saveGame(saveLoadSlot, desc) == errOK) + return Common::kNoError; + else + return Common::kUnknownError; +} + } // End of namespace Agi -- cgit v1.2.3