From be6317b4ff865ae245140de9e3ba5176a56921bc Mon Sep 17 00:00:00 2001 From: Steve Goldman Date: Tue, 25 Jun 2024 15:42:55 -0500 Subject: [PATCH] Change: Autoscrolling while following a vehicle stops following --- src/window.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/window.cpp b/src/window.cpp index 4ec2d2c968..9f215d4593 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2683,15 +2683,20 @@ static void HandleAutoscroll() y -= vp->top; /* here allows scrolling in both x and y axis */ + /* If we succeed at scrolling in any direction, stop following a vehicle. */ static const int SCROLLSPEED = 3; if (x - 15 < 0) { + w->viewport->follow_vehicle = INVALID_VEHICLE; w->viewport->dest_scrollpos_x += ScaleByZoom((x - 15) * SCROLLSPEED, vp->zoom); } else if (15 - (vp->width - x) > 0) { + w->viewport->follow_vehicle = INVALID_VEHICLE; w->viewport->dest_scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * SCROLLSPEED, vp->zoom); } if (y - 15 < 0) { + w->viewport->follow_vehicle = INVALID_VEHICLE; w->viewport->dest_scrollpos_y += ScaleByZoom((y - 15) * SCROLLSPEED, vp->zoom); } else if (15 - (vp->height - y) > 0) { + w->viewport->follow_vehicle = INVALID_VEHICLE; w->viewport->dest_scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * SCROLLSPEED, vp->zoom); } }