From 03a22611772265b539f826f1f8bc482e71ca4a99 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 1 Apr 2015 00:42:00 +0300 Subject: [PATCH] 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. --- source/libr2c2/timetable.cpp | 25 ++++++++----------------- source/libr2c2/trainrouter.cpp | 3 +++ source/libr2c2/trainrouter.h | 1 + 3 files changed, 12 insertions(+), 17 deletions(-) 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; -- 2.45.2