X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=b53342c645c6d71e77ab3727e9833908835bf228;hb=3dfcd6a470a96dc7b6f2f100e604c7f0db6da00c;hp=7b6bef1de2d7e914846f67ec1b8c5f8b4eadfd64;hpb=2875ea548e0567ad2ce1b8f9bda58e6452813204;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 7b6bef1..b53342c 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -55,7 +55,6 @@ Track::Track(Layout &l, const TrackType &t): layout.add(*this); - for(unsigned paths = type.get_paths(); !(paths&1); ++active_path, paths>>=1) ; } @@ -320,6 +319,10 @@ bool Track::link_to(Object &other) if(!otrack) return false; + float gauge_ratio = otrack->get_type().get_gauge()/type.get_gauge(); + if(gauge_ratio<0.99 || gauge_ratio>1.01) + return false; + float limit = type.get_gauge(); if(!flex && !otrack->get_flex()) limit /= 10; @@ -413,6 +416,12 @@ void Track::save(list &st) const st.push_back((DataFile::Statement("flex"), true)); } +void Track::save_dynamic(list &st) const +{ + if(turnout_addr) + st.push_back((DataFile::Statement("path"), active_path)); +} + void Track::turnout_event(unsigned id, unsigned state) { if(id==turnout_id) @@ -436,6 +445,7 @@ void Track::turnout_failed(unsigned id) Track::Loader::Loader(Track &t): DataFile::ObjectLoader(t) { + add("path", &Loader::path); add("position", &Loader::position); add("rotation", &Loader::rotation); add("tilt", &Loader::tilt); @@ -449,6 +459,16 @@ Track::Loader::Loader(Track &t): add("slope", &Loader::slope); } +void Track::Loader::path(unsigned p) +{ + obj.set_active_path(p); + if(obj.path_changing) + { + obj.active_path = p; + obj.signal_path_changed.emit(p); + } +} + void Track::Loader::position(float x, float y, float z) { obj.set_position(Vector(x, y, z));