X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=8e10026f182bee49987318eb0daee177ad679873;hb=b51fbe499f1fd68a1abcbdee913cde1ccb580bca;hp=bb82fe4c34090cf22b53f90cda41aa74478dcc01;hpb=73e4a36bbf828e07b83a779b696875e1f80045cc;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index bb82fe4..8e10026 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); + } } } @@ -468,8 +487,11 @@ void Train::sensor_state_changed(Sensor &sensor, Sensor::State state) last_entry_block = allocator.iter_for(*block); travel_time = Time::zero; - pure_speed = true; - accurate_position = true; + if(!layout.get_driver().is_halted()) + { + pure_speed = true; + accurate_position = true; + } overshoot_dist = 0; if(!advancing && vehicles.front()->is_placed()) @@ -565,6 +587,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 +623,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);