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

waltervn at users.sourceforge.net waltervn at users.sourceforge.net
Fri Oct 30 04:54:50 CET 2009


Revision: 45521
          http://scummvm.svn.sourceforge.net/scummvm/?rev=45521&view=rev
Author:   waltervn
Date:     2009-10-30 03:54:50 +0000 (Fri, 30 Oct 2009)

Log Message:
-----------
SCI: AvoidPath: Don't discard contained-access polygon when starting point
is right next to it.

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-30 03:27:27 UTC (rev 45520)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-10-30 03:54:50 UTC (rev 45521)
@@ -1050,6 +1050,21 @@
 }
 
 /**
+ * Checks whether a point is nearby a contained-access polygon (distance 1 pixel)
+ * @param point			the point
+ * @param polygon		the contained-access polygon
+ * @return true when point is nearby polygon, false otherwise
+ */
+static bool nearbyPolygon(const Common::Point &point, Polygon *polygon) {
+	assert(polygon->type == POLY_CONTAINED_ACCESS);
+
+	return ((contained(Common::Point(point.x, point.y + 1), polygon) != CONT_INSIDE)
+			|| (contained(Common::Point(point.x, point.y - 1), polygon) != CONT_INSIDE)
+			|| (contained(Common::Point(point.x + 1, point.y), polygon) != CONT_INSIDE)
+			|| (contained(Common::Point(point.x - 1, point.y), polygon) != CONT_INSIDE));
+}
+
+/**
  * Checks that the start point is in a valid position, and takes appropriate action if it's not.
  * @param s				the pathfinding state
  * @param start			the start point
@@ -1075,12 +1090,14 @@
 		case POLY_CONTAINED_ACCESS:
 			// Remove contained access polygons that do not contain
 			// the start point (containment test is inverted here).
-			if (cont == CONT_INSIDE) {
+			// SSCI appears to be using a small margin of error here,
+			// so we do the same.
+			if ((cont == CONT_INSIDE) && !nearbyPolygon(start, *it)) {
 				delete *it;
 				it = s->polygons.erase(it);
 				continue;
 			}
-			break;
+			// Fall through
 		case POLY_BARRED_ACCESS:
 		case POLY_NEAREST_ACCESS:
 			if (cont == CONT_INSIDE) {
@@ -1095,7 +1112,7 @@
 					return NULL;
 				}
 
-				if (type == POLY_BARRED_ACCESS)
+				if ((type == POLY_BARRED_ACCESS) || (type == POLY_CONTAINED_ACCESS))
 					warning("AvoidPath: start position at unreachable location");
 
 				// The original start position is in an invalid location, so we


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