[Scummvm-cvs-logs] SF.net SVN: scummvm:[47735] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Sun Jan 31 02:26:06 CET 2010


Revision: 47735
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47735&view=rev
Author:   thebluegr
Date:     2010-01-31 01:26:06 +0000 (Sun, 31 Jan 2010)

Log Message:
-----------
Removed duplicate code. Some cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/detection.cpp
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/savegame.cpp
    scummvm/trunk/engines/sci/engine/savegame.h

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2010-01-31 01:15:05 UTC (rev 47734)
+++ scummvm/trunk/engines/sci/console.cpp	2010-01-31 01:26:06 UTC (rev 47735)
@@ -893,26 +893,17 @@
 		return true;
 	}
 
-	EngineState *newstate = NULL;
-
 	Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
 	Common::SeekableReadStream *in = saveFileMan->openForLoading(argv[1]);
 	if (in) {
 		// found a savegame file
-		newstate = gamestate_restore(_vm->_gamestate, in);
+		gamestate_restore(_vm->_gamestate, in);
 		delete in;
 	}
 
-	if (newstate) {
-		_vm->_gamestate->successor = newstate; // Set successor
-
-		script_abort_flag = 2; // Abort current game with replay
-
-		shrink_execution_stack(_vm->_gamestate, _vm->_gamestate->execution_stack_base + 1);
-		return 0;
-	} else {
+	if (_vm->_gamestate->r_acc == make_reg(0, 1)) {
 		DebugPrintf("Restoring gamestate '%s' failed.\n", argv[1]);
-		return 1;
+		return true;
 	}
 
 	return false;

Modified: scummvm/trunk/engines/sci/detection.cpp
===================================================================
--- scummvm/trunk/engines/sci/detection.cpp	2010-01-31 01:15:05 UTC (rev 47734)
+++ scummvm/trunk/engines/sci/detection.cpp	2010-01-31 01:26:06 UTC (rev 47735)
@@ -475,23 +475,17 @@
 }
 
 Common::Error SciEngine::loadGameState(int slot) {
-	EngineState *newstate = NULL;
 	Common::String fileName = Common::String::printf("%s.%03d", _targetName.c_str(), slot);
 	Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
 	Common::SeekableReadStream *in = saveFileMan->openForLoading(fileName);
 
 	if (in) {
 		// found a savegame file
-		newstate = gamestate_restore(_gamestate, in);
+		gamestate_restore(_gamestate, in);
 		delete in;
 	}
 
-	if (newstate) {
-		_gamestate->successor = newstate; // Set successor
-
-		script_abort_flag = 2; // Abort current game with replay
-
-		shrink_execution_stack(_gamestate, _gamestate->execution_stack_base + 1);
+	if (_gamestate->r_acc != make_reg(0, 1)) {
 		return Common::kNoError;
 	} else {
 		warning("Restoring gamestate '%s' failed", fileName.c_str());

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2010-01-31 01:15:05 UTC (rev 47734)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2010-01-31 01:26:06 UTC (rev 47735)
@@ -618,17 +618,9 @@
 		if ((in = saveFileMan->openForLoading(filename))) {
 			// found a savegame file
 
-			EngineState *newstate = gamestate_restore(s, in);
+			gamestate_restore(s, in);
 			delete in;
 
-			if (newstate) {
-				s->successor = newstate;
-				script_abort_flag = 2; // Abort current game with replay
-				shrink_execution_stack(s, s->execution_stack_base + 1);
-			} else {
-				s->r_acc = make_reg(0, 1);
-				warning("Restoring failed (game_id = '%s')", game_id.c_str());
-			}
 			return s->r_acc;
 		}
 	}

Modified: scummvm/trunk/engines/sci/engine/savegame.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.cpp	2010-01-31 01:15:05 UTC (rev 47734)
+++ scummvm/trunk/engines/sci/engine/savegame.cpp	2010-01-31 01:26:06 UTC (rev 47735)
@@ -903,28 +903,21 @@
 }
 #endif
 
-EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
+void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
 	EngineState *retval;
 #ifdef USE_OLD_MUSIC_FUNCTIONS
 	SongLibrary temp;
 #endif
 
-/*
-	if (s->sound_server) {
-		if ((s->sound_server->restore)(s, dirname)) {
-			warning("Restoring failed for the sound subsystem");
-			return NULL;
-		}
-	}
-*/
-
 	SavegameMetadata meta;
 
 	Common::Serializer ser(fh, 0);
 	sync_SavegameMetadata(ser, meta);
 
-	if (fh->eos())
-		return false;
+	if (fh->eos()) {
+		s->r_acc = make_reg(0, 1);	// signal failure
+		return;
+	}
 
 	if ((meta.savegame_version < MINIMUM_SAVEGAME_VERSION) ||
 	    (meta.savegame_version > CURRENT_SAVEGAME_VERSION)) {
@@ -933,7 +926,8 @@
 		else
 			warning("Savegame version is %d- maximum supported is %0d", meta.savegame_version, CURRENT_SAVEGAME_VERSION);
 
-		return NULL;
+		s->r_acc = make_reg(0, 1);	// signal failure
+		return;
 	}
 
 	if (meta.savegame_version >= 12) {
@@ -1027,7 +1021,10 @@
 	}
 #endif
 
-	return retval;
+
+	s->successor = retval; // Set successor
+	script_abort_flag = 2; // Abort current game with replay
+	shrink_execution_stack(s, s->execution_stack_base + 1);
 }
 
 bool get_savegame_metadata(Common::SeekableReadStream *stream, SavegameMetadata *meta) {

Modified: scummvm/trunk/engines/sci/engine/savegame.h
===================================================================
--- scummvm/trunk/engines/sci/engine/savegame.h	2010-01-31 01:15:05 UTC (rev 47734)
+++ scummvm/trunk/engines/sci/engine/savegame.h	2010-01-31 01:26:06 UTC (rev 47735)
@@ -63,9 +63,8 @@
  * Restores a game state from a directory.
  * @param s			An older state from the same game
  * @param dirname	The subdirectory to restore from
- * @return NULL on failure, a pointer to a valid EngineState otherwise
  */
-EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *save);
+void gamestate_restore(EngineState *s, Common::SeekableReadStream *save);
 
 /**
  * Read the header from a savegame.


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