diff options
-rw-r--r-- | engines/parallaction/animation.cpp | 12 | ||||
-rw-r--r-- | engines/parallaction/location.cpp | 4 | ||||
-rw-r--r-- | engines/parallaction/parallaction.h | 4 | ||||
-rw-r--r-- | engines/parallaction/walk.cpp | 34 | ||||
-rw-r--r-- | engines/parallaction/zone.h | 13 |
5 files changed, 30 insertions, 37 deletions
diff --git a/engines/parallaction/animation.cpp b/engines/parallaction/animation.cpp index f2c2becfa7..97db78513f 100644 --- a/engines/parallaction/animation.cpp +++ b/engines/parallaction/animation.cpp @@ -141,8 +141,8 @@ Animation *Parallaction::parseAnimation(Script& script, Node *list, char *name) fillBuffers(script, true); } - vD0->_oldLeft = -1000; - vD0->_oldTop = -1000; + vD0->_oldPos.x = -1000; + vD0->_oldPos.y = -1000; vD0->_flags |= 0x1000000; @@ -207,7 +207,7 @@ void jobDisplayAnimations(void *parm, Job *j) { if (((v18->_flags & kFlagsActive) == 0) && (v18->_flags & kFlagsRemove)) { v18->_flags &= ~kFlagsRemove; - v18->_oldLeft = -1000; + v18->_oldPos.x = -1000; } if ((v18->_flags & kFlagsActive) && (v18->_flags & kFlagsRemove)) { @@ -233,12 +233,12 @@ void jobEraseAnimations(void *arg_0, Job *j) { if (((a->_flags & kFlagsActive) == 0) && ((a->_flags & kFlagsRemove) == 0)) continue; Common::Rect r(a->width(), a->height()); - r.moveTo(a->_oldLeft, a->_oldTop); + r.moveTo(a->_oldPos); _vm->_gfx->restoreBackground(r); if (arg_0) { - a->_oldLeft = a->_left; - a->_oldTop = a->_top; + a->_oldPos.x = a->_left; + a->_oldPos.y = a->_top; } } diff --git a/engines/parallaction/location.cpp b/engines/parallaction/location.cpp index f595fc7b20..80af47eecf 100644 --- a/engines/parallaction/location.cpp +++ b/engines/parallaction/location.cpp @@ -385,8 +385,8 @@ void Parallaction::changeLocation(char *location) { _gfx->copyScreen(Gfx::kBitBack, Gfx::kBit2); debugC(1, kDebugLocation, "changeLocation: new location '%s' parsed", _saveData1); - _vm->_char._ani._oldLeft = -1000; - _vm->_char._ani._oldTop = -1000; + _vm->_char._ani._oldPos.x = -1000; + _vm->_char._ani._oldPos.y = -1000; _vm->_char._ani.field_50 = 0; if (_location._startPosition.x != -1000) { diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h index 0a6f7d674e..fcf1d446ed 100644 --- a/engines/parallaction/parallaction.h +++ b/engines/parallaction/parallaction.h @@ -260,8 +260,8 @@ struct Character { _ani._left = 150; _ani._top = 100; _ani._z = 10; - _ani._oldLeft = -1000; - _ani._oldTop = -1000; + _ani._oldPos.x = -1000; + _ani._oldPos.y = -1000; _ani._frame = 0; _ani._flags = kFlagsActive | kFlagsNoName; _ani._type = kZoneYou; diff --git a/engines/parallaction/walk.cpp b/engines/parallaction/walk.cpp index 311a65904e..0042210e85 100644 --- a/engines/parallaction/walk.cpp +++ b/engines/parallaction/walk.cpp @@ -134,25 +134,27 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { WalkNode v58; - int16 _si = v48->_x; // _si, _di: target top left coordinates - int16 _di = v48->_y; + Common::Point stop(v48->_x, v48->_y); addNode(&v58, v48); WalkNode *_closest_node = NULL; int32 v30, v34, v2C, v28; + Common::Point pos(_vm->_char._ani._left, _vm->_char._ani._top); + byte _closest_node_found = 1; bool emptyList = true; + Common::Point v8; + do { v48 = &v58; - Common::Point v20(_vm->_char._ani._left, _vm->_char._ani._top); - Common::Point v8(_si - _vm->_char._ani._left, _di - _vm->_char._ani._top); + Common::Point v20(pos); - v34 = v30 = dotProduct(v8, v8); // square distance from current position and target + v34 = v30 = pos.sqrDist(stop); // square distance from current position and target while (_closest_node_found != 0) { @@ -163,13 +165,10 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { // which can't be farther than the target position // otherwise no _closest_node is selected while (location_node != NULL) { - v8.x = location_node->_x - _si; - v8.y = location_node->_y - _di; - v2C = dotProduct(v8, v8); // square distance from Node to target position - v8.x = location_node->_x - v20.x; - v8.y = location_node->_y - v20.y; - v28 = dotProduct(v8, v8); // square distance from Node to current position + location_node->getPoint(v8); + v2C = v8.sqrDist(stop); + v28 = v8.sqrDist(v20); if (v2C < v34 && v28 < v30) { _closest_node_found = 1; @@ -185,10 +184,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { WalkNode *_newnode = new WalkNode(*_closest_node); _newnode->getPoint(v20); - Common::Point tmp(_si - v20.x, _di - v20.y); - - v34 = v30 = dotProduct(tmp, tmp); - + v34 = v30 = v20.sqrDist(stop); debugC(1, kDebugWalk, "adding walk node (%i, %i) to path", _newnode->_x, _newnode->_y); @@ -204,8 +200,7 @@ WalkNode *buildWalkPath(uint16 x, uint16 y) { debugC(1, kDebugWalk, "can't find a path node: rejecting partial path"); return v44; } else { - _si = ((WalkNode*)(v58._next))->_x; - _di = ((WalkNode*)(v58._next))->_y; + ((WalkNode*)(v58._next))->getPoint(stop); emptyList = false; _closest_node_found = 1; } @@ -373,8 +368,7 @@ void jobWalk(void *parm, Job *j) { Common::Point pos(_vm->_char._ani._left, _vm->_char._ani._top); - _vm->_char._ani._oldLeft = pos.x; - _vm->_char._ani._oldTop = pos.y; + _vm->_char._ani._oldPos = pos; node = getNextPathNode(pos, node); if (node == NULL) { @@ -394,7 +388,7 @@ void jobWalk(void *parm, Job *j) { _vm->_char._ani._left = pos.x; _vm->_char._ani._top = pos.y; - if ((pos.x == _vm->_char._ani._oldLeft) && (pos.y == _vm->_char._ani._oldTop)) { + if (pos == _vm->_char._ani._oldPos) { j->_finished = 1; checkDoor(); freeNodeList(node); diff --git a/engines/parallaction/zone.h b/engines/parallaction/zone.h index 3c6e708c5b..671b0814e5 100644 --- a/engines/parallaction/zone.h +++ b/engines/parallaction/zone.h @@ -219,11 +219,11 @@ struct Zone : public Node { _bottom += y; } - uint16 width() const { + virtual uint16 width() const { return _right - _left; } - uint16 height() const { + virtual uint16 height() const { return _bottom - _top; } }; @@ -294,8 +294,8 @@ struct Program : public Node { struct Animation : public Zone { - int16 _oldLeft; - int16 _oldTop; + + Common::Point _oldPos; Program *_program; Cnv *_cnv; int16 _frame; @@ -309,19 +309,18 @@ struct Animation : public Zone { uint16 field_5E; // unused Animation() { - _oldLeft = _oldTop = 0; _cnv = NULL; _program = NULL; _frame = 0; _z = 0; } - uint16 width() const { + virtual uint16 width() const { if (!_cnv) return 0; return _cnv->_width; } - uint16 height() const { + virtual uint16 height() const { if (!_cnv) return 0; return _cnv->_height; } |