[Scummvm-cvs-logs] scummvm master -> 21e9007d80ee60e519896c330324e5e3a95f772f

bluegr bluegr at gmail.com
Sat Jan 10 21:04:26 CET 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
21e9007d80 Revert "ZVISION: Remove ActionRestoreGame and loading of r.svr (restart slot)"


Commit: 21e9007d80ee60e519896c330324e5e3a95f772f
    https://github.com/scummvm/scummvm/commit/21e9007d80ee60e519896c330324e5e3a95f772f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-01-10T22:03:15+02:00

Commit Message:
Revert "ZVISION: Remove ActionRestoreGame and loading of r.svr (restart slot)"

This reverts commit 9f642074ba8e17aa23b01bcee82b2293fe84f8f1, as it
broke the credits screen in ZGI.

This has been rewritten to use the common save code

Changed paths:
    engines/zvision/file/save_manager.cpp
    engines/zvision/file/save_manager.h
    engines/zvision/scripting/actions.cpp
    engines/zvision/scripting/actions.h
    engines/zvision/scripting/scr_file_handling.cpp
    engines/zvision/scripting/script_manager.cpp
    engines/zvision/scripting/script_manager.h



diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp
index fb9ccee..5e96e4a 100644
--- a/engines/zvision/file/save_manager.cpp
+++ b/engines/zvision/file/save_manager.cpp
@@ -130,12 +130,25 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S
 	file->writeSint16LE(td.tm_min);
 }
 
-Common::Error SaveManager::loadGame(uint slot) {
-	Common::SeekableReadStream *saveFile = getSlotFile(slot);
-	if (saveFile == 0) {
-		return Common::kPathDoesNotExist;
+Common::Error SaveManager::loadGame(int slot) {
+	Common::SeekableReadStream *saveFile = NULL;
+	
+	if (slot >= 0) {
+		saveFile = getSlotFile(slot);
+	} else {
+		Common::File *saveFile = _engine->getSearchManager()->openFile("r.svr");
+		if (!saveFile) {
+			saveFile = new Common::File;
+			if (!saveFile->open("r.svr")) {
+				delete saveFile;
+				return Common::kPathDoesNotExist;
+			}
+		}
 	}
 
+	if (!saveFile)
+		return Common::kPathDoesNotExist;
+
 	// Read the header
 	SaveGameHeader header;
 	if (!readSaveGameHeader(saveFile, header)) {
diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h
index d3f6aaa..9e81637 100644
--- a/engines/zvision/file/save_manager.h
+++ b/engines/zvision/file/save_manager.h
@@ -91,7 +91,7 @@ public:
 	 *
 	 * @param slot    The save slot to load. Must be [1, 20]
 	 */
-	Common::Error loadGame(uint slot);
+	Common::Error loadGame(int slot);
 
 	Common::SeekableReadStream *getSlotFile(uint slot);
 	bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header);
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index e3fc6fa..e989478 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -23,11 +23,12 @@
 #include "common/scummsys.h"
 #include "video/video_decoder.h"
 
+#include "zvision/scripting/actions.h"
+
 #include "zvision/zvision.h"
 #include "zvision/scripting/script_manager.h"
 #include "zvision/graphics/render_manager.h"
 #include "zvision/file/save_manager.h"
-#include "zvision/scripting/actions.h"
 #include "zvision/scripting/menu.h"
 #include "zvision/scripting/effects/timer_effect.h"
 #include "zvision/scripting/effects/music_effect.h"
@@ -798,6 +799,22 @@ bool ActionRandom::execute() {
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// ActionRestoreGame
+//////////////////////////////////////////////////////////////////////////////
+
+ActionRestoreGame::ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line) :
+	ResultAction(engine, slotkey) {
+	char buf[128];
+	sscanf(line.c_str(), "%s", buf);
+	_fileName = Common::String(buf);
+}
+
+bool ActionRestoreGame::execute() {
+	_engine->getSaveManager()->loadGame(-1);
+	return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
 // ActionRotateTo
 //////////////////////////////////////////////////////////////////////////////
 
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index c2350bc..8d43309 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -340,6 +340,15 @@ private:
 	ValueSlot *_max;
 };
 
+class ActionRestoreGame : public ResultAction {
+public:
+	ActionRestoreGame(ZVision *engine, int32 slotkey, const Common::String &line);
+	bool execute();
+
+private:
+	Common::String _fileName;
+};
+
 class ActionRotateTo : public ResultAction {
 public:
 	ActionRotateTo(ZVision *engine, int32 slotkey, const Common::String &line);
diff --git a/engines/zvision/scripting/scr_file_handling.cpp b/engines/zvision/scripting/scr_file_handling.cpp
index 7856bf7..b4da61a 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -271,8 +271,8 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
 					actionList.push_back(new ActionRegion(_engine, slot, args));
 				} else if (act.matchString("restore_game", true)) {
 					// Only used by ZGI to load the restart game slot, r.svr.
-					_engine->getScriptManager()->reset();
-					_engine->getScriptManager()->changeLocation('g', 'a', 'r', 'y', 0);
+					// Used by the credits screen.
+					actionList.push_back(new ActionRestoreGame(_engine, slot, args));
 				} else if (act.matchString("rotate_to", true)) {
 					actionList.push_back(new ActionRotateTo(_engine, slot, args));
 				} else if (act.matchString("save_game", true)) {
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 8220d5c..ad04943 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -686,7 +686,7 @@ void ScriptManager::serialize(Common::WriteStream *stream) {
 		stream->writeSint16LE(getStateValue(i));
 }
 
-void ScriptManager::reset() {
+void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
 	// Clear out the current table values
 	_globalState.clear();
 	_globalStateFlags.clear();
@@ -706,10 +706,6 @@ void ScriptManager::reset() {
 	_activeSideFx.clear();
 
 	_referenceTable.clear();
-}
-
-void ScriptManager::deserialize(Common::SeekableReadStream *stream) {
-	reset();
 
 	if (stream->readUint32BE() != MKTAG('Z', 'N', 'S', 'G') || stream->readUint32LE() != 4) {
 		changeLocation('g', 'a', 'r', 'y', 0);
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index a05c112..f6201c3 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -248,7 +248,6 @@ public:
 
 	void serialize(Common::WriteStream *stream);
 	void deserialize(Common::SeekableReadStream *stream);
-	void reset();
 
 	Location getCurrentLocation() const;
 	Location getLastLocation();






More information about the Scummvm-git-logs mailing list