shithub: sce

Download patch

ref: 1c6adc14e8febf8d631984b2ae1de6a3f3e97baa
parent: 94f786ad93b4e5f1f3158062f4a0400c6b1b80df
author: qwx <qwx@sciops.net>
date: Wed Sep 2 04:45:28 EDT 2020

path: fix corner case for pathfinding to the left

we rely on a sign change to detect going further
than the goal, but if we're right on top of the
goal when moving left, this does not happen.
and yes, this code is horrid.

--- a/path.c
+++ b/path.c
@@ -153,7 +153,7 @@
 		*ofs = steps;
 	if(end && Δug2 == 0)
 		return nil;
-	if(Δvg == 0 && (Δug < 0) ^ (Δug2 < 0)){
+	if(Δvg == 0 && (Δug == 0 || (Δug < 0) ^ (Δug2 < 0))){
 		b->Δg = steps - abs(Δug2);
 		b->Δlen = b->Δg;
 		return b;