ZVISION: Move the criteriaMet bool outside of the loop

Only fire off the Results of ALL of the criteria are met
This commit is contained in:
richiesams 2013-07-29 21:52:27 -05:00
parent c22c91b7d3
commit 48a3a1530d

View File

@ -77,10 +77,10 @@ void ScriptManager::updateNodes(uint32 deltaTimeMillis) {
void ScriptManager::checkPuzzleCriteria() {
while (!_puzzlesToCheck.empty()) {
Puzzle *puzzle = _puzzlesToCheck.pop();
// Check each Criteria
for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
bool criteriaMet = false;
// Check each Criteria
bool criteriaMet = false;
for (Common::List<Criteria>::iterator iter = puzzle->criteriaList.begin(); iter != puzzle->criteriaList.end(); iter++) {
// Get the value to compare against
byte argumentValue;
if ((*iter).argument)
@ -104,11 +104,16 @@ void ScriptManager::checkPuzzleCriteria() {
break;
}
// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
if (criteriaMet) {
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
(*resultIter)->execute(_engine);
}
if (!criteriaMet) {
break;
}
}
// TODO: Add logic for the different Flags (aka, ONCE_PER_INST)
// criteriaList can be empty. Aka, the puzzle should be executed immediately
if (puzzle->criteriaList.empty() || criteriaMet) {
for (Common::List<ResultAction *>::iterator resultIter = puzzle->resultActions.begin(); resultIter != puzzle->resultActions.end(); resultIter++) {
(*resultIter)->execute(_engine);
}
}
}