diff options
author | Filippos Karapetis | 2015-01-10 22:03:15 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-01-10 22:03:15 +0200 |
commit | 21e9007d80ee60e519896c330324e5e3a95f772f (patch) | |
tree | 037976cbb0e675ce4dad27dd4fcb87baadeb4c41 | |
parent | 899cf4813c7e009e1dbee56be8ad10d20650cf10 (diff) | |
download | scummvm-rg350-21e9007d80ee60e519896c330324e5e3a95f772f.tar.gz scummvm-rg350-21e9007d80ee60e519896c330324e5e3a95f772f.tar.bz2 scummvm-rg350-21e9007d80ee60e519896c330324e5e3a95f772f.zip |
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
-rw-r--r-- | engines/zvision/file/save_manager.cpp | 21 | ||||
-rw-r--r-- | engines/zvision/file/save_manager.h | 2 | ||||
-rw-r--r-- | engines/zvision/scripting/actions.cpp | 19 | ||||
-rw-r--r-- | engines/zvision/scripting/actions.h | 9 | ||||
-rw-r--r-- | engines/zvision/scripting/scr_file_handling.cpp | 4 | ||||
-rw-r--r-- | engines/zvision/scripting/script_manager.cpp | 6 | ||||
-rw-r--r-- | engines/zvision/scripting/script_manager.h | 1 |
7 files changed, 48 insertions, 14 deletions
diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index fb9cceecbe..5e96e4ab5e 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 d3f6aaaedc..9e816373ea 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 e3fc6fa549..e989478dd1 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 c2350bc83a..8d43309b74 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 7856bf7b2e..b4da61a119 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 8220d5c37c..ad049434c3 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 a05c112a18..f6201c3572 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(); |