- // Check if the next block is still part of the designated route
- BlockIter b_iter_next = b_iter.next(*route);
+ TrackIter track = train.get_block_allocator().iter_for(block).track_iter();
+
+ // Is the block a turnout? If so, set it to the proper path.
+ if(unsigned taddr = block.get_turnout_address())
+ {
+ int path = (*reserving_route)->get_turnout(taddr);
+ if(path>=0)
+ track->set_active_path(path);
+ }
+
+ if(reserving_route==routes.end() || !(*reserving_route)->has_track(*track))
+ {
+ reserving_route = routes.begin();
+ arrival = ON_THE_WAY;
+ track = t->get_block_allocator().first().track_iter();
+ for(; track; track=track.next())
+ {
+ if(!advance_to_track(reserving_route, *track))
+ throw logic_error("internal error (reservation outside of route)");
+ else if(&track->get_block()==&block)
+ break;
+ }
+ }