mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-04 06:44:01 +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:
@@ -24,6 +24,7 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
#include "vehicle/DynObj.h"
|
#include "vehicle/DynObj.h"
|
||||||
#include "world/Event.h"
|
#include "world/Event.h"
|
||||||
#include "world/MemCell.h"
|
#include "world/MemCell.h"
|
||||||
|
#include "world/RoadOrder.h"
|
||||||
#include "simulation/simulation.h"
|
#include "simulation/simulation.h"
|
||||||
#include "simulation/simulationtime.h"
|
#include "simulation/simulationtime.h"
|
||||||
#include "world/Track.h"
|
#include "world/Track.h"
|
||||||
@@ -602,7 +603,13 @@ void TController::TableTraceRoute(double fDistance, TDynamicObject *pVehicle)
|
|||||||
fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ),
|
fCurrentDistance + ProjectEventOnTrack( pEvent, pTrack, fLastDir ),
|
||||||
OrderCurrentGet() ) ) {
|
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ć
|
fDistance = newspeedpoint.fDist; // jeśli sygnał stop, to nie ma potrzeby dalej skanować
|
||||||
|
|||||||
@@ -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)};
|
auto const closed{control > 0.0 || (control == 0.0 && m_hold > 0.0)};
|
||||||
if (closed != m_closed)
|
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);
|
close(closed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user