From 295204374849b810afa33ec6ff18a0debdd97ef5 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 25 Apr 2020 11:46:18 +0100 Subject: [PATCH] Fix insufficient YAPF cost added when reversing behind signal Distance to target cost compensation was too small in case where target was perfectly in line with reversing track due to exit direction offset added in PfCalcEstimate. See: #147 --- src/pathfinder/yapf/yapf_costrail.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp index 8a78208d5d..5098ca24e5 100644 --- a/src/pathfinder/yapf/yapf_costrail.hpp +++ b/src/pathfinder/yapf/yapf_costrail.hpp @@ -482,8 +482,8 @@ public: int y1 = 2 * TileY(prev.tile); int x2 = 2 * TileX(cur.tile); int y2 = 2 * TileY(cur.tile); - int dx = abs(x1 - x2); - int dy = abs(y1 - y2); + int dx = abs(x1 - x2) + 1; + int dy = abs(y1 - y2) + 1; int dmin = min(dx, dy); int dxy = abs(dx - dy); segment_entry_cost += dmin * YAPF_TILE_CORNER_LENGTH + (dxy - 1) * (YAPF_TILE_LENGTH / 2);