X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainpanel.cpp;h=cc53499050a419b7c647b76f36d908516b11ba14;hb=e13742268b7030f8d6152858d39f1c6b43f94c88;hp=a0dbbeef3890e345b773344f78c4c8d87ce6d8bd;hpb=f74ce147edde73319e55475433adb8e1d87b7201;p=r2c2.git diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index a0dbbee..cc53499 100644 --- a/source/engineer/trainpanel.cpp +++ b/source/engineer/trainpanel.cpp @@ -8,6 +8,7 @@ Distributed under the GPL #include #include #include "libmarklin/timetable.h" +#include "libmarklin/trackiter.h" #include "libmarklin/vehicletype.h" #include "engineer.h" #include "routeselect.h" @@ -263,13 +264,14 @@ void TrainPanel::place(Track *track, unsigned ep) pick_conn.disconnect(); Block &block = track->get_block(); + TrackIter iter(track, ep); - while(1) + while(block.has_track(*iter)) { const vector &eps = block.get_endpoints(); bool ok = false; for(unsigned i=0; (!ok && iget_links()[ep]; - ep = next->traverse(next->get_endpoint_by_link(*track), 0); - track = next; - if(!block.has_track(*track)) - break; - } + + iter = iter.flip().reverse(); } } @@ -292,12 +288,6 @@ void TrainPanel::go_to(Track *track, unsigned) { pick_conn.disconnect(); - try - { - train.go_to(*track); - } - catch(const Exception &e) - { - engineer.set_status(e.what()); - } + if(!train.go_to(*track)) + engineer.set_status("Could not set route"); }