]> git.tdb.fi Git - r2c2.git/commitdiff
Add a separate double_address flag to TrackType
authorMikko Rasa <tdb@tdb.fi>
Wed, 21 Apr 2010 23:08:10 +0000 (23:08 +0000)
committerMikko Rasa <tdb@tdb.fi>
Wed, 21 Apr 2010 23:08:10 +0000 (23:08 +0000)
source/libmarklin/track.cpp
source/libmarklin/tracktype.cpp
source/libmarklin/tracktype.h
tracks.dat

index 208d40f10cdbbdfe09e81f6457c1a29a3da1a7c8..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
index 19b0c6b4a3e83ecbeeef8a10fe710d832d8ce993..d86977918655541b377fab7117f057289e931350 100644 (file)
@@ -14,7 +14,8 @@ using namespace Msp;
 namespace Marklin {
 
 TrackType::TrackType(unsigned a):
-       art_nr(a)
+       art_nr(a),
+       double_address(false)
 { }
 
 float TrackType::get_total_length() const
@@ -52,11 +53,6 @@ bool TrackType::is_turnout() const
        return endpoints.size()>2;
 }
 
-bool TrackType::is_double_address() const
-{
-       return get_n_paths()>2;
-}
-
 TrackPoint TrackType::get_point(unsigned epi, unsigned path, float d) const
 {
        if(epi>=endpoints.size())
@@ -158,6 +154,7 @@ TrackType::Loader::Loader(TrackType &t):
        Msp::DataFile::BasicLoader<TrackType>(t)
 {
        add("description", &TrackType::description);
+       add("double_address", &TrackType::double_address);
        add("part",        &Loader::part);
 }
 
index 14c98665bd11d0938c5a7c8b0c1404c0ad3fa20a..582f77ae25b1a506bbd49b28c6fec8cfea3f57e7 100644 (file)
@@ -32,6 +32,7 @@ private:
        std::string description;
        std::vector<TrackPart> parts;
        std::vector<Endpoint> endpoints;
+       bool double_address;
 
 public:
        TrackType(unsigned);
@@ -43,7 +44,7 @@ public:
        unsigned get_paths() const;
        unsigned get_n_paths() const;
        bool is_turnout() const;
-       bool is_double_address() const;
+       bool is_double_address() const { return double_address; }
        const std::vector<TrackPart> &get_parts() const { return parts; }
        const std::vector<Endpoint> &get_endpoints() const { return endpoints; }
        TrackPoint get_point(unsigned, unsigned, float) const;
index dafc85ba0dae18a7ddf22e42107b7c9d6a8bf8dd..7a2c07a354523d886217c9f5e843c386faecaa26 100644 (file)
@@ -308,6 +308,7 @@ track 24612
 track 24630
 {
        description "Turnout, 3-way";
+       double_address true;
        part
        {
                length 188.3;