[Scummvm-cvs-logs] SF.net SVN: scummvm:[45223] scummvm/trunk/engines/sci/engine/kpathing.cpp

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Sun Oct 18 16:35:36 CEST 2009


Revision: 45223
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45223&view=rev
Author:   waltervn
Date:     2009-10-18 14:35:36 +0000 (Sun, 18 Oct 2009)

Log Message:
-----------
SCI: AvoidPath: skip polygons without vertices

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kpathing.cpp

Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-10-18 13:47:42 UTC (rev 45222)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-10-18 14:35:36 UTC (rev 45223)
@@ -1217,11 +1217,17 @@
 	// Converts an SCI polygon into a Polygon
 	// Parameters: (EngineState *) s: The game state
 	//             (reg_t) polygon: The SCI polygon to convert
-	// Returns   : (Polygon *) The converted polygon
+	// Returns   : (Polygon *) The converted polygon, or NULL on error
 	SegManager *segMan = s->_segMan;
 	int i;
 	reg_t points = GET_SEL32(polygon, points);
 	int size = GET_SEL32(polygon, size).toUint16();
+
+	if (size == 0) {
+		// If the polygon has no vertices, we skip it
+		return NULL;
+	}
+
 	Polygon *poly = new Polygon(GET_SEL32(polygon, type).toUint16());
 
 	int skip = 0;
@@ -1379,8 +1385,11 @@
 			if (dup == node) {
 				// Polygon is not a duplicate, so convert it
 				polygon = convert_polygon(s, node->value);
-				pf_s->polygons.push_back(polygon);
-				count += GET_SEL32(node->value, size).toUint16();
+
+				if (polygon) {
+					pf_s->polygons.push_back(polygon);
+					count += GET_SEL32(node->value, size).toUint16();
+				}
 			}
 
 			node = s->_segMan->lookupNode(node->succ);
@@ -1652,6 +1661,10 @@
 	case 3 : {
 		reg_t retval;
 		Polygon *polygon = convert_polygon(s, argv[2]);
+
+		if (!polygon)
+			return NULL_REG;
+
 		// Override polygon type to prevent inverted result for contained access polygons
 		polygon->type = POLY_BARRED_ACCESS;
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list