]> git.tdb.fi Git - r2c2.git/commitdiff
Avoid deactivating while the controller still has nonzero speed
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 May 2011 07:40:54 +0000 (07:40 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 May 2011 07:40:54 +0000 (07:40 +0000)
source/libr2c2/train.cpp

index 00730c8e15e08fd048b35b137d51c7adcac51d91..93ebebec3c16ef66502da7045fe6df24cf429a4d 100644 (file)
@@ -583,6 +583,7 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)
                (*i)->tick(t, dt);
        controller->tick(dt);
        float speed = controller->get_speed();
+       bool moving = speed>0;
 
        if(controller->get_reverse()!=reverse)
        {
@@ -609,7 +610,7 @@ void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)
                speed = speed_quantizer->get_speed(current_speed_step);
        }
 
-       if(speed)
+       if(moving)
        {
                if(!active)
                        set_active(true);