From 18c56359eee5477ed1ffe86360b9dcf2d1d75002 Mon Sep 17 00:00:00 2001 From: maj00r <73280030+maj00r@users.noreply.github.com> Date: Wed, 11 Nov 2026 04:30:13 +0100 Subject: [PATCH] fix(ai): the stop point on a W4 kept the margin of a passenger stop from the platform's end (#321) The W4 stop point was shifted with fMinProximityDist (8 m), while the train comes to a stand anywhere up to the margin of a passenger stop (10-15 m by the number of vehicles) short of it. A train stopping by the middle of a platform could so stand with its tail a few metres past the platform's end (L053: Swoszowice 204.5 m of 201, Tumlin 244.3 m of 242). The point is now shifted with the same margin the stop is judged by, so the tail stays inside (197.5 m and 240.4 m on the same run). Co-authored-by: maj00r --- vehicle/Driver.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 2bd05baab..27b742b06 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -1205,6 +1205,12 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub } // koniec obsługi przelotu na W4 else { // zatrzymanie na W4 + // the margins of a passenger stop, whether the train is already making for it or not: the present ones + // depend on this very flag, and a check against them would turn it on and off every other scan + auto const [ stopminproximity, stopmaxproximity ] { + is_train() ? + train_proximity_margins( true ) : + std::pair{ fMinProximityDist, fMaxProximityDist } }; if ( false == Point.bMoved ) { // potentially shift the stop point in accordance with its defined parameters /* @@ -1223,9 +1229,12 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub } else { //środek - L = Par1 - fMinProximityDist - fLength * 0.5; + L = Par1 - stopminproximity - fLength * 0.5; } - L = std::max(0.0, std::min(L, std::abs(Par2) - fMinProximityDist - fLength)); + // the train comes to a stand anywhere up to the margin of a passenger stop short of this point, not + // that of the signals it may be making for when it first sees the W4, so the tail is to keep that far + // inside the platform + L = std::max(0.0, std::min(L, std::abs(Par2) - stopminproximity - fLength)); Point.UpdateDistance(L); Point.bMoved = true; Point.fMoved = L; @@ -1246,12 +1255,6 @@ TController::TableUpdateStopPoint( TCommandType &Command, TSpeedPos &Point, doub return true; } - // the margins of a passenger stop, whether the train is already making for it or not: the present ones - // depend on this very flag, and a check against them would turn it on and off every other scan - auto const [ stopminproximity, stopmaxproximity ] { - is_train() ? - train_proximity_margins( true ) : - std::pair{ fMinProximityDist, fMaxProximityDist } }; IsAtPassengerStop = Point.fDist <= passengerstopmaxdistance // Ra 2F1I: odległość plus długość pociągu musi być mniejsza od długości // peronu, chyba że pociąg jest dłuższy, to wtedy minimalna.