aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/zvision/scr_file_handling.cpp8
-rw-r--r--engines/zvision/script_manager.cpp21
-rw-r--r--engines/zvision/script_manager.h7
3 files changed, 28 insertions, 8 deletions
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index 061079cd85..efd122994d 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -33,7 +33,7 @@
namespace ZVision {
-void ScriptManager::parseScrFile(const Common::String &fileName) {
+void ScriptManager::parseScrFile(const Common::String &fileName, bool isGlobal) {
Common::File file;
if (!file.open(fileName))
return; // File.open already throws a warning if the file doesn't exist, so there is no need to throw another
@@ -54,7 +54,11 @@ void ScriptManager::parseScrFile(const Common::String &fileName) {
sscanf(line.c_str(),"puzzle:%u",&(puzzle.key));
parsePuzzle(puzzle, file);
- _activePuzzles.push_back(puzzle);
+ if (isGlobal) {
+ _globalPuzzles.push_back(puzzle);
+ } else {
+ _activePuzzles.push_back(puzzle);
+ }
} else if (line.matchString("control:*", true)) {
Common::SharedPtr<Control> control;
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index fe6548cd80..027fec43a1 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -35,13 +35,12 @@ namespace ZVision {
ScriptManager::ScriptManager(ZVision *engine) : _engine(engine) {}
-// TODO: Actually do something in the initialize or remove it
void ScriptManager::initialize() {
-
+ parseScrFile("universe.scr", true);
}
void ScriptManager::createReferenceTable() {
- // Iterate through each Puzzle
+ // Iterate through each local Puzzle
for (Common::List<Puzzle>::iterator activePuzzleIter = _activePuzzles.begin(); activePuzzleIter != _activePuzzles.end(); activePuzzleIter++) {
Puzzle *puzzlePtr = &(*activePuzzleIter);
@@ -50,7 +49,21 @@ void ScriptManager::createReferenceTable() {
_referenceTable[criteriaIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
- if (criteriaIter->argument)
+ if (criteriaIter->argumentIsAKey)
+ _referenceTable[criteriaIter->argument].push_back(puzzlePtr);
+ }
+ }
+
+ // Iterate through each global Puzzle
+ for (Common::List<Puzzle>::iterator globalPuzzleIter = _globalPuzzles.begin(); globalPuzzleIter != _globalPuzzles.end(); globalPuzzleIter++) {
+ Puzzle *puzzlePtr = &(*globalPuzzleIter);
+
+ // Iterate through each Criteria and add a reference from the criteria key to the Puzzle
+ for (Common::List<Puzzle::Criteria>::iterator criteriaIter = globalPuzzleIter->criteriaList.begin(); criteriaIter != (*globalPuzzleIter).criteriaList.end(); criteriaIter++) {
+ _referenceTable[criteriaIter->key].push_back(puzzlePtr);
+
+ // If the argument is a key, add a reference to it as well
+ if (criteriaIter->argumentIsAKey)
_referenceTable[criteriaIter->argument].push_back(puzzlePtr);
}
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index 484069b335..63dc4f8804 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -59,6 +59,8 @@ private:
Common::Stack<Puzzle *> _puzzlesToCheck;
/** Holds the currently active puzzles */
Common::List<Puzzle> _activePuzzles;
+ /** Holds the global puzzles */
+ Common::List<Puzzle>_globalPuzzles;
/** Holds the currently active controls */
Common::List<Common::SharedPtr<Control> > _activeControls;
@@ -82,9 +84,10 @@ private:
/**
* Parses a script file into triggers and events
*
- * @param fileName Name of the .scr file
+ * @param fileName Name of the .scr file
+ * @param isGlobal Are the puzzles included in the file global (true). AKA, the won't be purged during location changes
*/
- void parseScrFile(const Common::String &fileName);
+ void parseScrFile(const Common::String &fileName, bool isGlobal = false);
/**
* Parses the stream into a Puzzle object