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.
This commit is contained in:
richiesams 2013-08-26 14:13:27 -05:00
parent b667002124
commit a6b2bb7581
2 changed files with 8 additions and 15 deletions

View file

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

View file

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