+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2006-2008 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
#include "control.h"
#include "block.h"
#include "tracktype.h"
return -1;
}
-int Block::traverse(unsigned epi) const
+int Block::traverse(unsigned epi, float *len) const
{
if(epi>=endpoints.size())
throw InvalidParameterValue("Endpoint index out of range");
Track *track=ep.track;
unsigned track_ep=ep.track_ep;
+ if(len)
+ *len=0;
+
while(1)
{
unsigned cur_route=0;
cur_route=turnout.get_route();
}
+ if(len)
+ *len+=track->get_type().get_route_length(cur_route);
+
int other_ep=track->traverse(track_ep, cur_route);
if(other_ep<0)
- return 0;
+ return -1;
for(unsigned i=0; i<endpoints.size(); ++i)
if(endpoints[i].track==track && endpoints[i].track_ep==static_cast<unsigned>(other_ep))
{
train=t;
if(train)
- cout<<"Block "<<this<<" reserved for train "<<train<<'\n';
+ cout<<"Block "<<this<<" reserved for train "<<train->get_name()<<'\n';
else
cout<<"Block "<<this<<" freed\n";
trfc_mgr.signal_block_reserved.emit(*this, train);