X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.cpp;h=e8e367f7255715dc3c7ac2343763ae7da11021bf;hb=8e3009751ee81e0e5312cae53ee844bdd9e49628;hp=b9b65ad710dca9dd833177ee993b31562c3c4b5b;hpb=c400ed779704cc802de977090594c3441c3e7093;p=r2c2.git diff --git a/source/libmarklin/block.cpp b/source/libmarklin/block.cpp index b9b65ad..e8e367f 100644 --- a/source/libmarklin/block.cpp +++ b/source/libmarklin/block.cpp @@ -84,6 +84,14 @@ bool Block::has_track(Track &t) const return tracks.count(&t); } +const Block::Endpoint &Block::get_endpoint(unsigned i) const +{ + if(i>=endpoints.size()) + throw InvalidParameterValue("Endpoint index out of range"); + + return endpoints[i]; +} + int Block::get_endpoint_by_link(Block &other) const { for(unsigned i=0; iget_turnout_id() && route) - path = route->get_turnout(t_iter->get_turnout_id()); - if(path==-1) - path = t_iter->get_active_path(); - + unsigned path = (route ? route->get_path(*t_iter) : t_iter->get_active_path()); result += t_iter->get_type().get_path_length(path); t_iter = t_iter.next(path); @@ -168,7 +171,7 @@ bool Block::reserve(Train *t) void Block::find_paths(TrackIter track, unsigned path) { - unsigned mask = track->get_type().get_endpoints()[track.entry()].paths; + unsigned mask = track.endpoint().paths; for(unsigned i=0; mask>>i; ++i) if(mask&(1<