17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-26 15:54:53 +01: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ć

View File

@@ -947,6 +947,8 @@ void roadpoint_node::update_crossing(double const Deltatime)
auto const closed{control > 0.0 || (control == 0.0 && m_hold > 0.0)};
if (closed != m_closed)
{
WriteLog("Level crossing \"" + m_name + "\" " + (closed ? "closed" : "opened") + (control != 0.0 ? " by memory cell \"" + m_memcell->name() + "\"" : " by the trains") + ", stops: " +
std::to_string(m_stops.size()));
close(closed);
}
}