X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.cpp;h=e9c170c1ccb7140911666f3ca3704892a440af90;hb=c47f3fad07af11210c9cbd65d87964794189065e;hp=9a9164ea292770380548aea3a2c517ac4fbe327d;hpb=6dc18b0e518407bd2a86602bae1e9bbae05da7c8;p=r2c2.git diff --git a/source/libmarklin/block.cpp b/source/libmarklin/block.cpp index 9a9164e..e9c170c 100644 --- a/source/libmarklin/block.cpp +++ b/source/libmarklin/block.cpp @@ -68,7 +68,7 @@ int Block::get_endpoint_by_link(const Block &other) const return -1; } -int Block::traverse(unsigned epi, float *len) const +unsigned Block::traverse(unsigned epi, float *len) const { if(epi>=endpoints.size()) throw InvalidParameterValue("Endpoint index out of range"); @@ -93,17 +93,14 @@ int Block::traverse(unsigned epi, float *len) const if(len) *len += track->get_type().get_path_length(cur_path); - int other_ep = track->traverse(track_ep, cur_path); - if(other_ep<0) - return -1; - + unsigned other_ep = track->traverse(track_ep, cur_path); for(unsigned i=0; i(other_ep)) return i; Track *next = track->get_link(other_ep); - if(tracks.count(next)==0) - return -1; + if(!tracks.count(next)) + throw LogicError("Block traversal strayed out of the block"); track_ep = next->get_endpoint_by_link(*track); track = next; }