From: Mikko Rasa Date: Fri, 3 Dec 2010 19:05:50 +0000 (+0000) Subject: Fix MFX speedsteps in Central Station driver X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4d60572bd7ba7f6b9ffed2c9f1191e39aad3d54c;p=r2c2.git Fix MFX speedsteps in Central Station driver Don't leave symbol uninitialized --- diff --git a/source/libr2c2/centralstation.cpp b/source/libr2c2/centralstation.cpp index 69bb8a9..6a8de96 100644 --- a/source/libr2c2/centralstation.cpp +++ b/source/libr2c2/centralstation.cpp @@ -90,7 +90,7 @@ unsigned CentralStation::get_protocol_speed_steps(const string &name) const { case MM: return 14; case MM_27: return 27; - case MFX: return 127; + case MFX: return 126; default: return 0; } } @@ -121,7 +121,12 @@ void CentralStation::set_loco_speed(unsigned addr, unsigned speed) unsigned id = map_address(locos, loco_addr, addr); if(id) + { + Locomotive &loco = locos[id]; + if(loco.protocol==MFX && speed) + ++speed; command(format("set(%d, speedstep[%d])", id, speed)); + } } void CentralStation::set_loco_reverse(unsigned addr, bool rev) @@ -157,7 +162,7 @@ void CentralStation::add_turnout(unsigned addr, const TrackType &type) cross = true; } - unsigned symbol; + unsigned symbol = Turnout::LEFT; if(cross) symbol = Turnout::DOUBLESLIP; else if(left && right) @@ -523,6 +528,8 @@ void CentralStation::process_object(unsigned id, const Message::AttribMap &attri else if(i->first=="speedstep") { loco.speed = lexical_cast(i->second); + if(loco.protocol==MFX && loco.speed) + --loco.speed; speed_changed = true; } else if(i->first=="dir")