From e18effcce4ba7a998b0b83491c2b7363ba55ac64 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Fri, 28 Jun 2019 02:20:57 +0530 Subject: HDB: Rewrite _animTargets as a struct array --- engines/hdb/ai-init.cpp | 4 +--- engines/hdb/ai-lists.cpp | 17 ++++++++--------- engines/hdb/ai.h | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp index 5bb8c89c05..56ecad26ca 100644 --- a/engines/hdb/ai-init.cpp +++ b/engines/hdb/ai-init.cpp @@ -669,7 +669,6 @@ AIEntTypeInfo aiEntList[] = { AI::AI() { _ents = new Common::Array; _floats = new Common::Array; - _animTargets = new Common::Array; _arrowPaths = new Common::Array; _triggerList = new Common::Array; _hereList = new Common::Array; @@ -684,7 +683,6 @@ AI::AI() { AI::~AI() { delete _ents; delete _floats; - delete _animTargets; delete _arrowPaths; delete _triggerList; delete _hereList; @@ -854,7 +852,7 @@ void AI::restartSystem() { _numLuaList = 0; // Clear Anim Targets List - _animTargets->clear(); + _animTargets.clear(); // Clear ArrowPath List _arrowPaths->clear(); diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp index bd3fcbf236..95bfe04d94 100644 --- a/engines/hdb/ai-lists.cpp +++ b/engines/hdb/ai-lists.cpp @@ -77,7 +77,7 @@ void AI::addAnimateTarget(int x, int y, int start, int end, AnimSpeed speed, boo } // Insert in the beginning - _animTargets->insert_at(0, at); + _animTargets.insert_at(0, at); } /* @@ -90,15 +90,15 @@ void AI::animateTargets() { int layer; g_hdb->_map->getMapXY(&mx, &my); - debug(9, "animateTargets: Size of _animTargets: %d", _animTargets->size()); + debug(9, "animateTargets: Size of _animTargets: %d", _animTargets.size()); debug(9, "_animTargets:"); - for (Common::Array::iterator it = _animTargets->begin(); it != _animTargets->end(); it++) { - at = *it; - debug(9, "it - _animTargets->begin(): %ld", it - _animTargets->begin()); + for (uint i = 0; i < _animTargets.size(); i++) { + at = _animTargets[i]; + debug(9, "i: %d", i); debug(9, "at: at->x: %d, at->y: %d, at->start: %d, at->end: %d, at->vel: %d", at->x, at->y, at->start, at->end, at->vel); - // Draw Non-Map stuff every frame + // Draw Non-map stuff every frame if (!at->inMap) // FIXME: Out of bounds reference to gfxList at->gfxList[at->start]->drawMasked(at->x - mx, at->y - my); @@ -133,9 +133,8 @@ void AI::animateTargets() { if (at->killAuto) autoDeactivate(at->x, at->y); - AnimTarget **jt = it; - _animTargets->erase(it); - it = jt-1; + _animTargets.remove_at(i); + i--; continue; } } diff --git a/engines/hdb/ai.h b/engines/hdb/ai.h index 654eec95a4..ab0abe6af3 100644 --- a/engines/hdb/ai.h +++ b/engines/hdb/ai.h @@ -1110,7 +1110,7 @@ private: Common::Array *_ents; Common::Array *_floats; - Common::Array *_animTargets; + Common::Array _animTargets; AIEntity *_player; // Cinematics Variables -- cgit v1.2.3