ZVISION: Remove zero valued entries in the global state table once a frame

This commit is contained in:
richiesams 2013-09-03 23:53:30 -05:00
parent dd307c2484
commit 9dd54a16e0
2 changed files with 15 additions and 0 deletions

View file

@ -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);