]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/train.cpp
Move double-address logic to drivers
[r2c2.git] / source / libr2c2 / train.cpp
index 0cbe306234c09b11a9535f1e21fe71673e4bed2e..28976838fcf7da9c699ed11b8b461cdab566fd41 100644 (file)
@@ -76,7 +76,7 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a, const string &p):
 
        layout.add_train(*this);
 
-       layout.get_driver().add_loco(address, protocol);
+       layout.get_driver().add_loco(address, protocol, loco_type);
        layout.get_driver().signal_loco_speed.connect(sigc::mem_fun(this, &Train::loco_speed_event));
        layout.get_driver().signal_loco_function.connect(sigc::mem_fun(this, &Train::loco_func_event));
 
@@ -186,10 +186,7 @@ void Train::set_function(unsigned func, bool state)
 {
        if(!loco_type.get_functions().count(func))
                throw InvalidParameterValue("Invalid function");
-       if(func<5)
-               layout.get_driver().set_loco_function(address, func, state);
-       else
-               layout.get_driver().set_loco_function(address+1, func-4, state);
+       layout.get_driver().set_loco_function(address, func, state);
 }
 
 float Train::get_control(const string &ctrl) const
@@ -690,10 +687,8 @@ void Train::loco_speed_event(unsigned addr, unsigned speed, bool)
 
 void Train::loco_func_event(unsigned addr, unsigned func, bool state)
 {
-       if(addr==address || (addr==address+1 && loco_type.get_max_function()>4))
+       if(addr==address)
        {
-               if(addr==address+1)
-                       func += 4;
                if(state)
                        functions |= 1<<func;
                else