X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fblockallocator.cpp;h=c9cc5b44440fe6987dff33fb0939cfbf4ca79363;hb=54392d65e2053d1eacb4cfcc435f1013993f2973;hp=ac840d3debfdfabb3b78c02eab31ed2120f0280f;hpb=ca9d278f9472206ad9a01190dcef9f0eb1bcc274;p=r2c2.git diff --git a/source/libr2c2/blockallocator.cpp b/source/libr2c2/blockallocator.cpp index ac840d3..c9cc5b4 100644 --- a/source/libr2c2/blockallocator.cpp +++ b/source/libr2c2/blockallocator.cpp @@ -30,12 +30,15 @@ BlockAllocator::BlockAllocator(Train &t): (*i)->signal_path_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &BlockAllocator::turnout_path_changed), sigc::ref(**i)))); } -void BlockAllocator::start_from(Block &block, unsigned entry) +void BlockAllocator::start_from(const BlockIter &block) { + if(!block) + throw invalid_argument("BlockAllocator::start_from"); + release_blocks(blocks.begin(), blocks.end()); - blocks.push_back(BlockIter(&block, entry)); - if(!block.reserve(&train)) + blocks.push_back(block); + if(!block->reserve(&train)) { blocks.pop_back(); return;