shithub: sce

Download patch

ref: ec7b4ca06c32197ecbd7bb61d69271a0ee926024
parent: 577f61eb155225c434adc2e663596d4b95a234b4
author: qwx <qwx@sciops.net>
date: Fri Apr 23 14:19:22 EDT 2021

path: fix path length for air units

--- a/path.c
+++ b/path.c
@@ -121,6 +121,16 @@
 }
 
 static double
+eucdist(Node *a, Node *b)
+{
+	double dx, dy;
+
+	dx = a->x - b->x;
+	dy = a->y - b->y;
+	return sqrt(dx * dx + dy * dy);
+}
+
+static double
 octdist(Node *a, Node *b)
 {
 	int dx, dy;
@@ -406,10 +416,10 @@
 }
 
 static void
-directpath(Node *g, Mobj *mo)
+directpath(Node *a, Node *g, Mobj *mo)
 {
 	resizepathbuf(mo, 1);
-	mo->pathlen = 1;
+	mo->pathlen = eucdist(a, g);
 	mo->pathe = mo->paths + 1;
 	mo->paths->x = g->x * Nodewidth;
 	mo->paths->y = g->y * Nodewidth;
@@ -548,7 +558,7 @@
 	b->x = p.x;
 	b->y = p.y;
 	if(mo->o->f & Fair){
-		directpath(b, mo);
+		directpath(a, b, mo);
 		return 0;
 	}
 	markmobj(mo, 0);