[Scummvm-cvs-logs] SF.net SVN: scummvm:[39095] scummvm/trunk/engines/sword1

hkz at users.sourceforge.net hkz at users.sourceforge.net
Tue Mar 3 21:05:00 CET 2009


Revision: 39095
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39095&view=rev
Author:   hkz
Date:     2009-03-03 20:05:00 +0000 (Tue, 03 Mar 2009)

Log Message:
-----------
Enabled and hopefully fixed GMM saving/loading for sword1

Modified Paths:
--------------
    scummvm/trunk/engines/sword1/detection.cpp
    scummvm/trunk/engines/sword1/sword1.cpp
    scummvm/trunk/engines/sword1/sword1.h

Modified: scummvm/trunk/engines/sword1/detection.cpp
===================================================================
--- scummvm/trunk/engines/sword1/detection.cpp	2009-03-03 19:49:50 UTC (rev 39094)
+++ scummvm/trunk/engines/sword1/detection.cpp	2009-03-03 20:05:00 UTC (rev 39095)
@@ -108,7 +108,9 @@
 
 bool Sword1::SwordEngine::hasFeature(EngineFeature f) const {
 	return
-		(f == kSupportsRTL);
+		(f == kSupportsRTL) ||
+		(f == kSupportsSavingDuringRuntime) ||
+		(f == kSupportsLoadingDuringRuntime);
 }
 
 GameList SwordMetaEngine::getSupportedGames() const {
@@ -313,30 +315,28 @@
 
 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

Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp	2009-03-03 19:49:50 UTC (rev 39094)
+++ scummvm/trunk/engines/sword1/sword1.cpp	2009-03-03 20:05:00 UTC (rev 39095)
@@ -149,6 +149,7 @@
 }
 
 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 @@
 	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

Modified: scummvm/trunk/engines/sword1/sword1.h
===================================================================
--- scummvm/trunk/engines/sword1/sword1.h	2009-03-03 19:49:50 UTC (rev 39094)
+++ scummvm/trunk/engines/sword1/sword1.h	2009-03-03 20:05:00 UTC (rev 39095)
@@ -76,7 +76,7 @@
 	virtual ~SwordEngine();
 	static SystemVars _systemVars;
 	void reinitialize(void);
-	
+
 	uint32 _features;
 
 	bool mouseIsActive();
@@ -98,13 +98,10 @@
 	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);
+	bool canLoadGameStateCurrently();
 	Common::Error saveGameState(int slot, const char *desc);
-	bool canLoadGameStateCurrently();
 	bool canSaveGameStateCurrently();
-#endif
 
 private:
 	void delay(int32 amount);
@@ -113,6 +110,9 @@
 	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;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list