X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=28976838fcf7da9c699ed11b8b461cdab566fd41;hb=85362cce505281c1d281c959e135c9f8fa12bd5c;hp=0cbe306234c09b11a9535f1e21fe71673e4bed2e;hpb=90f9efba8d88f41c7a180734b7bcbdd1501d995e;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 0cbe306..2897683 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -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<