aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/zvision/script_manager.cpp29
-rw-r--r--engines/zvision/script_manager.h12
2 files changed, 38 insertions, 3 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 4ccbbef92d..586cc2af38 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -33,7 +33,7 @@
namespace ZVision {
-ScriptManager::ScriptManager(ZVision *engine) : _engine(engine) {}
+ScriptManager::ScriptManager(ZVision *engine) : _engine(engine), _changeLocation(false) {}
void ScriptManager::initialize() {
parseScrFile("universe.scr", true);
@@ -42,6 +42,11 @@ void ScriptManager::initialize() {
void ScriptManager::update(uint deltaTimeMillis) {
updateNodes(deltaTimeMillis);
checkPuzzleCriteria();
+
+ if (_changeLocation) {
+ changeLocationIntern();
+ _changeLocation = false;
+ }
}
void ScriptManager::createReferenceTable() {
@@ -178,6 +183,19 @@ void ScriptManager::addActionNode(const Common::SharedPtr<ActionNode> &node) {
}
void ScriptManager::changeLocation(char world, char room, char node, char view, uint32 x) {
+ _nextLocation.world = world;
+ _nextLocation.room = room;
+ _nextLocation.node = node;
+ _nextLocation.view = view;
+ _nextLocation.x = x;
+
+ _changeLocation = true;
+}
+
+void ScriptManager::changeLocationIntern() {
+ assert(_nextLocation.world != 0);
+ debug("Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.x);
+
// Clear all the containers
_referenceTable.clear();
_puzzlesToCheck.clear();
@@ -186,16 +204,21 @@ void ScriptManager::changeLocation(char world, char room, char node, char view,
_activeControls.clear();
// Parse into puzzles and controls
- Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view);
+ Common::String fileName = Common::String::format("%c%c%c%c.scr", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view);
parseScrFile(fileName);
// Create the puzzle reference table
createReferenceTable();
- // Add all the puzzles to the stack to be checked
+ // Add all the local puzzles to the stack to be checked
for (Common::List<Puzzle>::iterator iter = _activePuzzles.begin(); iter != _activePuzzles.end(); iter++) {
_puzzlesToCheck.push(&(*iter));
}
+
+ // Add all the global puzzles to the stack to be checked
+ for (Common::List<Puzzle>::iterator iter = _globalPuzzles.begin(); iter != _globalPuzzles.end(); iter++) {
+ _puzzlesToCheck.push(&(*iter));
+ }
}
} // End of namespace ZVision
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 29994259c9..8e79548f77 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -39,6 +39,14 @@ namespace ZVision {
class ZVision;
class ActionNode;
+struct Location {
+ char world;
+ char room;
+ char node;
+ char view;
+ uint32 x;
+};
+
class ScriptManager {
public:
ScriptManager(ZVision *engine);
@@ -64,6 +72,9 @@ private:
/** Holds the currently active controls */
Common::List<Common::SharedPtr<Control> > _activeControls;
+ Location _nextLocation;
+ bool _changeLocation;
+
public:
void initialize();
@@ -79,6 +90,7 @@ public:
private:
void createReferenceTable();
+ void changeLocationIntern();
void updateNodes(uint deltaTimeMillis);
void checkPuzzleCriteria();