[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.247,2.248 script_v7he.cpp,2.78,2.79

Eugene Sandulenko sev at users.sourceforge.net
Mon Sep 13 18:01:03 CEST 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5273

Modified Files:
	intern.h script_v7he.cpp 
Log Message:
Fix bug in polygonContains(). Still doesn't work.
Preparations for implementing findObject() HE changes.


Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.247
retrieving revision 2.248
diff -u -d -r2.247 -r2.248
--- intern.h	13 Sep 2004 23:24:36 -0000	2.247
+++ intern.h	14 Sep 2004 00:59:59 -0000	2.248
@@ -624,6 +624,8 @@
 					  int vert3x, int vert3y, int vert4x, int vert4y);
 	void polygonErase(int fromId, int toId);
 	bool polygonContains(WizPolygon &pol, int x, int y);
+	bool polygonDefined(int id);
+	int polygonHit(int id, int x, int y);
 
 
 	/* HE version 70 script opcodes */

Index: script_v7he.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v7he.cpp,v
retrieving revision 2.78
retrieving revision 2.79
diff -u -d -r2.78 -r2.79
--- script_v7he.cpp	13 Sep 2004 23:24:36 -0000	2.78
+++ script_v7he.cpp	14 Sep 2004 00:59:59 -0000	2.79
@@ -1070,8 +1070,8 @@
 	for (int j = 0; j < 4; j++) {
 		_WizPolygons[i].bound.left = MIN(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].x);
 		_WizPolygons[i].bound.top = MIN(_WizPolygons[i].bound.top, _WizPolygons[i].vert[j].y);
-		_WizPolygons[i].bound.right = MAX(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].x);
-		_WizPolygons[i].bound.bottom = MAX(_WizPolygons[i].bound.left, _WizPolygons[i].vert[j].y);
+		_WizPolygons[i].bound.right = MAX(_WizPolygons[i].bound.right, _WizPolygons[i].vert[j].x);
+		_WizPolygons[i].bound.bottom = MAX(_WizPolygons[i].bound.bottom, _WizPolygons[i].vert[j].y);
 	}
 }
 
@@ -1090,16 +1090,27 @@
 
 	debug(1, "o7_polygonHit(%d, %d)", x, y);
 
+	push(polygonHit(0, x, y));
+}
+
+int ScummEngine_v7he::polygonHit(int id, int x, int y) {
 	for (int i = 0; i < _WizNumPolygons; i++) {
-		if (_WizPolygons[i].bound.contains(x, y)) {
+		if ((!id || id == i) && _WizPolygons[i].bound.contains(x, y)) {
 			if (polygonContains(_WizPolygons[i], x, y)) {
-				push(_WizPolygons[i].id);
-				return;
+				return _WizPolygons[i].id;
 			}
 		}
 	}
 
-	push(0);
+	return 0;
+}
+
+bool ScummEngine_v7he::polygonDefined(int id) {
+	for (int i = 0; i < _WizNumPolygons; i++)
+		if (_WizPolygons[i].id == id)
+			return true;
+
+	return false;
 }
 
 bool ScummEngine_v7he::polygonContains(WizPolygon &pol, int x, int y) {
@@ -1108,7 +1119,7 @@
 	bool curdir;
 	bool r = false;
 
-	for (int i = 0; i < pol.numVerts; i++) {
+	for (int i = 0; i < pol.numVerts - 1; i++) {
 		curdir = (y <= pol.vert[i].y);
 
 		if (curdir != diry) {
@@ -1120,6 +1131,9 @@
 		pi = i;
 		diry = curdir;
 	}
+
+	//r = true;
+
 	return r;
 }
 





More information about the Scummvm-git-logs mailing list