If the final block of the route is allocated while the train is stopped,
arrival could be triggered prematurely. I'm not entirely certain if this
can happen in absence of certain quirks of the dummy driver, but better
safe than sorry.
/* Find the route that should be used for the next allocated block. We
can't rely on the resync code in block_reserved since we may need to
clear the stop marker to continue allocation. */
/* Find the route that should be used for the next allocated block. We
can't rely on the resync code in block_reserved since we may need to
clear the stop marker to continue allocation. */
- TrackIter track = train.get_block_allocator().first().track_iter();
+ const BlockAllocator &allocator = train.get_block_allocator();
+ TrackIter track = allocator.first().track_iter();
list<SequencePoint>::iterator seq_begin = sequence_points.begin();
for(; track; track=track.next())
{
if(!advance_to_track(reserving_route, track))
{
list<SequencePoint>::iterator seq_begin = sequence_points.begin();
for(; track; track=track.next())
{
if(!advance_to_track(reserving_route, track))
{
- arrival = RESERVED_TO_END;
+ arrival = (allocator.is_block_current(track->get_block()) ? ADVANCED_TO_END : RESERVED_TO_END);
break;
}
if(&track->get_block()==fncb.block())
break;
}
if(&track->get_block()==fncb.block())
sequence_check_pending = false;
}
sequence_check_pending = false;
}
- if(arrival==RESERVED_TO_END && !train.get_speed())
+ if(arrival==ADVANCED_TO_END && !train.get_speed())
{
signal_arrived.emit(waypoints.back());
signal_event.emit(Message("arrived", waypoints.back()));
{
signal_arrived.emit(waypoints.back());
signal_event.emit(Message("arrived", waypoints.back()));
{
BlockIter b_iter = train.get_block_allocator().iter_for(block);
{
BlockIter b_iter = train.get_block_allocator().iter_for(block);
{
// A waypoint is considered reached when the train has advanced through it.
const TrackChain &wp = *waypoints.front();
{
// A waypoint is considered reached when the train has advanced through it.
const TrackChain &wp = *waypoints.front();
{
if(!wp.has_track(*t_iter))
{
{
if(!wp.has_track(*t_iter))
{
- waypoints.erase(waypoints.begin());
- metrics_stale = true;
- signal_waypoint_reached.emit(&wp);
- signal_event.emit(Message("waypoint-reached", &wp));
+ if(waypoints.size()==1)
+ {
+ if(arrival==RESERVED_TO_END)
+ arrival = ADVANCED_TO_END;
+ }
+ else
+ {
+ waypoints.erase(waypoints.begin());
+ metrics_stale = true;
+ signal_waypoint_reached.emit(&wp);
+ signal_event.emit(Message("waypoint-reached", &wp));
+ }
break;
}
else if(!block.has_track(*t_iter))
break;
}
else if(!block.has_track(*t_iter))
ON_THE_WAY,
WAITING_FOR_SEQUENCE,
RESERVED_TO_END,
ON_THE_WAY,
WAITING_FOR_SEQUENCE,
RESERVED_TO_END,