From: Mikko Rasa Date: Thu, 10 Apr 2014 19:04:03 +0000 (+0300) Subject: Use path coercion in track iterators X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=sidebyside;h=02453a447bad0ecc2a71e00b9578c9afaee0eadb;hp=30c14e235f19442753e5eeeb8a86cbc22960afb1;p=r2c2.git Use path coercion in track iterators This enforces common traversal rules in all places. It also fixes a bug in TrackOffsetIter where moving to a turnout from an endpoint not on the selected path would potentially cause an out-of-range iterator to be created. --- diff --git a/source/libr2c2/trackiter.cpp b/source/libr2c2/trackiter.cpp index da949e7..330e2f6 100644 --- a/source/libr2c2/trackiter.cpp +++ b/source/libr2c2/trackiter.cpp @@ -70,6 +70,7 @@ const TrackType::Endpoint &TrackIter::endpoint() const int TrackIter::get_exit(unsigned path) const { + path = _track->get_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 diff --git a/source/libr2c2/trackoffsetiter.cpp b/source/libr2c2/trackoffsetiter.cpp index 9676985..8f21e95 100644 --- a/source/libr2c2/trackoffsetiter.cpp +++ b/source/libr2c2/trackoffsetiter.cpp @@ -117,6 +117,7 @@ TrackOffsetIter TrackOffsetIter::advance(float d, const Route *r) const { if(p<0) p = (r ? r->get_path(*t) : t->get_active_path()); + p = t->get_type().coerce_path(t.entry(), p); float length = t->get_type().get_path_length(p); if(o