diff options
-rw-r--r-- | engines/zvision/script_manager.cpp | 14 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index f3c945d658..45e1459293 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -196,6 +196,17 @@ void ScriptManager::checkPuzzleCriteria() { } } +void ScriptManager::cleanStateTable() { + for (Common::HashMap<uint32, uint32>::iterator iter = _globalState.begin(); iter != _globalState.end(); iter++) { + // If the value is equal to zero, we can purge it since getStateValue() + // will return zero if _globalState doesn't contain a key + if ((*iter)._value == 0) { + // Remove the node + _globalState.erase(iter); + } + } +} + uint ScriptManager::getStateValue(uint32 key) { if (_globalState.contains(key)) return _globalState[key]; @@ -285,6 +296,9 @@ void ScriptManager::changeLocation(char world, char room, char node, char view, // Reset the background velocity _engine->getRenderManager()->setBackgroundVelocity(0); + // Clean the global state table + cleanStateTable(); + // Parse into puzzles and controls Common::String fileName = Common::String::format("%c%c%c%c.scr", world, room, node, view); parseScrFile(fileName); diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 75be66c3f0..723f4fe032 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -114,6 +114,7 @@ private: void createReferenceTable(); void updateNodes(uint deltaTimeMillis); void checkPuzzleCriteria(); + void cleanStateTable(); // TODO: Make this private. It was only made public so Console::cmdParseAllScrFiles() could use it public: |