diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index f3c945d658e..45e14592933 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::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 75be66c3f0f..723f4fe0322 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: