X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrackiter.cpp;h=330e2f66c810bd9ee2c38cd0c6f2f1ebd14ae6d7;hb=02453a447bad0ecc2a71e00b9578c9afaee0eadb;hp=64d223e21cc3ce6142061ab7efc670e3fbd715f5;hpb=32316772d422223827833366a7ee2d0a76d76ff1;p=r2c2.git diff --git a/source/libr2c2/trackiter.cpp b/source/libr2c2/trackiter.cpp index 64d223e..330e2f6 100644 --- a/source/libr2c2/trackiter.cpp +++ b/source/libr2c2/trackiter.cpp @@ -30,27 +30,31 @@ BlockIter TrackIter::block_iter() const Block &block = _track->get_block(); const vector &beps = block.get_endpoints(); - if(_track->get_type().is_turnout()) - { - /* A turnouts is the only track in its block. Go ahead and find the - matching endpoint in the block. */ - for(unsigned i=0; iget_type().is_turnout()) { - TrackIter rev = reverse(); + /* Since there was no endpoint match, the preceding track can't be in a + different block. */ + TrackIter rev = flip(); + TrackIter last; while(rev && &rev.track()->get_block()==&block) { - TrackIter fwd = rev.reverse(); - - for(unsigned i=0; iget_type().coerce_path(_entry, path); const vector &eps = _track->get_type().get_endpoints(); // Find an endpoint that's connected to the entry and has the requested path for(unsigned i=0; iget_link(exit); - result._entry = (result._track ? result._track->get_endpoint_by_link(*_track) : 0); + result._entry = (result._track ? result._track->get_link_slot(*_track) : 0); return result; } @@ -127,7 +132,7 @@ TrackIter TrackIter::flip() const TrackIter result; result._track = _track->get_link(_entry); - result._entry = (result._track ? result._track->get_endpoint_by_link(*_track) : 0); + result._entry = (result._track ? result._track->get_link_slot(*_track) : 0); return result; }