[Scummvm-cvs-logs] scummvm master -> 109ff80475d036ad426df9fc236de9e8108d4e00

sev- sev at scummvm.org
Thu Oct 17 22:20:00 CEST 2013


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
2f1387bb26 FULLPIPE: Implement MovGraph2::findLink1()
109ff80475 FULLPIPE: Implement MovGraph2::findLink2()


Commit: 2f1387bb26ffdc3bb7dd0066e7023c2818cb77dd
    https://github.com/scummvm/scummvm/commit/2f1387bb26ffdc3bb7dd0066e7023c2818cb77dd
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-10-17T13:19:28-07:00

Commit Message:
FULLPIPE: Implement MovGraph2::findLink1()

Changed paths:
    engines/fullpipe/motion.cpp
    engines/fullpipe/utils.h



diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 0c0db32..da6a82f 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<MovGraphLink *> *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 d976e09..64f56ce 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,


Commit: 109ff80475d036ad426df9fc236de9e8108d4e00
    https://github.com/scummvm/scummvm/commit/109ff80475d036ad426df9fc236de9e8108d4e00
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-10-17T13:19:28-07:00

Commit Message:
FULLPIPE: Implement MovGraph2::findLink2()

Changed paths:
    engines/fullpipe/motion.cpp



diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index da6a82f..b49b297 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -861,9 +861,45 @@ MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
 }
 
 MovGraphLink *MovGraph2::findLink2(int x, int y) {
-	warning("STUB: MovGraphLink *MovGraph2::findLink2()");
+	double mindist = 1.0e20;
+	MovGraphLink *res;
 
-	return 0;
+	for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
+		assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
+
+		MovGraphLink *lnk = (MovGraphLink *)*i;
+
+		if (!(lnk->_flags & 0x20000000)) {
+			double n1x = lnk->_movGraphNode1->_x;
+			double n1y = lnk->_movGraphNode1->_y;
+			double n2x = lnk->_movGraphNode2->_x;
+			double n2y = lnk->_movGraphNode2->_y;
+			double n1dx = n1x - x;
+			double n1dy = n1y - y;
+			double dst1 = sqrt(n1dy * n1dy + n1dx * n1dx);
+			double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_distance / dst1;
+			double dst3 = coeff1 * dst1;
+			double dst2 = sqrt(1.0 - coeff1 * coeff1) * dst1;
+
+			if (coeff1 * dst1 < 0.0) {
+				dst3 = 0.0;
+				dst2 = sqrt(n1dy * n1dy + n1dx * n1dx);
+			}
+			if (dst3 > lnk->_distance) {
+				dst3 = lnk->_distance;
+				dst2 = sqrt((n2x - x) * (n2x - x) + (n2y - y) * (n2y - y));
+			}
+			if (dst3 >= 0.0 && dst3 <= lnk->_distance && dst2 < mindist) {
+				mindist = dst2;
+				res = lnk;
+			}
+		}
+	}
+
+	if (mindist < 1.0e20)
+		return res;
+	else
+		return 0;
 }
 
 double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj) {






More information about the Scummvm-git-logs mailing list