- for(BlockList::iterator i=blocks.begin(); i!=cur_blocks_end; ++i)
- if(i->block()==&block)
- {
- if(++i!=cur_blocks_end)
- release_blocks_begin(i);
- return;
- }
-}
-
-bool BlockAllocator::release_from(const Block &block)
-{
- bool have_sensor = false;
- for(BlockList::iterator i=cur_blocks_end; i!=blocks.end(); ++i)
- {
- if(i->block()==&block)
- {
- if(have_sensor)
- release_blocks_end(i);
- return have_sensor;
- }
- else if((*i)->get_sensor_id())
- have_sensor = true;
- }
-
- return false;
-}
-
-void BlockAllocator::release_noncurrent()
-{
- release_blocks_end(cur_blocks_end);
+ BlockList::iterator end;
+ if(block)
+ end = find_if(cur_blocks_end, blocks.end(), BlockMatch(*block));
+ else
+ end = blocks.end();
+
+ SetFlag setf(advancing);
+ BlockList::iterator i = cur_blocks_end;
+ // Update cur_blocks_end first to keep things consistent.
+ cur_blocks_end = end;
+ for(; i!=end; ++i)
+ train.signal_advanced.emit(**i);