diff options
author | richiesams | 2013-08-26 14:13:27 -0500 |
---|---|---|
committer | richiesams | 2013-08-28 16:44:23 -0500 |
commit | a6b2bb75819554a779b238045c21867943ce5f6c (patch) | |
tree | 6860048122872f9ada1e6c6d88f1e596a72dbd01 | |
parent | b66700212479bb05ce1367a43fe6341cdfca1b00 (diff) | |
download | scummvm-rg350-a6b2bb75819554a779b238045c21867943ce5f6c.tar.gz scummvm-rg350-a6b2bb75819554a779b238045c21867943ce5f6c.tar.bz2 scummvm-rg350-a6b2bb75819554a779b238045c21867943ce5f6c.zip |
ZVISION: Remove ScriptManager::_activeNodes and change all iterators to iterate over _activeControls
We also change _activeControls to a List instead of a HashMap because a List should have
slightly better iteration time.
-rw-r--r-- | engines/zvision/script_manager.cpp | 17 | ||||
-rw-r--r-- | engines/zvision/script_manager.h | 6 |
2 files changed, 8 insertions, 15 deletions
diff --git a/engines/zvision/script_manager.cpp b/engines/zvision/script_manager.cpp index dcfcf02048..3cc4c92f0b 100644 --- a/engines/zvision/script_manager.cpp +++ b/engines/zvision/script_manager.cpp @@ -108,11 +108,10 @@ void ScriptManager::createReferenceTable() { void ScriptManager::updateNodes(uint deltaTimeMillis) { // If process() returns true, it means the node can be deleted - for (Common::List<ActionNode *>::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) { + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end();) { if ((*iter)->process(deltaTimeMillis)) { - // Delete the node then remove the pointer - delete (*iter); - iter = _activeNodes.erase(iter); + // Remove the node + iter = _activeControls.erase(iter); } else { iter++; } @@ -257,12 +256,10 @@ void ScriptManager::changeLocationIntern() { delete (*iter); } _activePuzzles.clear(); - for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { - delete (*iter)._value; + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + delete (*iter); } _activeControls.clear(); - _engine->clearAllMouseEvents(); - // TODO: See if we need to clear _activeNodes as well. And if so, remember to delete the nodes before clearing the list // Revert to the idle cursor _engine->getCursorManager()->revertToIdle(); @@ -278,8 +275,8 @@ void ScriptManager::changeLocationIntern() { _engine->getRenderManager()->setBackgroundPosition(_nextLocation.offset); // Enable all the controls - for (Common::HashMap<uint32, Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { - (*iter)._value->enable(); + for (Common::List<Control *>::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { + (*iter)->enable(); } // Add all the local puzzles to the queue to be checked diff --git a/engines/zvision/script_manager.h b/engines/zvision/script_manager.h index 27e2e61238..0f3ea43dc3 100644 --- a/engines/zvision/script_manager.h +++ b/engines/zvision/script_manager.h @@ -37,7 +37,6 @@ class SeekableReadStream; namespace ZVision { class ZVision; -class ActionNode; struct Location { char world; @@ -60,8 +59,6 @@ private: * particular state key are checked after the key is modified. */ Common::HashMap<uint32, uint> _globalState; - /** Holds the currently active ActionNodes */ - Common::List<ActionNode *> _activeNodes; /** References _globalState keys to Puzzles */ Common::HashMap<uint32, Common::Array<Puzzle *> > _referenceTable; /** Holds the Puzzles that should be checked this frame */ @@ -71,13 +68,12 @@ private: /** Holds the global puzzles */ Common::List<Puzzle *>_globalPuzzles; /** Holds the currently active controls */ - Common::HashMap<uint32, Control *> _activeControls; + Common::List<Control *> _activeControls; Location _nextLocation; bool _changeLocation; public: - void initialize(); void update(uint deltaTimeMillis); |