X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.cpp;h=780ee1bbd293e75a9e442f6a83a80c8a38a28f26;hb=2029c5e4220e0809a39744a28ca9e2ff22e8ad28;hp=aa16fffc6ba5b6e3f04879f0e3d5fdb206b809c3;hpb=39d3db437ae419bf8195d33422d5ee38962175aa;p=r2c2.git diff --git a/source/libmarklin/block.cpp b/source/libmarklin/block.cpp index aa16fff..780ee1b 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; @@ -71,7 +72,12 @@ Block::~Block() layout.remove_block(*this); } -int Block::get_endpoint_by_link(const Block &other) const +bool Block::has_track(Track &t) const +{ + return tracks.count(&t); +} + +int Block::get_endpoint_by_link(Block &other) const { for(unsigned i=0; i=endpoints.size()) throw InvalidParameterValue("Endpoint index out of range"); @@ -94,7 +105,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);