set_active(false);
accurate_position = false;
+ blocks.push_back(BlockIter(&block, entry));
if(!block.reserve(this))
+ {
+ blocks.pop_back();
return;
+ }
- blocks.push_back(BlockIter(&block, entry));
if(reverse)
{
TrackIter track = BlockIter(&block, entry).reverse().track_iter();
if(dist>10*layout.get_catalogue().get_scale())
{
- blocks.front()->reserve(0);
+ Block &block = *blocks.front();
blocks.pop_front();
+ block.reserve(0);
}
}
}
}
}
+ blocks.push_back(block);
bool reserved = block->reserve(this);
if(!reserved)
{
+ blocks.pop_back();
/* We've found another train. If it wants to exit the block from the
same endpoint we're trying to enter from or the other way around,
treat it as coming towards us. Otherwise treat it as going in the
/* Ask a lesser priority train going to the same direction to free
the block for us */
if(other_train->free_block(*block))
- reserved = block->reserve(this);
+ {
+ blocks.push_back(block);
+ if(!(reserved = block->reserve(this)))
+ blocks.pop_back();
+ }
}
else if(other_train!=yielding_to && (other_prio<priority || (other_prio==priority && entry_conflict)))
{
if(!contested_blocks.empty() && contested_blocks.front()==block)
contested_blocks.pop_front();
- blocks.push_back(block);
-
if(cur_blocks_end==blocks.end())
--cur_blocks_end;
if(clear_blocks_end==blocks.end())
if(entry<0)
entry = 0;
- blk->reserve(&obj);
obj.blocks.push_back(BlockIter(blk, entry));
+ blk->reserve(&obj);
if(blk->get_sensor_id())
obj.layout.get_driver().set_sensor(blk->get_sensor_id(), true);