X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainpanel.cpp;h=cc53499050a419b7c647b76f36d908516b11ba14;hb=e13742268b7030f8d6152858d39f1c6b43f94c88;hp=c1fc1d9cac6c74109b2a8393a85b6f82411adb5e;hpb=2029c5e4220e0809a39744a28ca9e2ff22e8ad28;p=r2c2.git diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index c1fc1d9..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" @@ -262,14 +263,15 @@ void TrainPanel::place(Track *track, unsigned ep) { pick_conn.disconnect(); - Block &block = engineer.get_layout().get_block_by_track(*track); + 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"); }