From 7fc8bb81a74f58d46b82b7d555ef3da4c0076ee9 Mon Sep 17 00:00:00 2001 From: Fabio Battaglia Date: Tue, 3 Mar 2009 20:05:00 +0000 Subject: Enabled and hopefully fixed GMM saving/loading for sword1 svn-id: r39095 --- engines/sword1/detection.cpp | 16 ++++++++-------- engines/sword1/sword1.cpp | 11 +++++++++++ engines/sword1/sword1.h | 10 +++++----- 3 files changed, 24 insertions(+), 13 deletions(-) (limited to 'engines/sword1') diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp index b086f2eb0b..246bf95b8e 100644 --- a/engines/sword1/detection.cpp +++ b/engines/sword1/detection.cpp @@ -108,7 +108,9 @@ bool SwordMetaEngine::hasFeature(MetaEngineFeature f) const { bool Sword1::SwordEngine::hasFeature(EngineFeature f) const { return - (f == kSupportsRTL); + (f == kSupportsRTL) || + (f == kSupportsSavingDuringRuntime) || + (f == kSupportsLoadingDuringRuntime); } GameList SwordMetaEngine::getSupportedGames() const { @@ -313,30 +315,28 @@ SaveStateDescriptor SwordMetaEngine::querySaveMetaInfos(const char *target, int namespace Sword1 { -// FIXME: Loading a game through the GMM crashes the game -#if 0 Common::Error SwordEngine::loadGameState(int slot) { _systemVars.forceRestart = false; _systemVars.controlPanelMode = CP_NORMAL; _control->restoreGameFromFile(slot); reinitialize(); _control->doRestore(); + reinitRes(); return Common::kNoError; // TODO: return success/failure } +bool SwordEngine::canLoadGameStateCurrently() { + return mouseIsActive(); +} + Common::Error SwordEngine::saveGameState(int slot, const char *desc) { _control->setSaveDescription(slot, desc); _control->saveGameToFile(slot); return Common::kNoError; // TODO: return success/failure } -bool SwordEngine::canLoadGameStateCurrently() { - return mouseIsActive(); -} - bool SwordEngine::canSaveGameStateCurrently() { return mouseIsActive(); } -#endif } // End of namespace Sword1 diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp index 28cc1a51d2..d42d90af70 100644 --- a/engines/sword1/sword1.cpp +++ b/engines/sword1/sword1.cpp @@ -149,6 +149,7 @@ Common::Error SwordEngine::init() { } void SwordEngine::reinitialize(void) { + _sound->quitScreen(); _resMan->flush(); // free everything that's currently alloced and opened. (*evil*) _logic->initialize(); // now reinitialize these objects as they (may) have locked @@ -729,4 +730,14 @@ bool SwordEngine::mouseIsActive() { return Logic::_scriptVars[MOUSE_STATUS] & 1; } +// The following function is needed to restore proper status after GMM load game +void SwordEngine::reinitRes(void) { + _screen->newScreen(Logic::_scriptVars[NEW_SCREEN]); + _logic->newScreen(Logic::_scriptVars[NEW_SCREEN]); + _sound->newScreen(Logic::_scriptVars[NEW_SCREEN]); + Logic::_scriptVars[SCREEN] = Logic::_scriptVars[NEW_SCREEN]; + _screen->fullRefresh(); + _screen->draw(); +} + } // End of namespace Sword1 diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h index 8563946196..1aaa5da5e0 100644 --- a/engines/sword1/sword1.h +++ b/engines/sword1/sword1.h @@ -76,7 +76,7 @@ public: virtual ~SwordEngine(); static SystemVars _systemVars; void reinitialize(void); - + uint32 _features; bool mouseIsActive(); @@ -98,13 +98,10 @@ protected: virtual bool hasFeature(EngineFeature f) const; virtual void syncSoundSettings(); - // FIXME: Loading a game through the GMM crashes the game -#if 0 Common::Error loadGameState(int slot); - Common::Error saveGameState(int slot, const char *desc); bool canLoadGameStateCurrently(); + Common::Error saveGameState(int slot, const char *desc); bool canSaveGameStateCurrently(); -#endif private: void delay(int32 amount); @@ -113,6 +110,9 @@ private: void checkCd(void); void showFileErrorMsg(uint8 type, bool *fileExists); void flagsToBool(bool *dest, uint8 flags); + + void reinitRes(void); //Reinits the resources after a GMM load + uint8 mainLoop(void); Common::Point _mouseCoord; -- cgit v1.2.3