TrainRoutePlanner::TrainRoutingInfo::TrainRoutingInfo(Train &t):
train(&t),
speed(train->get_maximum_speed()),
+ first_noncritical(train->get_first_noncritical_block().block()),
router(train->get_ai_of_type<TrainRouter>()),
destination(0),
has_duration(false)
TrainRoutePlanner::TrainRoutingState::TrainRoutingState(TrainRoutingInfo &inf):
info(&inf),
+ critical(true),
occupied_tracks(0),
state(MOVING),
delay(info->router->get_departure_delay()),
info(other.info),
track(other.track),
path(other.path),
+ critical(other.critical),
occupied_tracks(other.occupied_tracks),
offset(other.offset),
back_offset(other.back_offset),
waypoint = -1;
}
+ if(info->first_noncritical->has_track(*track))
+ critical = false;
+
return false;
}
train.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))
- {
- train.path = i;
- train.update_estimate();
- next.update_estimate();
- if(next.is_viable())
- new_steps.push_back(next);
- }
+ if(train.critical)
+ {
+ train.path = train.track->get_type().coerce_path(train.track.entry(), train.track->get_active_path());
+ train.update_estimate();
+ next.update_estimate();
+ if(next.is_viable())
+ new_steps.push_back(next);
+ }
+ else
+ {
+ for(unsigned i=0; next_entry_ep.paths>>i; ++i)
+ if(next_entry_ep.has_path(i))
+ {
+ train.path = i;
+ train.update_estimate();
+ next.update_estimate();
+ if(next.is_viable())
+ new_steps.push_back(next);
+ }
+ }
new_steps.sort();
for(list<RoutingStep>::iterator i=new_steps.begin(); ++i!=new_steps.end(); )
i->update_estimate();
}
- if(next_entry_ep.paths!=next_track->get_type().get_paths())
+ if(next_entry_ep.paths!=next_track->get_type().get_paths() && !train.critical)
{
RoutingStep wait(this);
wait.advance(dt);