X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.cpp;h=b53342c645c6d71e77ab3727e9833908835bf228;hb=3907520897611cb1b5f2f938c60d3eaff34477a5;hp=0df1f40b03141c60febd73c237148a2d97656709;hpb=9cb5f9ef3c0eaac499ef5d045c513116d6809e56;p=r2c2.git diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 0df1f40..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,7 +319,11 @@ bool Track::link_to(Object &other) if(!otrack) return false; - float limit = layout.get_catalogue().get_gauge(); + 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; limit *= limit; @@ -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));