diff options
author | Nicola Mettifogo | 2008-07-26 05:56:39 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2008-07-26 05:56:39 +0000 |
commit | 8245aa42b5892b92aafe0f0c9c891cabfd7f91ef (patch) | |
tree | 3b9589addc160e1a45a6930b77f67ae73244870c | |
parent | 34ff51d1c6331e3654877da17cd689351edd86f1 (diff) | |
download | scummvm-rg350-8245aa42b5892b92aafe0f0c9c891cabfd7f91ef.tar.gz scummvm-rg350-8245aa42b5892b92aafe0f0c9c891cabfd7f91ef.tar.bz2 scummvm-rg350-8245aa42b5892b92aafe0f0c9c891cabfd7f91ef.zip |
More cleanup.
svn-id: r33298
-rw-r--r-- | engines/parallaction/parallaction.cpp | 9 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 2 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 75 | ||||
-rw-r--r-- | engines/parallaction/walk.h | 6 |
4 files changed, 40 insertions, 52 deletions
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp index 78e7af6343..0c053f35f2 100644 --- a/engines/parallaction/parallaction.cpp +++ b/engines/parallaction/parallaction.cpp @@ -548,8 +548,8 @@ void Character::setFoot(const Common::Point &foot) { } #if 0 -void dumpPath(PointList *list, const char* text) { - for (PointList::iterator it = list->begin(); it != list->end(); it++) +void dumpPath(const PointList &list, const char* text) { + for (PointList::iterator it = list.begin(); it != list.end(); it++) printf("node (%i, %i)\n", it->x, it->y); return; @@ -561,7 +561,7 @@ void Character::scheduleWalk(int16 x, int16 y) { return; } - _walkPath = _builder->buildPath(x, y); + _builder->buildPath(x, y); #if 0 dumpPath(_walkPath, _name); #endif @@ -570,8 +570,7 @@ void Character::scheduleWalk(int16 x, int16 y) { _engineFlags |= kEngineWalking; } else { // BRA can't walk yet! - delete _walkPath; - _walkPath = 0; + _walkPath.clear(); } } diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 03bff44981..d7786e0633 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -199,7 +199,7 @@ struct Character { GfxObj *_talk; GfxObj *_objs; PathBuilder *_builder; - PointList *_walkPath; + PointList _walkPath; Character(Parallaction *vm); ~Character(); diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 2adbfb3bac..bede804f45 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -148,9 +148,11 @@ uint32 PathBuilder_NS::buildSubPath(const Common::Point& pos, const Common::Poin // // x, y: mouse click (foot) coordinates // -PointList *PathBuilder_NS::buildPath(uint16 x, uint16 y) { +void PathBuilder_NS::buildPath(uint16 x, uint16 y) { debugC(1, kDebugWalk, "PathBuilder::buildPath to (%i, %i)", x, y); + _ch->_walkPath.clear(); + Common::Point to(x, y); correctPathPoint(to); debugC(1, kDebugWalk, "found closest path point at (%i, %i)", to.x, to.y); @@ -162,43 +164,32 @@ PointList *PathBuilder_NS::buildPath(uint16 x, uint16 y) { if (v38 == 1) { // destination directly reachable debugC(1, kDebugWalk, "direct move to (%i, %i)", to.x, to.y); - - _list = new PointList; - _list->push_back(v48); - return _list; + _ch->_walkPath.push_back(v48); + return; } // path is obstructed: look for alternative - _list = new PointList; - _list->push_back(v48); + _ch->_walkPath.push_back(v48); #if 0 printNodes(_list, "start"); #endif - Common::Point stop(v48.x, v48.y); Common::Point pos; _ch->getFoot(pos); - uint32 v34 = buildSubPath(pos, stop); + uint32 v34 = buildSubPath(pos, v48); if (v38 != 0 && v34 > v38) { // no alternative path (gap?) - _list->clear(); - _list->push_back(v44); - return _list; + _ch->_walkPath.clear(); + _ch->_walkPath.push_back(v44); + return; } - _list->insert(_list->begin(), _subPath.begin(), _subPath.end()); -#if 0 - printNodes(_list, "first segment"); -#endif + _ch->_walkPath.insert(_ch->_walkPath.begin(), _subPath.begin(), _subPath.end()); - stop = *_list->begin(); - buildSubPath(pos, stop); - _list->insert(_list->begin(), _subPath.begin(), _subPath.end()); -#if 0 - printNodes(_list, "complete"); -#endif + buildSubPath(pos, *_ch->_walkPath.begin()); + _ch->_walkPath.insert(_ch->_walkPath.begin(), _subPath.begin(), _subPath.end()); - return _list; + return; } @@ -318,8 +309,7 @@ void Parallaction::finalizeWalk(Character &character) { character.getFoot(foot); checkDoor(foot); - delete character._walkPath; - character._walkPath = 0; + character._walkPath.clear(); } void Parallaction_ns::walk(Character &character) { @@ -331,17 +321,17 @@ void Parallaction_ns::walk(Character &character) { character.getFoot(curPos); // update target, if previous was reached - PointList::iterator it = character._walkPath->begin(); - if (it != character._walkPath->end()) { + PointList::iterator it = character._walkPath.begin(); + if (it != character._walkPath.end()) { if (*it == curPos) { debugC(1, kDebugWalk, "walk reached node (%i, %i)", (*it).x, (*it).y); - it = character._walkPath->erase(it); + it = character._walkPath.erase(it); } } // advance character towards the target Common::Point targetPos; - if (it == character._walkPath->end()) { + if (it == character._walkPath.end()) { debugC(1, kDebugWalk, "walk reached last node"); finalizeWalk(character); targetPos = curPos; @@ -397,54 +387,53 @@ bool PathBuilder_BR::directPathExists(const Common::Point &from, const Common::P return true; } -PointList* PathBuilder_BR::buildPath(uint16 x, uint16 y) { +void PathBuilder_BR::buildPath(uint16 x, uint16 y) { Common::Point foot; _ch->getFoot(foot); debugC(1, kDebugWalk, "buildPath: from (%i, %i) to (%i, %i)", foot.x, foot.y, x, y); - - PointList *list = new PointList; + _ch->_walkPath.clear(); // look for easy path first Common::Point dest(x, y); if (directPathExists(foot, dest)) { - list->push_back(dest); + _ch->_walkPath.push_back(dest); debugC(3, kDebugWalk, "buildPath: direct path found"); - return list; + return; } // look for short circuit cases ZonePtr z0 = _vm->hitZone(kZonePath, x, y); if (z0 == nullZonePtr) { - list->push_back(dest); + _ch->_walkPath.push_back(dest); debugC(3, kDebugWalk, "buildPath: corner case 0"); - return list; + return; } ZonePtr z1 = _vm->hitZone(kZonePath, foot.x, foot.y); if (z1 == nullZonePtr || z1 == z0) { - list->push_back(dest); + _ch->_walkPath.push_back(dest); debugC(3, kDebugWalk, "buildPath: corner case 1"); - return list; + return; } // build complex path int id = atoi(z0->_name); if (z1->u.path->_lists[id].empty()) { - list->clear(); + _ch->_walkPath.clear(); debugC(3, kDebugWalk, "buildPath: no path"); - return list; + return; } PointList::iterator b = z1->u.path->_lists[id].begin(); PointList::iterator e = z1->u.path->_lists[id].end(); for ( ; b != e; b++) { - list->push_front(*b); + _ch->_walkPath.push_front(*b); } - list->push_back(dest); + _ch->_walkPath.push_back(dest); debugC(3, kDebugWalk, "buildPath: complex path"); - return list; + return; } PathBuilder_BR::PathBuilder_BR(Character *ch) : PathBuilder(ch) { diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h index 680fd3f93f..e6ad8e5c16 100644 --- a/engines/parallaction/walk.h +++ b/engines/parallaction/walk.h @@ -45,7 +45,7 @@ public: PathBuilder(Character *ch) : _ch(ch) { } virtual ~PathBuilder() { } - virtual PointList* buildPath(uint16 x, uint16 y) = 0; + virtual void buildPath(uint16 x, uint16 y) = 0; }; @@ -60,7 +60,7 @@ class PathBuilder_NS : public PathBuilder { public: PathBuilder_NS(Character *ch); - PointList* buildPath(uint16 x, uint16 y); + void buildPath(uint16 x, uint16 y); }; @@ -70,7 +70,7 @@ class PathBuilder_BR : public PathBuilder { public: PathBuilder_BR(Character *ch); - PointList* buildPath(uint16 x, uint16 y); + void buildPath(uint16 x, uint16 y); }; |