summaryrefslogtreecommitdiff
path: root/src/pathfinder
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-02-21 00:07:29 +0000
committerCharles Pigott <charlespigott@googlemail.com>2021-02-21 10:53:25 +0000
commit1d6a0c7b5287984d55f8827acab7e895ab12e7ee (patch)
treed416289e6112ef4f1a9fdd69e24c97ff51eee918 /src/pathfinder
parentc461999b2b543238d0be2f88ea3d88544c2114ab (diff)
downloadopenttd-1d6a0c7b5287984d55f8827acab7e895ab12e7ee.tar.xz
Fix: [YAPF] Road pathfinder did not account for length of tunnel/bridge in path cost
Copy calculations from the rail pathfinder
Diffstat (limited to 'src/pathfinder')
-rw-r--r--src/pathfinder/yapf/yapf_road.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pathfinder/yapf/yapf_road.cpp b/src/pathfinder/yapf/yapf_road.cpp
index 9d42f622d..98cd889c9 100644
--- a/src/pathfinder/yapf/yapf_road.cpp
+++ b/src/pathfinder/yapf/yapf_road.cpp
@@ -161,8 +161,8 @@ public:
int min_speed = 0;
int max_veh_speed = v->GetDisplayMaxSpeed();
int max_speed = F.GetSpeedLimit(&min_speed);
- if (max_speed < max_veh_speed) segment_cost += 1 * (max_veh_speed - max_speed);
- if (min_speed > max_veh_speed) segment_cost += 10 * (min_speed - max_veh_speed);
+ if (max_speed < max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (max_veh_speed - max_speed) * (4 + F.m_tiles_skipped) / max_veh_speed;
+ if (min_speed > max_veh_speed) segment_cost += YAPF_TILE_LENGTH * (min_speed - max_veh_speed);
/* move to the next tile */
tile = F.m_new_tile;