X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;fp=source%2Flibr2c2%2Ftrain.cpp;h=bb82fe4c34090cf22b53f90cda41aa74478dcc01;hb=73e4a36bbf828e07b83a779b696875e1f80045cc;hp=50ad137723d42ec2a8c10775767a3de92c91d745;hpb=b28062f2dc88e082ee5a28b2e1f7c4c8bd989023;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 50ad137..bb82fe4 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -58,7 +58,7 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a, const string &p): layout.add_train(*this); - layout.get_driver().add_loco(address, protocol, loco_type); + loco_id = 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)); @@ -140,7 +140,7 @@ void Train::set_function(unsigned func, bool state) { if(!loco_type.get_functions().count(func)) throw invalid_argument("Train::set_function"); - layout.get_driver().set_loco_function(address, func, state); + layout.get_driver().set_loco_function(loco_id, func, state); } float Train::get_control(const string &ctrl) const @@ -317,7 +317,7 @@ void Train::tick(const Time::TimeDelta &dt) bool r = reverse; if(loco_type.get_swap_direction()) r = !r; - driver.set_loco_reverse(address, r); + driver.set_loco_reverse(loco_id, r); allocator.reverse(); last_entry_block = BlockIter(); @@ -329,7 +329,7 @@ void Train::tick(const Time::TimeDelta &dt) if(speed_step!=current_speed_step && !speed_changing && !driver.is_halted() && driver.get_power()) { speed_changing = true; - driver.set_loco_speed(address, speed_step); + driver.set_loco_speed(loco_id, speed_step); pure_speed = false; } @@ -404,24 +404,24 @@ void Train::control_changed(const Controller::Control &ctrl) signal_control_changed.emit(ctrl.name, ctrl.value); } -void Train::loco_speed_event(unsigned addr, unsigned speed, bool rev) +void Train::loco_speed_event(unsigned id, unsigned speed, bool rev) { - if(addr==address) + if(id==loco_id) { current_speed_step = speed; bool r = reverse; if(loco_type.get_swap_direction()) r = !r; if(rev!=r) - layout.get_driver().set_loco_reverse(address, r); + layout.get_driver().set_loco_reverse(loco_id, r); speed_changing = false; pure_speed = false; } } -void Train::loco_func_event(unsigned addr, unsigned func, bool state) +void Train::loco_func_event(unsigned id, unsigned func, bool state) { - if(addr==address) + if(id==loco_id) { if(state) functions |= 1<