aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorrichiesams2013-07-29 22:16:21 -0500
committerrichiesams2013-08-04 13:32:54 -0500
commitf39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7 (patch)
treed5c06f4f4e17abd32576f1238b4e1b4a58082e44 /engines/zvision
parentf975fbe52190ccc0ca1264d6aa63a897ad784f31 (diff)
downloadscummvm-rg350-f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7.tar.gz
scummvm-rg350-f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7.tar.bz2
scummvm-rg350-f39e1fdc43a97c0d06bfcda0e5c6dfdfb4e95ef7.zip
ZVISION: Move CriteriaOperator, Criteria, and StateFlag inside the Puzzle class
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/puzzle.h60
-rw-r--r--engines/zvision/scr_file_handling.cpp18
-rw-r--r--engines/zvision/script_manager.cpp12
-rw-r--r--engines/zvision/script_manager.h2
4 files changed, 47 insertions, 45 deletions
diff --git a/engines/zvision/puzzle.h b/engines/zvision/puzzle.h
index a0c4e9d758..fba139c0a6 100644
--- a/engines/zvision/puzzle.h
+++ b/engines/zvision/puzzle.h
@@ -29,41 +29,43 @@ namespace ZVision {
class ResultAction;
-/** How criteria should be decided */
-enum CriteriaOperator {
- EQUAL_TO,
- NOT_EQUAL_TO,
- GREATER_THAN,
- LESS_THAN
-};
-
-/** Criteria for a Puzzle result to be fired */
-struct Criteria {
- /** The key of a global state */
- uint32 key;
- /**
- * What we're comparing the value of the global state against
- * This can either be a pure value or it can be the key of another global state
- */
- uint32 argument;
- /** How to do the comparison */
- CriteriaOperator criteriaOperator;
- /** Whether 'argument' is the key of a global state (true) or a pure value (false) */
- bool argumentIsAKey;
-};
-
-enum StateFlags {
- ONCE_PER_INST = 0x01,
- DO_ME_NOW = 0x02,
- DISABLED = 0x04
-};
-
class Puzzle {
public:
Puzzle() {}
~Puzzle();
Puzzle(const Puzzle &other);
+
+public:
+ /** How criteria should be decided */
+ enum CriteriaOperator {
+ EQUAL_TO,
+ NOT_EQUAL_TO,
+ GREATER_THAN,
+ LESS_THAN
+ };
+
+ /** Criteria for a Puzzle result to be fired */
+ struct Criteria {
+ /** The key of a global state */
+ uint32 key;
+ /**
+ * What we're comparing the value of the global state against
+ * This can either be a pure value or it can be the key of another global state
+ */
+ uint32 argument;
+ /** How to do the comparison */
+ CriteriaOperator criteriaOperator;
+ /** Whether 'argument' is the key of a global state (true) or a pure value (false) */
+ bool argumentIsAKey;
+ };
+ enum StateFlags {
+ ONCE_PER_INST = 0x01,
+ DO_ME_NOW = 0x02,
+ DISABLED = 0x04
+ };
+
+public:
uint32 key;
Common::List<Criteria> criteriaList;
// This has to be list of pointers because ResultAction is abstract
diff --git a/engines/zvision/scr_file_handling.cpp b/engines/zvision/scr_file_handling.cpp
index ec73fa1fdf..5f2140d45a 100644
--- a/engines/zvision/scr_file_handling.cpp
+++ b/engines/zvision/scr_file_handling.cpp
@@ -71,7 +71,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
while (!line.contains('}')) {
if (line.matchString("criteria {", true)) {
- Criteria criteria;
+ Puzzle::Criteria criteria;
if (parseCriteria(&criteria, stream)) {
puzzle.criteriaList.push_back(criteria);
}
@@ -86,7 +86,7 @@ void ScriptManager::parsePuzzle(Puzzle &puzzle, Common::SeekableReadStream &stre
}
}
-bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const {
+bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const {
// Loop until we find the closing brace
Common::String line = stream.readLine();
trimCommentsAndWhiteSpace(&line);
@@ -108,13 +108,13 @@ bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream
// Parse the operator out of the second token
token = tokenizer.nextToken();
if (token.c_str()[0] == '=')
- criteria->criteriaOperator = EQUAL_TO;
+ criteria->criteriaOperator = Puzzle::EQUAL_TO;
else if (token.c_str()[0] == '!')
- criteria->criteriaOperator = NOT_EQUAL_TO;
+ criteria->criteriaOperator = Puzzle::NOT_EQUAL_TO;
else if (token.c_str()[0] == '>')
- criteria->criteriaOperator = GREATER_THAN;
+ criteria->criteriaOperator = Puzzle::GREATER_THAN;
else if (token.c_str()[0] == '<')
- criteria->criteriaOperator = LESS_THAN;
+ criteria->criteriaOperator = Puzzle::LESS_THAN;
// First determine if the last token is an id or a value
// Then parse it into 'argument'
@@ -276,11 +276,11 @@ byte ScriptManager::parseFlags(Common::SeekableReadStream &stream) const {
while (!line.contains('}')) {
if (line.matchString("ONCE_PER_INST", true)) {
- flags |= ONCE_PER_INST;
+ flags |= Puzzle::ONCE_PER_INST;
} else if (line.matchString("DO_ME_NOW", true)) {
- flags |= DO_ME_NOW;
+ flags |= Puzzle::DO_ME_NOW;
} else if (line.matchString("DISABLED", true)) {
- flags |= DISABLED;
+ flags |= Puzzle::DISABLED;
}
line = stream.readLine();
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp
index 97f2cadfce..0ff0509737 100644
--- a/engines/zvision/script_manager.cpp
+++ b/engines/zvision/script_manager.cpp
@@ -45,7 +45,7 @@ void ScriptManager::createReferenceTable() {
Puzzle *puzzlePtr = &(*activePuzzleIter);
// Iterate through each Criteria and add a reference from the criteria key to the Puzzle
- for (Common::List<Criteria>::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
+ for (Common::List<Puzzle::Criteria>::iterator criteriaIter = activePuzzleIter->criteriaList.begin(); criteriaIter != (*activePuzzleIter).criteriaList.end(); criteriaIter++) {
_referenceTable[criteriaIter->key].push_back(puzzlePtr);
// If the argument is a key, add a reference to it as well
@@ -80,7 +80,7 @@ void ScriptManager::checkPuzzleCriteria() {
// Check each Criteria
bool criteriaMet = false;
- for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
+ for (Common::List<Puzzle::Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
// Get the value to compare against
byte argumentValue;
if ((*iter).argument)
@@ -90,16 +90,16 @@ void ScriptManager::checkPuzzleCriteria() {
// Do the comparison
switch ((*iter).criteriaOperator) {
- case EQUAL_TO:
+ case Puzzle::EQUAL_TO:
criteriaMet = getStateValue(iter->key) == argumentValue;
break;
- case NOT_EQUAL_TO:
+ case Puzzle::NOT_EQUAL_TO:
criteriaMet = getStateValue(iter->key) != argumentValue;
break;
- case GREATER_THAN:
+ case Puzzle::GREATER_THAN:
criteriaMet = getStateValue(iter->key) > argumentValue;
break;
- case LESS_THAN:
+ case Puzzle::LESS_THAN:
criteriaMet = getStateValue(iter->key) < argumentValue;
break;
}
diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h
index caec0dd550..3e054ff68a 100644
--- a/engines/zvision/script_manager.h
+++ b/engines/zvision/script_manager.h
@@ -103,7 +103,7 @@ private:
* @param stream Scr file stream
* @return Whether any criteria were read
*/
- bool ScriptManager::parseCriteria(Criteria *criteria, Common::SeekableReadStream &stream) const;
+ bool ScriptManager::parseCriteria(Puzzle::Criteria *criteria, Common::SeekableReadStream &stream) const;
/**
* Parses the stream into a Results object