(svn r3785) Replace some if-magic to determine the turning direction for road vehicles with the new DirDiff stuff
authortron
Wed, 08 Mar 2006 07:50:26 +0000
changeset 3159 b4a664574e8f
parent 3158 696a6ca0bfa9
child 3160 14b27357d353
(svn r3785) Replace some if-magic to determine the turning direction for road vehicles with the new DirDiff stuff
roadveh_cmd.c
--- a/roadveh_cmd.c	Wed Mar 08 07:48:56 2006 +0000
+++ b/roadveh_cmd.c	Wed Mar 08 07:50:26 2006 +0000
@@ -852,15 +852,11 @@
 {
 	Direction b = RoadVehGetNewDirection(v, x, y);
 	Direction d = v->direction;
+	DirDiff delta;
 
 	if (b == d) return d;
-	d = (d + 1) & 7;
-	if (b == d) return d;
-	d = (d - 2) & 7;
-	if (b == d) return d;
-	if (b == ((d - 1) & 7)) return d;
-	if (b == ((d - 2) & 7)) return d;
-	return (d + 2) & 7;
+	delta = (DirDifference(d, b) > DIRDIFF_REVERSE ? DIRDIFF_45LEFT : DIRDIFF_45RIGHT);
+	return ChangeDir(d, delta);
 }
 
 typedef struct OvertakeData {