Lead routes are now created up to the target, but not past it. This fixes
a problem where a route diverging from the train's reserved blocks caused
the router to attempt to create a lead route with gaps.
lead->set_temporary(true);
}
- set<Track *> tracks;
- for(BlockIter i=train.get_block_allocator().first(); (i && i->get_train()==&train); i=i.next())
+ bool target_reached = false;
+ for(TrackIter i=train.get_block_allocator().first().track_iter(); i; i=i.next())
{
- const set<Track *> &btracks = i->get_tracks();
- for(set<Track *>::const_iterator j=btracks.begin(); j!=btracks.end(); ++j)
- if(!target || !target->has_track(**j))
- tracks.insert(*j);
+ if(i->get_block().get_train()!=&train)
+ break;
+ if(target)
+ {
+ if(target->has_track(*i))
+ target_reached = true;
+ else if(target_reached)
+ break;
+ }
+ lead->add_track(*i);
}
- lead->add_tracks(tracks);
-
return lead;
}