From b992df7ab796fddaab97979f6f979aac6636519e Mon Sep 17 00:00:00 2001 From: pwarszawski Date: Sat, 7 Nov 2026 23:53:02 +0100 Subject: [PATCH] AI braking: slowdowndistance in the init-statement of its if (Sonar S6004) --- vehicle/Driver.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 92a693532..e27dff946 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -7638,13 +7638,13 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { } // allow to coast at reasonably low speed auto const brakingdistance { fBrakeDist * braking_distance_multiplier( VelNext ) }; - auto const slowdowndistance { ( - mvOccupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance - brakingdistance : - std::max( - (OrderCurrentGet() & Connect) == 0 ? 100.0 : 25.0, - brakingdistance ) ) }; - if( brakingdistance + std::max(slowdowndistance, fMaxProximityDist) < ActualProximityDist - fMaxProximityDist ) { + if( auto const slowdowndistance { ( + mvOccupied->CategoryFlag == 2 ? // cars can stop on a dime, for bigger vehicles we enforce some minimal braking distance + brakingdistance : + std::max( + (OrderCurrentGet() & Connect) == 0 ? 100.0 : 25.0, + brakingdistance ) ) }; + brakingdistance + std::max(slowdowndistance, fMaxProximityDist) < ActualProximityDist - fMaxProximityDist ) { // don't slow down prematurely; as long as we have room to come to a full stop at a safe distance, we're good return; }