X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrainrouter.cpp;h=65a4a24500206cb0286a1f5cb3da4efc22358c7c;hb=1124a98ce5e1edee1904eeec089976d446601afd;hp=b5a5bef11f674f3301a36c1304558bc63b2bc8fa;hpb=b28062f2dc88e082ee5a28b2e1f7c4c8bd989023;p=r2c2.git diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index b5a5bef..65a4a24 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -57,6 +57,14 @@ bool TrainRouter::set_route(const Route *r) train.stop_at(0); arriving = 0; + /* TODO destination should also be cleared when manually setting a different + route, but not when the planner calls this. */ + if(!r) + { + dest_zone = 0; + dest_block = 0; + } + train.refresh_blocks_from(*fncb); const Route *route = get_route(); @@ -110,6 +118,12 @@ bool TrainRouter::is_destination(Track &track) const return false; } +void TrainRouter::set_departure_delay(const Time::TimeDelta &d) +{ + delay = d; + update_pending = true; +} + void TrainRouter::message(const Message &msg) { if(msg.type=="set-route") @@ -135,10 +149,19 @@ void TrainRouter::message(const Message &msg) else set_destination(*msg.value.value()); } + else if(msg.type=="set-departure-delay") + set_departure_delay(msg.value.value()); } -void TrainRouter::tick(const Time::TimeDelta &) +void TrainRouter::tick(const Time::TimeDelta &dt) { + if(delay) + { + delay -= dt; + if(delay<=Time::zero) + delay = Time::zero; + } + if(update_pending) create_plans(train.get_layout());