aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarisa-Chan2014-11-08 13:06:48 +0600
committerMarisa-Chan2014-11-08 13:06:48 +0600
commitea8cc34a66f7b8a853d396daaade9de25efb431f (patch)
treebf838ea9e8f7adabe151834b49100a3705cf1b6a
parent19e2251a7562defc560a25dd4655ededad4d5369 (diff)
downloadscummvm-rg350-ea8cc34a66f7b8a853d396daaade9de25efb431f.tar.gz
scummvm-rg350-ea8cc34a66f7b8a853d396daaade9de25efb431f.tar.bz2
scummvm-rg350-ea8cc34a66f7b8a853d396daaade9de25efb431f.zip
ZVISION: Implement action:restore_game
-rw-r--r--engines/zvision/scripting/actions.cpp17
-rw-r--r--engines/zvision/scripting/actions.h9
-rw-r--r--engines/zvision/scripting/scr_file_handling.cpp2
-rw-r--r--engines/zvision/scripting/script_manager.cpp40
-rw-r--r--engines/zvision/scripting/script_manager.h4
5 files changed, 50 insertions, 22 deletions
diff --git a/engines/zvision/scripting/actions.cpp b/engines/zvision/scripting/actions.cpp
index 1e1b3b2862..04f318b84e 100644
--- a/engines/zvision/scripting/actions.cpp
+++ b/engines/zvision/scripting/actions.cpp
@@ -42,6 +42,7 @@
#include "zvision/graphics/effects/fog.h"
#include "zvision/graphics/effects/light.h"
#include "zvision/graphics/effects/wave.h"
+#include "zvision/core/save_manager.h"
#include "common/file.h"
@@ -722,6 +723,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(_fileName);
+ return false;
+}
+
+//////////////////////////////////////////////////////////////////////////////
// ActionRotateTo
//////////////////////////////////////////////////////////////////////////////
diff --git a/engines/zvision/scripting/actions.h b/engines/zvision/scripting/actions.h
index dd771c1078..a6b5aa1290 100644
--- a/engines/zvision/scripting/actions.h
+++ b/engines/zvision/scripting/actions.h
@@ -385,6 +385,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 06354feaae..d5f5704f2a 100644
--- a/engines/zvision/scripting/scr_file_handling.cpp
+++ b/engines/zvision/scripting/scr_file_handling.cpp
@@ -268,7 +268,7 @@ void ScriptManager::parseResults(Common::SeekableReadStream &stream, Common::Lis
} else if (act.matchString("region", true)) {
actionList.push_back(new ActionRegion(_engine, slot, args));
} else if (act.matchString("restore_game", true)) {
- // TODO: Implement ActionRestoreGame
+ 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 28958dd972..457b491042 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -79,14 +79,18 @@ void ScriptManager::update(uint deltaTimeMillis) {
do_changeLocation();
updateNodes(deltaTimeMillis);
- execScope(nodeview);
- execScope(room);
- execScope(world);
- execScope(universe);
+ if (! execScope(nodeview))
+ return;
+ if (! execScope(room))
+ return;
+ if (! execScope(world))
+ return;
+ if (! execScope(universe))
+ return;
updateControls(deltaTimeMillis);
}
-void ScriptManager::execScope(script_scope &scope) {
+bool ScriptManager::execScope(script_scope &scope) {
// Swap queues
PuzzleList *tmp = scope.exec_queue;
scope.exec_queue = scope.scope_queue;
@@ -98,15 +102,18 @@ void ScriptManager::execScope(script_scope &scope) {
if (scope.proc_count < 2 || getStateValue(StateKey_ExecScopeStyle)) {
for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter)
- checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ return false;
} else {
for (PuzzleList::iterator PuzzleIter = scope.exec_queue->begin(); PuzzleIter != scope.exec_queue->end(); ++PuzzleIter)
- checkPuzzleCriteria(*PuzzleIter, scope.proc_count);
+ if (!checkPuzzleCriteria(*PuzzleIter, scope.proc_count))
+ return false;
}
if (scope.proc_count < 2) {
scope.proc_count++;
}
+ return true;
}
void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) {
@@ -185,16 +192,16 @@ void ScriptManager::updateControls(uint deltaTimeMillis) {
break;
}
-void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
+bool ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
// Check if the puzzle is already finished
// Also check that the puzzle isn't disabled
if (getStateValue(puzzle->key) == 1 || (getStateFlag(puzzle->key) & Puzzle::DISABLED) == Puzzle::DISABLED) {
- return;
+ return true;
}
// Check each Criteria
if (counter == 0 && (getStateFlag(puzzle->key) & Puzzle::DO_ME_NOW) == 0)
- return;
+ return true;
bool criteriaMet = false;
for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = puzzle->criteriaList.begin(); criteriaIter != puzzle->criteriaList.end(); ++criteriaIter) {
@@ -243,18 +250,13 @@ void ScriptManager::checkPuzzleCriteria(Puzzle *puzzle, uint counter) {
// Set the puzzle as completed
setStateValue(puzzle->key, 1);
- bool shouldContinue = true;
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); ++resultIter) {
- shouldContinue = shouldContinue && (*resultIter)->execute();
- if (!shouldContinue) {
- break;
- }
- }
-
- if (!shouldContinue) {
- return;
+ if (!(*resultIter)->execute())
+ return false;
}
}
+
+ return true;
}
void ScriptManager::cleanStateTable() {
diff --git a/engines/zvision/scripting/script_manager.h b/engines/zvision/scripting/script_manager.h
index fb17077aa6..ddb8c885aa 100644
--- a/engines/zvision/scripting/script_manager.h
+++ b/engines/zvision/scripting/script_manager.h
@@ -253,10 +253,10 @@ private:
void addPuzzlesToReferenceTable(script_scope &scope);
void updateNodes(uint deltaTimeMillis);
void updateControls(uint deltaTimeMillis);
- void checkPuzzleCriteria(Puzzle *puzzle, uint counter);
+ bool checkPuzzleCriteria(Puzzle *puzzle, uint counter);
void cleanStateTable();
void cleanScriptScope(script_scope &scope);
- void execScope(script_scope &scope);
+ bool execScope(script_scope &scope);
/** Perform change location */
void do_changeLocation();