diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 40e90cc2011..40df28504fa 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -59,11 +59,8 @@ WalkFrames _char24WalkFrames_NS = { { 2, 2, 4, 4 } }; - // adjusts position towards nearest walkable point -// void PathWalker_NS::correctPathPoint(Common::Point &to) { - if (IS_PATH_CLEAR(to.x, to.y)) return; int maxX = _vm->_gfx->_backgroundInfo->_path->w; @@ -80,7 +77,6 @@ void PathWalker_NS::correctPathPoint(Common::Point &to) { right = (right == maxX) ? 1000 : right - to.x; left = (left == 0) ? 1000 : to.x - left; - int16 top = to.y; int16 bottom = to.y; do { @@ -92,7 +88,6 @@ void PathWalker_NS::correctPathPoint(Common::Point &to) { top = (top == 0) ? 1000 : to.y - top; bottom = (bottom == maxY) ? 1000 : bottom - to.y; - int16 closeX = (right >= left) ? left : right; int16 closeY = (top >= bottom) ? bottom : top; int16 close = (closeX >= closeY) ? closeY : closeX; @@ -108,13 +103,9 @@ void PathWalker_NS::correctPathPoint(Common::Point &to) { if (close == bottom) { to.y += bottom; } - - return; - } uint32 PathWalker_NS::buildSubPath(const Common::Point& pos, const Common::Point& stop) { - uint32 v28 = 0; uint32 v2C = 0; uint32 v34 = pos.sqrDist(stop); // square distance from current position and target @@ -155,12 +146,9 @@ uint32 PathWalker_NS::buildSubPath(const Common::Point& pos, const Common::Point } return v34; - } -// // x, y: mouse click (foot) coordinates -// void PathWalker_NS::buildPath(AnimationPtr a, uint16 x, uint16 y) { debugC(1, kDebugWalk, "PathBuilder::buildPath to (%i, %i)", x, y); @@ -199,20 +187,14 @@ void PathWalker_NS::buildPath(AnimationPtr a, uint16 x, uint16 y) { buildSubPath(pos, *_walkPath.begin()); _walkPath.insert(_walkPath.begin(), _subPath.begin(), _subPath.end()); - - return; } - -// // x,y : top left coordinates // // 0 : Point not reachable // 1 : Point reachable in a straight line // other values: square distance to target (point not reachable in a straight line) -// uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) { - Common::Point arg(to); Common::Point v4; @@ -229,7 +211,6 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) { if (foot.y < to.y && IS_PATH_CLEAR(foot.x, foot.y + 1)) foot.y++; if (foot.y > to.y && IS_PATH_CLEAR(foot.x, foot.y - 1)) foot.y--; - if (foot == v8 && foot != arg) { // foot couldn't move and still away from target @@ -253,7 +234,6 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) { } v8 = foot; - } // there exists an unobstructed path @@ -261,7 +241,6 @@ uint16 PathWalker_NS::walkFunc1(const Common::Point &to, Common::Point& node) { } void PathWalker_NS::clipMove(Common::Point& pos, const Common::Point& to) { - if ((pos.x < to.x) && (pos.x < _vm->_gfx->_backgroundInfo->_path->w) && IS_PATH_CLEAR(pos.x + 2, pos.y)) { pos.x = (pos.x + 2 < to.x) ? pos.x + 2 : to.x; } @@ -277,13 +256,9 @@ void PathWalker_NS::clipMove(Common::Point& pos, const Common::Point& to) { if ((pos.y > to.y) && (pos.y > 0) && IS_PATH_CLEAR(pos.x, pos.y - 2)) { pos.y = (pos.y - 2 >= to.y) ? pos.y - 2 : to.y; } - - return; } - void PathWalker_NS::checkDoor(const Common::Point &foot) { - ZonePtr z = _vm->hitZone(kZoneDoor, foot.x, foot.y); if (z) { if ((z->_flags & kFlagsClosed) == 0) { @@ -309,10 +284,8 @@ void PathWalker_NS::checkDoor(const Common::Point &foot) { _vm->clearLocationFlags(kFlagsExit); _vm->_zoneTrap.reset(); } - } - void PathWalker_NS::finalizeWalk() { _engineFlags &= ~kEngineWalking; @@ -371,7 +344,6 @@ void PathWalker_NS::walk() { } void PathWalker_NS::updateDirection(const Common::Point& pos, const Common::Point& to) { - Common::Point dist(to.x - pos.x, to.y - pos.y); WalkFrames *frames = (_a->getFrameNum() == 20) ? &_char20WalkFrames_NS : &_char24WalkFrames_NS; @@ -391,11 +363,9 @@ void PathWalker_NS::updateDirection(const Common::Point& pos, const Common::Poin _a->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]); } - PathWalker_NS::PathWalker_NS() : _direction(WALK_DOWN), _step(0) { } - bool PathWalker_BR::directPathExists(const Common::Point &from, const Common::Point &to) { Common::Point copy(from); @@ -445,7 +415,6 @@ void PathWalker_BR::stopFollower() { _follower._active = false; } - void PathWalker_BR::buildPath(State &s, uint16 x, uint16 y) { Common::Point foot; s._a->getFoot(foot); @@ -495,7 +464,6 @@ void PathWalker_BR::buildPath(State &s, uint16 x, uint16 y) { debugC(3, kDebugWalk, "buildPath: complex path (%i nodes)", s._walkPath.size()); } - void PathWalker_BR::finalizeWalk(State &s) { _engineFlags &= ~kEngineWalking; @@ -627,7 +595,6 @@ void PathWalker_BR::doWalk(State &s) { int xStep = (scale * 16) / 100 + 1; int yStep = (scale * 10) / 100 + 1; - /* WORKAROUND: in the balloon scene, the position of the balloon (which is implemented as a Character) is controlled by the user (for movement, via this walking code) and by the scripts (to simulate the balloon floating in the air, in a neverending loop that alters the position @@ -724,12 +691,10 @@ void PathWalker_BR::doWalk(State &s) { s._a->getFoot(p2); checkTrap(p2); debugC(3, kDebugWalk, "PathWalker_BR::doWalk, stepped to (%i, %i)", p2.x, p2.y); - return; + } else { + debugC(3, kDebugWalk, "PathWalker_BR::doWalk, case 2"); + finalizeWalk(s); } - - debugC(3, kDebugWalk, "PathWalker_BR::doWalk, case 2"); - finalizeWalk(s); - return; } PathWalker_BR::PathWalker_BR() { @@ -739,5 +704,4 @@ PathWalker_BR::PathWalker_BR() { _follower._step = 0; } - } // namespace Parallaction diff --git a/engines/parallaction/walk.h b/engines/parallaction/walk.h index d82b112a541..655c4761069 100644 --- a/engines/parallaction/walk.h +++ b/engines/parallaction/walk.h @@ -31,12 +31,10 @@ #include "parallaction/objects.h" - namespace Parallaction { struct Character; - class PathWalker_NS { AnimationPtr _a; PointList _walkPath; @@ -61,7 +59,6 @@ public: void walk(); }; - class PathWalker_BR { struct State {