X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.cpp;h=db1942bb5b613fde7ff1b71272383455740bc875;hb=97443d96ff3ce51388d2edd1e0dca8f2cd231346;hp=aa16fffc6ba5b6e3f04879f0e3d5fdb206b809c3;hpb=39d3db437ae419bf8195d33422d5ee38962175aa;p=r2c2.git diff --git a/source/libmarklin/block.cpp b/source/libmarklin/block.cpp index aa16fff..db1942b 100644 --- a/source/libmarklin/block.cpp +++ b/source/libmarklin/block.cpp @@ -8,6 +8,7 @@ Distributed under the GPL #include #include "block.h" #include "layout.h" +#include "route.h" #include "tracktype.h" using namespace std; @@ -81,6 +82,11 @@ int Block::get_endpoint_by_link(const Block &other) const } unsigned Block::traverse(unsigned epi, float *len) const +{ + return traverse(epi, 0, len); +} + +unsigned Block::traverse(unsigned epi, const Route *route, float *len) const { if(epi>=endpoints.size()) throw InvalidParameterValue("Endpoint index out of range"); @@ -94,7 +100,11 @@ unsigned Block::traverse(unsigned epi, float *len) const while(1) { - unsigned cur_path = track->get_active_path(); + int cur_path = -1; + if(track->get_turnout_id() && route) + cur_path = route->get_turnout(track->get_turnout_id()); + if(cur_path==-1) + cur_path = track->get_active_path(); if(len) *len += track->get_type().get_path_length(cur_path);