]> git.tdb.fi Git - r2c2.git/commitdiff
Add a vehicle property for swapping directions
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 May 2011 11:20:40 +0000 (11:20 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 May 2011 11:20:40 +0000 (11:20 +0000)
Add a BR E 03 loco from the package 37574
Add whistle function for BR E 41

locos.dat
source/libr2c2/train.cpp
source/libr2c2/vehicletype.cpp
source/libr2c2/vehicletype.h

index aa472db93efe08e9a633eed1bc0e5afa9de64170..d05b96f64f6e4ff2699648a9a755eb858f200d12 100644 (file)
--- a/locos.dat
+++ b/locos.dat
@@ -306,6 +306,7 @@ vehicle 39410
        locomotive true;
        function 0 "light";
        function 3 "sfx";
+       function 5 "whstl";
 
        length 180;
        width 35;
@@ -329,3 +330,36 @@ vehicle 39410
                axle { position -18.5; wheel_diameter 14; powered true; object "bre41-axle.object"; };
        };
 };
+
+vehicle \37574-01
+{
+       name "BR E 03";
+       locomotive true;
+       function 0 "light";
+       function 2 "sfx";
+       function 3 "whstl";
+       swap_direction true;
+
+       length 219;
+       width 35;
+       height 49;
+
+       // XXX Create proper 3D model for this
+       object "br185-body.object";
+
+       bogie
+       {
+               position 62;
+               axle { position 17; wheel_diameter 14; powered true; };
+               axle { position -8.5; wheel_diameter 14; powered true; };
+               axle { position -34; wheel_diameter 14; powered true; };
+       };
+
+       bogie
+       {
+               position -62;
+               axle { position 34; wheel_diameter 14; powered true; };
+               axle { position 8.5; wheel_diameter 14; powered true; };
+               axle { position -17; wheel_diameter 14; powered true; };
+       };
+};
index ba1a861b9e24ec75f14a91049d8d3a76b54fc29f..415d49146d290e1865c65043800d7ff4e33d21d6 100644 (file)
@@ -588,7 +588,10 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)
        if(controller->get_reverse()!=reverse)
        {
                reverse = controller->get_reverse();
-               driver.set_loco_reverse(address, reverse);
+               bool r = reverse;
+               if(loco_type.get_swap_direction())
+                       r = !r;
+               driver.set_loco_reverse(address, r);
 
                release_blocks(cur_blocks_end, blocks.end());
                reverse_blocks(blocks);
@@ -715,8 +718,11 @@ void Train::loco_speed_event(unsigned addr, unsigned speed, bool rev)
        if(addr==address)
        {
                current_speed_step = speed;
-               if(rev!=reverse)
-                       layout.get_driver().set_loco_reverse(address, reverse);
+               bool r = reverse;
+               if(loco_type.get_swap_direction())
+                       r = !r;
+               if(rev!=r)
+                       layout.get_driver().set_loco_reverse(address, r);
                speed_changing = false;
                pure_speed = false;
        }
index 52dc7b0f45edf2f99fd9fc0257ef3bbb982fbbda..6c9d387ad7978f1da7ae4d65701050633eabe719 100644 (file)
@@ -15,6 +15,7 @@ namespace R2C2 {
 VehicleType::VehicleType(const ArticleNumber &an):
        art_nr(an),
        locomotive(false),
+       swap_direction(false),
        length(0),
        width(0),
        height(0)
@@ -119,6 +120,7 @@ VehicleType::Loader::Loader(VehicleType &vt):
        add("name",       &VehicleType::name);
        add("object",     &VehicleType::object);
        add("rod",        &Loader::rod);
+       add("swap_direction", &VehicleType::swap_direction);
        add("width",      &Loader::width);
 }
 
index 461a3bec535198931f1a74604d2618c6c533f91e..33d7d6590dba03fdec299a0e4932a5f1e1528f21 100644 (file)
@@ -134,6 +134,7 @@ private:
        std::string name;
        bool locomotive;
        std::map<unsigned, std::string> functions;
+       bool swap_direction;
        float length;
        float width;
        float height;
@@ -150,6 +151,7 @@ public:
        bool is_locomotive() const { return locomotive; }
        unsigned get_max_function() const;
        const std::map<unsigned, std::string> &get_functions() const { return functions; }
+       bool get_swap_direction() const { return swap_direction; }
        float get_length() const { return length; }
        float get_width() const { return width; }
        float get_height() const { return height; }