From 2f1387bb26ffdc3bb7dd0066e7023c2818cb77dd Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 17 Oct 2013 22:44:30 +0300 Subject: FULLPIPE: Implement MovGraph2::findLink1() --- engines/fullpipe/motion.cpp | 35 +++++++++++++++++++++++++++++++++-- engines/fullpipe/utils.h | 1 + 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 0c0db322f8..da6a82ffeb 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -685,6 +685,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int if (!linkInfoDest.node) { linkInfoDest.link = findLink1(xpos, ypos, idxsub, fuzzyMatch); + if (!linkInfoDest.link) { obj->setPicAniInfo(&picAniInfo); @@ -826,9 +827,37 @@ int MovGraph2::findLink(Common::Array *linkList, MovGraphLink *l } MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) { - warning("STUB: MovGraphLink *MovGraph2::findLink1()"); + Common::Point point; + MovGraphLink *res = 0; - return 0; + for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) { + assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink); + + MovGraphLink *lnk = (MovGraphLink *)*i; + + if (fuzzyMatch) { + point.x = x; + point.y = y; + double dst = calcDistance(&point, lnk, 0); + + if (dst >= 0.0 && dst < 2.0) + return lnk; + } else if (!(lnk->_flags & 0x20000000)) { + if (lnk->_movGraphReact->pointInRegion(x, y)) { + if (abs(lnk->_movGraphNode1->_x - lnk->_movGraphNode2->_x) <= abs(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y)) { + if (idx == 2 || idx == 3) + return lnk; + res = lnk; + } else { + if (idx == 1 || !idx) + return lnk; + res = lnk; + } + } + } + } + + return res; } MovGraphLink *MovGraph2::findLink2(int x, int y) { @@ -919,6 +948,8 @@ MovGraphLink::MovGraphLink() { _field_38 = 0; _movGraphReact = 0; _name = 0; + + _objtype = kObjTypeMovGraphLink; } bool MovGraphLink::load(MfcArchive &file) { diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index d976e09d60..64f56ced0a 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -67,6 +67,7 @@ class MfcArchive : public Common::SeekableReadStream { enum ObjType { kObjTypeDefault, kObjTypeMovGraph, + kObjTypeMovGraphLink, kObjTypeMovGraphNode, kObjTypeMctlCompound, kObjTypeObjstateCommand, -- cgit v1.2.3