X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrainrouter.cpp;h=122b91a3bd195837f90455cc3da66289d37ea453;hb=68877070660f2806cc2a7f0ccb69153059ef6ce7;hp=9befe4788c4b03114cfe4939f6ea7c02eee0fe06;hpb=83c6923396fcfa42e6adf949b9476663f322748b;p=r2c2.git diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index 9befe47..122b91a 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -1,3 +1,4 @@ +#include "driver.h" #include "layout.h" #include "route.h" #include "trackiter.h" @@ -67,6 +68,8 @@ void TrainRouter::use_planned_route() { if(!planner || planner->get_result()!=TrainRoutePlanner::COMPLETE) return; + if(waypoints.empty()) + return; const list &planned_routes = planner->get_routes_for(train); @@ -118,7 +121,7 @@ void TrainRouter::route_changed() if(!sequence_points.empty()) { const SequencePoint &sp = sequence_points.front(); - if(sp.block==fncb.block() && !sp.is_cleared()) + if(sp.block==fncb.block() && sp.preceding_train) { arrival = WAITING_FOR_SEQUENCE; sequence_check_pending = true; @@ -225,24 +228,28 @@ void TrainRouter::message(const Message &msg) void TrainRouter::tick(const Time::TimeDelta &dt) { - if(delay) - { - delay -= dt; - if(delaycheck()!=TrainRoutePlanner::PENDING) apply_plan(train.get_layout(), *planner); + Layout &layout = train.get_layout(); + if(!layout.get_driver().is_halted() && !layout.get_clock().is_stopped()) + { + if(delay) + { + delay -= dt; + if(delay routers; get_routers(layout, routers);