17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-24 22:37:36 +02:00

fix(ai): orders of road junctions and level crossings measured along the lane they lie on, so they aren't misplaced on short lanes

This commit is contained in:
2026-10-22 17:16:33 +02:00
parent 29f624024f
commit f4f8c75e49
2 changed files with 10 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
#include "vehicle/DynObj.h"
#include "world/Event.h"
#include "world/MemCell.h"
#include "world/RoadOrder.h"
#include "simulation/simulation.h"
#include "simulation/simulationtime.h"
#include "world/Track.h"
@@ -602,7 +603,13 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ),
OrderCurrentGet() ) ) {
*/
if (newspeedpoint.Set(pEvent, GetDistanceToEvent(pTrack, pEvent, fLastDir, fCurrentDistance), fLength, OrderCurrentGet()))
// an order of a road junction or a level crossing lies on the lane it's on. it's measured along that lane: the search
// for the events beside the track goes in steps of about a metre, and misplaces the ones on lanes shorter than a few metres
auto const eventdistance{
typeid( *pEvent ) == typeid( road_order ) ?
fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ) :
GetDistanceToEvent( pTrack, pEvent, fLastDir, fCurrentDistance ) };
if (newspeedpoint.Set(pEvent, eventdistance, fLength, OrderCurrentGet()))
{
fDistance = newspeedpoint.fDist; // jeśli sygnał stop, to nie ma potrzeby dalej skanować