Revert "ZVISION: Remove ActionRestoreGame and loading of r.svr (restart slot)"
This reverts commit 9f642074ba
, as it
broke the credits screen in ZGI.
This has been rewritten to use the common save code
This commit is contained in:
parent
899cf4813c
commit
21e9007d80
7 changed files with 48 additions and 14 deletions
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
@ -797,6 +798,22 @@ bool ActionRandom::execute() {
|
|||
return true;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -248,7 +248,6 @@ public:
|
|||
|
||||
void serialize(Common::WriteStream *stream);
|
||||
void deserialize(Common::SeekableReadStream *stream);
|
||||
void reset();
|
||||
|
||||
Location getCurrentLocation() const;
|
||||
Location getLastLocation();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue