]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/timetable.cpp
Allow direction to be specified for routing waypoints
[r2c2.git] / source / libr2c2 / timetable.cpp
index 0d68a7be8aea5c88f515a60192e4aac62d6267ce..b94cbf08fcfc37ad9d3485aeaf78f1ffe76ec615 100644 (file)
@@ -176,20 +176,19 @@ void Timetable::update_route()
        current_row = depart;
        for(list<Row>::const_iterator i=depart; i!=rows.end(); ++i)
        {
-               if(i->type==ARRIVE)
-               {
-                       train.ai_message(Message("add-waypoint", i->target));
-                       break;
-               }
-               else if(i->type==DEPART)
+               if(i->type==DEPART)
                {
                        Time::TimeDelta dt = i->time-clock.get_current_time();
                        while(dt<Time::zero)
                                dt += Time::day;
                        train.ai_message(Message("set-departure-delay", dt/clock.get_rate()));
                }
-               else if(i->type==THROUGH)
-                       train.ai_message(Message("add-waypoint", i->target));
+               else
+               {
+                       train.ai_message(Message("add-waypoint", TrainRouter::Waypoint(*i->target, i->direction)));
+                       if(i->type==ARRIVE)
+                               break;
+               }
        }
 
        list<Row>::iterator next_depart = find_trip(arrive, 0);
@@ -233,7 +232,8 @@ void Timetable::record_time()
 
 Timetable::Row::Row():
        type(ARRIVE),
-       target(0)
+       target(0),
+       direction(TrackChain::UNSPECIFIED)
 { }
 
 void Timetable::Row::save(list<DataFile::Statement> &st) const
@@ -241,6 +241,8 @@ void Timetable::Row::save(list<DataFile::Statement> &st) const
        st.push_back((DataFile::Statement("type"), type));
        st.push_back((DataFile::Statement("time"), time.raw()));
        st.push_back(target->save_reference());
+       if(direction)
+               st.push_back((DataFile::Statement("direction"), direction));
 }
 
 
@@ -265,6 +267,7 @@ Timetable::Row::Loader::Loader(Row &r, Layout &l):
        layout(l)
 {
        add("block", &Loader::block);
+       add("direction", &Row::direction);
        add("time", &Loader::time);
        add("type", &Row::type);
        add("zone", &Loader::zone);