X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fengineer%2Ftrainpanel.cpp;h=96aa00df6de1816a3cbea78cb50d22570e965d28;hb=bd649cbc44e04f5e456ca19b7a32ebe479c130e1;hp=922e3741e272183abad52382f4255ce08c6fbfe3;hpb=fcaa883538f98bac71ba1a90f98950bb2aa08d88;p=r2c2.git diff --git a/source/engineer/trainpanel.cpp b/source/engineer/trainpanel.cpp index 922e374..96aa00d 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.get_tracks().count(track)) - break; - } + + iter = iter.flip().reverse(); } }