diff options
author | Marisa-Chan | 2013-11-15 18:02:18 +0000 |
---|---|---|
committer | Marisa-Chan | 2013-11-15 18:02:18 +0000 |
commit | 29fc5be12ee5e28e1b74402065858698f4b8eb16 (patch) | |
tree | 4329809e7817befb491825bc3f12297ac3278675 /engines | |
parent | a0d73c34cf21403be85af43a5f1020ae910edde7 (diff) | |
download | scummvm-rg350-29fc5be12ee5e28e1b74402065858698f4b8eb16.tar.gz scummvm-rg350-29fc5be12ee5e28e1b74402065858698f4b8eb16.tar.bz2 scummvm-rg350-29fc5be12ee5e28e1b74402065858698f4b8eb16.zip |
ZVISION: Don't add puzzle to referencetable[key] twice.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/zvision/script_manager.cpp | 15 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 1 |
2 files changed, 14 insertions, 2 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index b58056ab29..13fb58b022 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -106,6 +106,17 @@ void ScriptManager::execScope(script_scope &scope) { } } +void ScriptManager::referenceTableAddPuzzle(uint32 key, puzzle_ref ref) { + if (_referenceTable.contains(key)) { + Common::Array<puzzle_ref> *arr = &_referenceTable[key]; + for (uint32 i = 0; i < arr->size(); i++) + if ((*arr)[i].puz == ref.puz) + return; + } + + _referenceTable[key].push_back(ref); +} + void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { // Iterate through each local Puzzle for (PuzzleList::iterator PuzzleIter = scope._puzzles.begin(); PuzzleIter != scope._puzzles.end(); ++PuzzleIter) { @@ -115,12 +126,12 @@ void ScriptManager::addPuzzlesToReferenceTable(script_scope &scope) { ref.scope = &scope; ref.puz = puzzlePtr; - _referenceTable[puzzlePtr->key].push_back(ref); + referenceTableAddPuzzle(puzzlePtr->key, ref); // Iterate through each CriteriaEntry and add a reference from the criteria key to the Puzzle for (Common::List<Common::List<Puzzle::CriteriaEntry> >::iterator criteriaIter = (*PuzzleIter)->criteriaList.begin(); criteriaIter != (*PuzzleIter)->criteriaList.end(); ++criteriaIter) for (Common::List<Puzzle::CriteriaEntry>::iterator entryIter = criteriaIter->begin(); entryIter != criteriaIter->end(); ++entryIter) - _referenceTable[entryIter->key].push_back(ref); + referenceTableAddPuzzle(entryIter->key, ref); } } diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 487a27cf05..38d398248e 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -236,6 +236,7 @@ public: Location getCurrentLocation() const; private: + void referenceTableAddPuzzle(uint32 key, puzzle_ref ref); void addPuzzlesToReferenceTable(script_scope &scope); void updateNodes(uint deltaTimeMillis); void updateControls(uint deltaTimeMillis); |