]> git.tdb.fi Git - r2c2.git/blobdiff - source/libmarklin/track.cpp
Set correct Z coordinate to vehicle position
[r2c2.git] / source / libmarklin / track.cpp
index 030af70bc85fd1d2e667b4e47a24830a7ac915ea..05f9f2f717c1044b47446b73aeab0ac01f68b73b 100644 (file)
@@ -130,8 +130,10 @@ void Track::set_active_path(unsigned p)
                throw InvalidParameterValue("Invalid path");
 
        layout.get_driver().set_turnout(turnout_id, p&1);
-       if(type.get_n_paths()>2)
+       if(type.is_double_address())
                layout.get_driver().set_turnout(turnout_id+1, p&2);
+       else if(type.get_n_paths()>2)
+               active_path = (active_path&1) | (p&2);
 }
 
 int Track::get_endpoint_by_link(const Track &other) const
@@ -293,6 +295,11 @@ unsigned Track::traverse(unsigned i, unsigned path) const
        throw Exception("Track endpoint did not have a counterpart");
 }
 
+unsigned Track::traverse(unsigned i) const
+{
+       return traverse(i, active_path);
+}
+
 TrackPoint Track::get_point(unsigned epi, unsigned path, float d) const
 {
        TrackPoint p = type.get_point(epi, path, d);