]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.cpp
New timetable system, which works like an actual timetable
[r2c2.git] / source / libr2c2 / train.cpp
index 845232fa4d9cf442fc5dddc692c5873291c35302..34b80ddcc39d213635431e50613ecdce29776d51 100644 (file)
@@ -14,6 +14,7 @@
 #include "route.h"
 #include "simplecontroller.h"
 #include "speedquantizer.h"
+#include "timetable.h"
 #include "trackcircuit.h"
 #include "trackiter.h"
 #include "tracktype.h"
@@ -408,6 +409,12 @@ void Train::save(list<DataFile::Statement> &st) const
                        router->save(ss.sub);
                        st.push_back(ss);
                }
+               else if(Timetable *timetable = dynamic_cast<Timetable *>(*i))
+               {
+                       DataFile::Statement ss("timetable");
+                       timetable->save(ss.sub);
+                       st.push_back(ss);
+               }
        }
 }
 
@@ -577,6 +584,7 @@ Train::Loader::Loader(Train &t):
        add("name",        &Loader::name);
        add("quantized_speed",  &Loader::quantized_speed);
        add("router",      &Loader::router);
+       add("timetable",   &Loader::timetable);
        add("vehicle",     &Loader::vehicle);
 }
 
@@ -612,6 +620,12 @@ void Train::Loader::router()
        load_sub(*rtr);
 }
 
+void Train::Loader::timetable()
+{
+       Timetable *ttbl = new Timetable(obj);
+       load_sub(*ttbl, obj.layout);
+}
+
 void Train::Loader::vehicle(ArticleNumber art_nr)
 {
        const VehicleType &vtype = obj.layout.get_catalogue().get<VehicleType>(art_nr);