X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=34b80ddcc39d213635431e50613ecdce29776d51;hb=6cfe927c34e7b866818502b39073b74b47666ba7;hp=bb82fe4c34090cf22b53f90cda41aa74478dcc01;hpb=73e4a36bbf828e07b83a779b696875e1f80045cc;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index bb82fe4..34b80dd 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -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" @@ -161,6 +162,18 @@ float Train::get_quantized_speed() const return controller->get_speed(); } +float Train::get_maximum_speed() const +{ + float ms = 0; + for(vector::const_iterator i=vehicles.begin(); i!=vehicles.end(); ++i) + { + float vms = (*i)->get_type().get_maximum_speed(); + if(ms<=0 || (vms>0 && vms>func)&1; @@ -396,6 +409,12 @@ void Train::save(list &st) const router->save(ss.sub); st.push_back(ss); } + else if(Timetable *timetable = dynamic_cast(*i)) + { + DataFile::Statement ss("timetable"); + timetable->save(ss.sub); + st.push_back(ss); + } } } @@ -565,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); } @@ -600,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(art_nr);