X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fblock.cpp;h=94be126c77d088c1b44ba63303a99253a0338957;hb=3df8cb5c78fbb0b919bcb79677c6c788b8028482;hp=3ca744ca0c287796396263c825130977be3e4e7f;hpb=25b79ab38c2be2e5c89b8240504f641fd9c4899c;p=r2c2.git diff --git a/source/libmarklin/block.cpp b/source/libmarklin/block.cpp index 3ca744c..94be126 100644 --- a/source/libmarklin/block.cpp +++ b/source/libmarklin/block.cpp @@ -1,13 +1,19 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + +#include #include "control.h" #include "block.h" #include "tracktype.h" #include "trafficmanager.h" #include "turnout.h" -using namespace Msp; - -#include using namespace std; +using namespace Msp; namespace Marklin { @@ -31,7 +37,7 @@ Block::Block(TrafficManager &tm, Track &start): for(unsigned i=0; iget_sensor_id()==sensor_id) + if(links[i]->get_sensor_id()==sensor_id && !links[i]->get_turnout_id() && !track->get_turnout_id()) { queue.push_back(links[i]); tracks.insert(links[i]); @@ -93,11 +99,10 @@ int Block::traverse(unsigned epi, float *len) const return i; Track *next=track->get_link(other_ep); + if(tracks.count(next)==0) + return -1; track_ep=next->get_endpoint_by_link(*track); track=next; - - if(tracks.count(track)==0) - return -1; } } @@ -129,10 +134,6 @@ bool Block::reserve(const Train *t) if(!t || !train) { train=t; - if(train) - cout<<"Block "<get_name()<<'\n'; - else - cout<<"Block "<