From: Mikko Rasa Date: Tue, 31 Mar 2015 21:42:00 +0000 (+0300) Subject: Move the responsibility of starting the train to TrainRouter X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=03a22611772265b539f826f1f8bc482e71ca4a99;p=r2c2.git Move the responsibility of starting the train to TrainRouter This avoids any further sync problems with the planner, accounts for irregular situations and also makes more sense. --- diff --git a/source/libr2c2/timetable.cpp b/source/libr2c2/timetable.cpp index 41cbbf0..da01b59 100644 --- a/source/libr2c2/timetable.cpp +++ b/source/libr2c2/timetable.cpp @@ -89,22 +89,6 @@ void Timetable::tick(const Time::TimeDelta &dt) { if(update_pending && !train.get_block_allocator().is_active()) update_route(); - - if(current_row->type==DEPART) - { - const Clock &clock = train.get_layout().get_clock(); - - Time::TimeDelta t = clock.get_current_time(); - if(ttime) - t += Time::day; - - Time::TimeDelta b = t-dt*clock.get_rate(); - if(btime) - { - train.ai_message(Message("set-target-speed", train.get_maximum_speed())); - ++current_row; - } - } } void Timetable::save(list &st) const @@ -202,11 +186,18 @@ void Timetable::update_route() dt += Time::day; train.ai_message(Message("set-trip-duration", dt/clock.get_rate())); } + + late_arrival = false; } void Timetable::event(TrainAI &, const Message &msg) { - if(msg.type=="arrived") + if(msg.type=="departed") + { + if(current_row->type==DEPART) + ++current_row; + } + else if(msg.type=="arrived") { if(current_row->type==ARRIVE) record_time(); diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index 1ada621..cc6277f 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -241,6 +241,9 @@ void TrainRouter::tick(const Time::TimeDelta &dt) if(delay signal_route_changed; + sigc::signal signal_departed; sigc::signal signal_arrived; sigc::signal signal_waypoint_reached;