+#include "catalogue.h"
#include "layout.h"
#include "route.h"
#include "train.h"
TrainRoutePlanner::TrainRoutingInfo::TrainRoutingInfo(Train &t):
train(&t),
+ speed(train->get_maximum_speed()),
router(train->get_ai_of_type<TrainRouter>()),
route(0)
-{ }
+{
+ // If no maximum speed is specified, use a sensible default
+ if(!speed)
+ speed = 20*train->get_layout().get_catalogue().get_scale();
+}
TrainRoutePlanner::OccupiedTrack::OccupiedTrack(Track &t, unsigned p, OccupiedTrack *n):
Time::TimeDelta TrainRoutePlanner::TrainRoutingState::get_time_to_next_track() const
{
- // TODO Consider the speed of the train
- return (track->get_type().get_path_length(path)-offset)*Time::sec+delay;
+ return ((track->get_type().get_path_length(path)-offset)/info->speed)*Time::sec+delay;
}
bool TrainRoutePlanner::TrainRoutingState::is_occupied(Track &trk) const
i->delay = Time::zero;
}
else if(i->state==MOVING)
- {
- float distance = dt/Time::sec;
- i->advance(distance);
- }
+ i->advance(i->info->speed*(dt/Time::sec));
}
}