-
- RoutingStep next(&step);
- next.advance(dt);
- TrainRouter &router = *train.info->router;
- if(train.waypoint<0 && router.is_destination(*train.track) && !router.is_destination(*next_track))
- {
- next.trains[train_index].state = ARRIVED;
- new_steps.push_back(next);
- }
- else
- {
- if(train.waypoint>=0 && router.is_waypoint(train.waypoint, *train.track) && !router.is_waypoint(train.waypoint, *next_track))
- {
- ++next.trains[train_index].waypoint;
- if(next.trains[train_index].waypoint>=static_cast<int>(router.get_n_waypoints()))
- next.trains[train_index].waypoint = -1;
- }
-
- next.trains[train_index].advance_track(0);
-
- const TrackType::Endpoint &next_entry_ep = next_track.endpoint();
- for(unsigned i=0; next_entry_ep.paths>>i; ++i)
- if(next_entry_ep.has_path(i))
- {
- next.trains[train_index].path = i;
- if(next.is_viable())
- new_steps.push_back(next);
- }
-
- if(next_entry_ep.paths!=next_track->get_type().get_paths())
- {
- RoutingStep wait(&step);
- wait.advance(dt);
- wait.trains[train_index].state = WAITING;
- if(wait.is_viable())
- new_steps.push_back(wait);
- }
- }
-