]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/aicontrol.cpp
Don't save an allocated but pending block
[r2c2.git] / source / libr2c2 / aicontrol.cpp
index 97b7209cf47539f892ddfa5872b21d053eed949f..f1f16bf1850a511c25059aa247356ec4445fbcee 100644 (file)
@@ -21,9 +21,6 @@ AIControl::AIControl(Train &t):
 
 void AIControl::set_target_speed(float s)
 {
-       if(s && !train.is_active())
-               train.set_active(true);
-
        target_speed = s;
        need_update = true;
        signal_event.emit(Message("target-speed-changed", target_speed));
@@ -83,7 +80,7 @@ void AIControl::tick(const Time::TimeDelta &)
                        speed_limit = 0;
                else if(state==APPROACH)
                        speed_limit = approach_speed;
-               else if(state==FOLLOW && train.get_preceding_train()->is_active())
+               else if(state==FOLLOW && train.get_preceding_train()->get_block_allocator().is_active())
                        speed_limit = train.get_preceding_train()->get_speed();
 
                if(speed_limit>=0 && target_speed>speed_limit)
@@ -99,9 +96,11 @@ void AIControl::tick(const Time::TimeDelta &)
                reverse = pending_reverse;
                train.set_control("reverse", reverse);
        }
+}
 
-       if(!target_speed && !train.get_controller().get_speed() && train.is_active())
-               train.set_active(false);
+bool AIControl::has_intent_to_move() const
+{
+       return target_speed;
 }
 
 void AIControl::event(TrainAI &, const Message &ev)