]> git.tdb.fi Git - r2c2.git/commitdiff
Fix MFX speedsteps in Central Station driver
authorMikko Rasa <tdb@tdb.fi>
Fri, 3 Dec 2010 19:05:50 +0000 (19:05 +0000)
committerMikko Rasa <tdb@tdb.fi>
Fri, 3 Dec 2010 19:05:50 +0000 (19:05 +0000)
Don't leave symbol uninitialized

source/libr2c2/centralstation.cpp

index 69bb8a9cf48c78745bf882f764cf0c7270087152..6a8de96694f3d9ada60020ff06dc4a018a676de6 100644 (file)
@@ -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<unsigned>(i->second);
+                               if(loco.protocol==MFX && loco.speed)
+                                       --loco.speed;
                                speed_changed = true;
                        }
                        else if(i->first=="dir")