[Scummvm-git-logs] scummvm master -> 1630cf0e6c4c278bc4913ecc0ba7503c5ff8eb06

peterkohaut peterkohaut at users.noreply.github.com
Sat Mar 9 19:20:57 CET 2019


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

Summary:
1630cf0e6c BLADERUNNER: Better fix for bug in pathfinding


Commit: 1630cf0e6c4c278bc4913ecc0ba7503c5ff8eb06
    https://github.com/scummvm/scummvm/commit/1630cf0e6c4c278bc4913ecc0ba7503c5ff8eb06
Author: Peter Kohaut (peter.kohaut at gmail.com)
Date: 2019-03-09T19:20:28+01:00

Commit Message:
BLADERUNNER: Better fix for bug in pathfinding

Basically just more robust (but slower) fix to the intermittent assert
in pathfinding code when polygons were touching only by a single corner.

Changed paths:
    engines/bladerunner/obstacles.cpp


diff --git a/engines/bladerunner/obstacles.cpp b/engines/bladerunner/obstacles.cpp
index a0e9d7a..66f3f73 100644
--- a/engines/bladerunner/obstacles.cpp
+++ b/engines/bladerunner/obstacles.cpp
@@ -191,7 +191,6 @@ bool Obstacles::mergePolygons(Polygon &polyA, Polygon &polyB) {
 	bool flagAddVertexToVertexList = true;
 	bool flagDidFindIntersection = false;
 	int vertIndex = 0;
-	int lastIntersectionIndex = -1;
 
 	Polygon *startingPolygon = polyPrimary;
 	int flagDone = false;
@@ -205,7 +204,12 @@ bool Obstacles::mergePolygons(Polygon &polyA, Polygon &polyB) {
 		polyPrimaryType = polyPrimary->vertexType[vertIndex];
 
 		if (flagAddVertexToVertexList) {
-			assert(polyMerged.verticeCount < kPolygonVertexCount);
+			// In some cases polygons will have only one intersection (touching corners) and because of that second SWAP never occure,
+			// algorithm will stop only when the merged polygon is full.
+			if (polyMerged.verticeCount >= kPolygonVertexCount) {
+				flagDidMergePolygons = false;
+				break;
+			}
 			polyMerged.vertices[polyMerged.verticeCount] = polyLine.start;
 			polyMerged.vertexType[polyMerged.verticeCount] = polyPrimaryType;
 			polyMerged.verticeCount++;
@@ -227,15 +231,8 @@ bool Obstacles::mergePolygons(Polygon &polyA, Polygon &polyB) {
 			SWAP(polyPrimary, polySecondary);
 
 			flagDidMergePolygons = true;
-			lastIntersectionIndex = polySecondaryIntersectionIndex;
 		} else {
 			vertIndex = (vertIndex + 1) % polyPrimary->verticeCount;
-			// In some cases polygons will have only one intersection (touching corners) and because of that second SWAP never occure and algorithm will never stop.
-			// This can be avoided by stopping the algorithm after looping over whole polygon. Such polygons will not merge.
-			if (vertIndex == lastIntersectionIndex) {
-				flagDidMergePolygons = false;
-				break;
-			}
 			flagDidFindIntersection = false;
 		}
 		if (polyPrimary->vertices[vertIndex] == startingPolygon->vertices[0]) {





More information about the Scummvm-git-logs mailing list