]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/timetable.cpp
Move the responsibility of starting the train to TrainRouter
[r2c2.git] / source / libr2c2 / timetable.cpp
index 41cbbf00ab834350714025c865853d54462c4796..da01b599876d03c7f18d0e1bae05eb2951e9bff5 100644 (file)
@@ -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(t<current_row->time)
-                       t += Time::day;
-
-               Time::TimeDelta b = t-dt*clock.get_rate();
-               if(b<current_row->time)
-               {
-                       train.ai_message(Message("set-target-speed", train.get_maximum_speed()));
-                       ++current_row;
-               }
-       }
 }
 
 void Timetable::save(list<DataFile::Statement> &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();