[Scummvm-cvs-logs] scummvm master -> a5c7cdcc0c4c2438a08f606668e5fa14637d47b5

sev- sev at scummvm.org
Sat Oct 19 20:22:43 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:
33c849698f FULLPIPE: Implement MovGraph2::buildMovInfo1SubItems()
a5c7cdcc0c FULLPIPE: Implement MovGraph2::findLink()


Commit: 33c849698f2a7fd093062d4e72357ddb76b31de0
    https://github.com/scummvm/scummvm/commit/33c849698f2a7fd093062d4e72357ddb76b31de0
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-10-19T11:22:15-07:00

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

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



diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index f915839..ef5a62b 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -536,7 +536,118 @@ void MovGraph2::addObject(StaticANIObject *obj) {
 }
 
 void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) {
-	warning("STUB: MovGraph2::buildMovInfo1SubItems()");
+	MovInfo1Sub *elem;
+	Common::Point point;
+	Common::Rect rect;
+
+	int subIndex = movinfo->subIndex;
+
+	movinfo->items.clear();
+
+	elem = new MovInfo1Sub;
+	elem->subIndex = subIndex;
+	elem->x = movinfo->pt1.x;
+	elem->y = movinfo->pt1.y;
+	elem->distance = -1;
+
+	movinfo->items.push_back(elem);
+
+	int prevSubIndex = movinfo->subIndex;
+
+	for (Common::Array<MovGraphLink *>::iterator i = linkList->begin(); i != linkList->end(); ++i) {
+		MovGraphLink *lnk = *i;
+
+		int idx1;
+
+		if (linkList->size() <= 1) {
+			if (linkList->size() == 1)
+				idx1 = getShortSide((*linkList)[0], movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y);
+			else
+				idx1 = getShortSide(0, movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y);
+
+			point.y = -1;
+			rect.bottom = -1;
+			rect.right = -1;
+			rect.top = -1;
+			rect.left = -1;
+		} else {
+			idx1 = findLink(linkList, lnk, &rect, &point);
+		}
+
+		if (idx1 != prevSubIndex) {
+			prevSubIndex = idx1;
+			subIndex = idx1;
+
+			elem = new MovInfo1Sub;
+			elem->subIndex = subIndex;
+			elem->x = rect.left;
+			elem->y = rect.top;
+			elem->distance = -1;
+
+			movinfo->items.push_back(elem);
+		}
+
+		if (i != linkList->end()) {
+			while (1) {
+				Common::Array<MovGraphLink *>::iterator j = i;
+
+				++i;
+
+				if (findLink(linkList, *i, &rect, 0) != prevSubIndex) {
+					i = j;
+					findLink(linkList, *i, &rect, &point);
+
+					break;
+				}
+
+				if (i == linkList->end())
+					break;
+			}
+			lnk = *i;
+		}
+
+		if (movinfo->items.back()->subIndex != 10) {
+			subIndex = prevSubIndex;
+
+			elem = new MovInfo1Sub;
+			elem->subIndex = 10;
+			elem->x = -1;
+			elem->y = -1;
+			elem->distance = -1;
+
+			movinfo->items.push_back(elem);
+
+			if (i == linkList->end()) {
+				elem = new MovInfo1Sub;
+				elem->subIndex = prevSubIndex;
+				elem->x = movinfo->pt2.x;
+				elem->y = movinfo->pt2.y;
+				elem->distance = movinfo->distance2;
+
+				movinfo->items.push_back(elem);
+			} else {
+				elem = new MovInfo1Sub;
+				elem->subIndex = prevSubIndex;
+				elem->x = rect.right;
+				elem->y = rect.bottom;
+				elem->distance = point.y;
+
+				movinfo->items.push_back(elem);
+			}
+		}
+	}
+
+	if (subIndex != movinfo->item1Index) {
+		elem = new MovInfo1Sub;
+		elem->subIndex = movinfo->item1Index;
+		elem->x = movinfo->pt2.x;
+		elem->y = movinfo->pt2.y;
+		elem->distance = movinfo->distance2;
+
+		movinfo->items.push_back(elem);
+	}
+
+	movinfo->itemsCount = movinfo->items.size();
 }
 
 MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) {
@@ -824,7 +935,7 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
 	return 0;
 }
 
-int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *a3, Common::Point *a4) {
+int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, MovGraphLink *lnk, Common::Rect *rect, Common::Point *point) {
 	warning("STUB: MovGraphLink *MovGraph2::findLink()");
 
 	return 0;
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index 6901a72..d53bcf1 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -280,6 +280,13 @@ struct LinkInfo {
 	MovGraphNode *node;
 };
 
+struct MovInfo1Sub {
+	int subIndex;
+	int x;
+	int y;
+	int distance;
+};
+
 struct MovInfo1 {
 	int field_0;
 	Common::Point pt1;
@@ -288,7 +295,7 @@ struct MovInfo1 {
 	int distance2;
 	int subIndex;
 	int item1Index;
-	int items;
+	Common::Array<MovInfo1Sub *> items;
 	int itemsCount;
 	int flags;
 };


Commit: a5c7cdcc0c4c2438a08f606668e5fa14637d47b5
    https://github.com/scummvm/scummvm/commit/a5c7cdcc0c4c2438a08f606668e5fa14637d47b5
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2013-10-19T11:22:15-07:00

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

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



diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index ef5a62b..6d0f1a2 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 d53bcf1..85ad084 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);






More information about the Scummvm-git-logs mailing list