From a6b2bb75819554a779b238045c21867943ce5f6c Mon Sep 17 00:00:00 2001 From: richiesams Date: Mon, 26 Aug 2013 14:13:27 -0500 Subject: 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. --- engines/zvision/script_manager.cpp | 17 +++++++---------- engines/zvision/script_manager.h | 6 +----- 2 files changed, 8 insertions(+), 15 deletions(-) (limited to 'engines') 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::iterator iter = _activeNodes.begin(); iter != _activeNodes.end();) { + for (Common::List::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::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { - delete (*iter)._value; + for (Common::List::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::iterator iter = _activeControls.begin(); iter != _activeControls.end(); iter++) { - (*iter)._value->enable(); + for (Common::List::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 _globalState; - /** Holds the currently active ActionNodes */ - Common::List _activeNodes; /** References _globalState keys to Puzzles */ Common::HashMap > _referenceTable; /** Holds the Puzzles that should be checked this frame */ @@ -71,13 +68,12 @@ private: /** Holds the global puzzles */ Common::List_globalPuzzles; /** Holds the currently active controls */ - Common::HashMap _activeControls; + Common::List _activeControls; Location _nextLocation; bool _changeLocation; public: - void initialize(); void update(uint deltaTimeMillis); -- cgit v1.2.3