summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorglx22 <glx22@users.noreply.github.com>2021-01-14 18:41:38 +0100
committerGitHub <noreply@github.com>2021-01-14 18:41:38 +0100
commit86818e5ae8a170951d00eb0060767c9d1687540c (patch)
treeeab0d40c49e5545535a474b999b8ff49d621ca14 /src/roadveh_cmd.cpp
parentbc8f347ef2386d77e105b336cec9c0242261f9fa (diff)
downloadopenttd-86818e5ae8a170951d00eb0060767c9d1687540c.tar.xz
Fix #7670: prevent useless pathfinder run for blocked vehicles
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 17c9c39e9..f0c2c8aa4 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1389,7 +1389,16 @@ again:
int y = TileY(v->tile) * TILE_SIZE + rdp[turn_around_start_frame].y;
Direction new_dir = RoadVehGetSlidingDirection(v, x, y);
- if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) return false;
+ if (v->IsFrontEngine() && RoadVehFindCloseTo(v, x, y, new_dir) != nullptr) {
+ /* We are blocked. */
+ v->cur_speed = 0;
+ if (!v->path.empty()) {
+ /* Prevent pathfinding rerun as we already know where we are heading to. */
+ v->path.tile.push_front(v->tile);
+ v->path.td.push_front(dir);
+ }
+ return false;
+ }
uint32 r = VehicleEnterTile(v, v->tile, x, y);
if (HasBit(r, VETS_CANNOT_ENTER)) {