/* 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))
{
- 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())
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()));
{
BlockIter b_iter = train.get_block_allocator().iter_for(block);
- if(waypoints.size()>1)
+ if(!waypoints.empty())
{
// A waypoint is considered reached when the train has advanced through it.
const TrackChain &wp = *waypoints.front();
{
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))