If route plans are regenerated when the train's last vehicle is on the
sensor following a turnout in a points-facing movement, the first track
of the lead route is a turnout with undetermined path. Route_changed
would then try to figure out which route the next allocation will occur
on and fail at the very beginning because advance_to_track refused to
use the undetermined turnout.
TrackIter track = train.get_block_allocator().first().track_iter();
for(; track; track=track.next())
{
TrackIter track = train.get_block_allocator().first().track_iter();
for(; track; track=track.next())
{
- if(!advance_to_track(reserving_route, *track))
+ if(!advance_to_track(reserving_route, track))
{
already_at_end = true;
break;
{
already_at_end = true;
break;
track = t->get_block_allocator().first().track_iter();
for(; track; track=track.next())
{
track = t->get_block_allocator().first().track_iter();
for(; track; track=track.next())
{
- if(!advance_to_track(reserving_route, *track))
+ if(!advance_to_track(reserving_route, track))
throw logic_error("internal error (reservation outside of route)");
else if(&track->get_block()==&block)
break;
throw logic_error("internal error (reservation outside of route)");
else if(&track->get_block()==&block)
break;
expected to be allocated next. */
for(; track; track=track.next((*reserving_route)->get_path(*track)))
{
expected to be allocated next. */
for(; track; track=track.next((*reserving_route)->get_path(*track)))
{
- if(!advance_to_track(reserving_route, *track))
+ if(!advance_to_track(reserving_route, track))
{
// We've reached the end of the route. Stop here.
arrival = RESERVED_TO_END;
{
// We've reached the end of the route. Stop here.
arrival = RESERVED_TO_END;
-bool TrainRouter::is_valid_for_track(const Route &route, Track &track) const
+bool TrainRouter::is_valid_for_track(const Route &route, const TrackIter &track) const
- if(!route.has_track(track))
+ if(!route.has_track(*track))
- if(track.get_type().is_turnout() && route.get_turnout(track.get_turnout_address())<0)
+ if(track->get_type().is_turnout() && route.get_turnout(track->get_turnout_address())<0 && route.has_track(*track.flip()))
return false;
return true;
}
return false;
return true;
}
-bool TrainRouter::advance_to_track(RouteList::iterator &route, Track &track)
+bool TrainRouter::advance_to_track(RouteList::iterator &route, const TrackIter &track)
{
if(!is_valid_for_track(**route, track))
{
{
if(!is_valid_for_track(**route, track))
{
void create_metrics();
bool create_lead_route();
void create_metrics();
bool create_lead_route();
- bool is_valid_for_track(const Route &, Track &) const;
- bool advance_to_track(RouteList::iterator &, Track &);
+ bool is_valid_for_track(const Route &, const TrackIter &) const;
+ bool advance_to_track(RouteList::iterator &, const TrackIter &);
static void start_planning(Layout &);
};
static void start_planning(Layout &);
};