diff options
author | Eugene Sandulenko | 2013-10-19 17:30:57 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-10-19 21:22:15 +0300 |
commit | a5c7cdcc0c4c2438a08f606668e5fa14637d47b5 (patch) | |
tree | 6a467b3c5864cc0d52495d2fe3eef427a47da8df | |
parent | 33c849698f2a7fd093062d4e72357ddb76b31de0 (diff) | |
download | scummvm-rg350-a5c7cdcc0c4c2438a08f606668e5fa14637d47b5.tar.gz scummvm-rg350-a5c7cdcc0c4c2438a08f606668e5fa14637d47b5.tar.bz2 scummvm-rg350-a5c7cdcc0c4c2438a08f606668e5fa14637d47b5.zip |
FULLPIPE: Implement MovGraph2::findLink()
-rw-r--r-- | engines/fullpipe/motion.cpp | 73 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 2 |
2 files changed, 55 insertions, 20 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index ef5a62b6f8..6d0f1a2530 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -554,9 +554,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL int prevSubIndex = movinfo->subIndex; - for (Common::Array<MovGraphLink *>::iterator i = linkList->begin(); i != linkList->end(); ++i) { - MovGraphLink *lnk = *i; - + for (uint i = 0; i < linkList->size(); i++) { int idx1; if (linkList->size() <= 1) { @@ -571,7 +569,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL rect.top = -1; rect.left = -1; } else { - idx1 = findLink(linkList, lnk, &rect, &point); + idx1 = findLink(linkList, i, &rect, &point); } if (idx1 != prevSubIndex) { @@ -587,23 +585,19 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->items.push_back(elem); } - if (i != linkList->end()) { + if (i != linkList->size()) { while (1) { - Common::Array<MovGraphLink *>::iterator j = i; - - ++i; - - if (findLink(linkList, *i, &rect, 0) != prevSubIndex) { - i = j; - findLink(linkList, *i, &rect, &point); + i++; + if (findLink(linkList, i, &rect, 0) != prevSubIndex) { + i--; + findLink(linkList, i, &rect, &point); break; } - if (i == linkList->end()) + if (i == linkList->size()) break; } - lnk = *i; } if (movinfo->items.back()->subIndex != 10) { @@ -617,7 +611,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->items.push_back(elem); - if (i == linkList->end()) { + if (i == linkList->size()) { elem = new MovInfo1Sub; elem->subIndex = prevSubIndex; elem->x = movinfo->pt2.x; @@ -861,7 +855,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int else movInfo1.item1Index = getShortSide(0, dx2 - dx1, dy2 - dy1); } else { - movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.back(), 0, 0); + movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.size() - 1, 0, 0); } movInfo1.flags = fuzzyMatch != 0; @@ -935,10 +929,51 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) { return 0; } -int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *rect, Common::Point *point) { - warning("STUB: MovGraphLink *MovGraph2::findLink()"); +int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) { + MovGraphNode *node1 = (*linkList)[idx]->_movGraphNode1; + MovGraphNode *node2 = (*linkList)[idx]->_movGraphNode2; + MovGraphNode *node3 = node1; - return 0; + if (idx != 0) { + MovGraphLink *lnk = (*linkList)[idx - 1]; + + if (lnk->_movGraphNode2 != node1) { + if (lnk->_movGraphNode1 != node1) { + if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) { + node3 = node2; + node2 = node1; + } + goto LABEL_7; + } + } + node3 = node1; + } else if (idx != linkList->size() - 1) { + MovGraphLink *lnk = (*linkList)[idx + 1]; + + if (lnk->_movGraphNode1 == node1 || lnk->_movGraphNode1 == node1) { + node3 = node2; + node2 = node1; + } else if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) { + node3 = node1; + } + } + + LABEL_7: + if (rect) { + rect->left = node3->_x; + rect->top = node3->_y; + rect->right = node2->_x; + rect->bottom = node2->_y; + } + if (point) { + point->x = node3->_distance; + point->y = node2->_distance; + } + + if (abs(node3->_x - node2->_x) <= abs(node3->_y - node2->_y)) + return (node3->_y < node2->_x) + 2; + else + return node3->_x >= node2->_x; } MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) { diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index d53bcf1bbf..85ad084f60 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -323,7 +323,7 @@ public: int getItemSubIndexByMGM(int idx, StaticANIObject *ani); int getShortSide(MovGraphLink *lnk, int x, int y); - int findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *a3, Common::Point *a4); + int findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *a3, Common::Point *a4); bool initDirections(StaticANIObject *obj, MovGraph2Item *item); void buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst); |