X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Faicontrol.cpp;h=f1f16bf1850a511c25059aa247356ec4445fbcee;hb=d6516b0d9faa26fe6c64000c34f8d820f91ac479;hp=97b7209cf47539f892ddfa5872b21d053eed949f;hpb=9f4f169affcedcf249e935f93e0a15ed60232f6a;p=r2c2.git diff --git a/source/libr2c2/aicontrol.cpp b/source/libr2c2/aicontrol.cpp index 97b7209..f1f16bf 100644 --- a/source/libr2c2/aicontrol.cpp +++ b/source/libr2c2/aicontrol.cpp @@ -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)