From 21ecdd1a0f1f7676ded020eea3cc9645356f3913 Mon Sep 17 00:00:00 2001 From: "S. Kozyr" Date: Tue, 1 Oct 2024 22:58:41 +0300 Subject: [PATCH 1/2] Fix index pointing out of array bound. Signed-off-by: S. Kozyr --- routing/ruler_router.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routing/ruler_router.cpp b/routing/ruler_router.cpp index 9cabe7dabd..ebab0f190d 100644 --- a/routing/ruler_router.cpp +++ b/routing/ruler_router.cpp @@ -100,8 +100,8 @@ RouterResultCode RulerRouter::CalculateRoute(Checkpoints const & checkpoints, else { // Duplicate last subroute attrs. - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i+1]), i*2-2, i*2); - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i+1]), i*2-2, i*2); + subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); + subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); } } -- 2.45.3 From 7dfe0d65683f094c75c312ed66867b278cc487d8 Mon Sep 17 00:00:00 2001 From: "S. Kozyr" Date: Wed, 2 Oct 2024 11:17:45 +0300 Subject: [PATCH 2/2] Simplified ruler router Signed-off-by: S. Kozyr --- routing/ruler_router.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/routing/ruler_router.cpp b/routing/ruler_router.cpp index ebab0f190d..73738e5251 100644 --- a/routing/ruler_router.cpp +++ b/routing/ruler_router.cpp @@ -36,7 +36,7 @@ void RulerRouter::SetGuides(GuidesTracks && guides) { /*m_guides = GuidesConnect | 1 | 2 | 2 | 4 | | 2 | 2 | 3 | 4 | | 2 | F | 4 | 6 | - | 2 | F | 4 | 6 | + | F | F | 5 | 6 | +-------+--------+-----------------+---------------+ Constraints: @@ -91,18 +91,8 @@ RouterResultCode RulerRouter::CalculateRoute(Checkpoints const & checkpoints, vector subroutes; for(size_t i = 1; i < count; ++i) { - if (i < count-1) - { - // Note: endSegmentIdx in decreased in Route::IsSubroutePassed(size_t) method. See routing/route.cpp:448 - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-1, i*2); - } - else - { - // Duplicate last subroute attrs. - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); - subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); - } + subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-2, i*2); + subroutes.emplace_back(ToPointWA(points[i-1]), ToPointWA(points[i]), i*2-1, i*2); } route.SetCurrentSubrouteIdx(checkpoints.GetPassedIdx()); -- 2.45.3