pending_block(0),
stop_at_block(0),
reserving(false),
- advancing(false)
+ advancing(false),
+ reserve_pending(false)
{
Layout &layout = train.get_layout();
layout.signal_block_reserved.connect(sigc::mem_fun(this, &BlockAllocator::block_reserved));
{
release_blocks_end(cur_blocks_end);
pending_block = 0;
+ reserve_pending = false;
}
}
return find_if(blocks.begin(), end, BlockMatch(block))!=cur_blocks_end;
}
+void BlockAllocator::tick()
+{
+ if(reserve_pending)
+ {
+ reserve_pending = false;
+ reserve_more();
+ }
+}
+
void BlockAllocator::reserve_more()
{
if(blocks.empty())
void BlockAllocator::turnout_path_changed(Track &track)
{
if(&track.get_block()==pending_block && !reserving)
- reserve_more();
+ reserve_pending = true;
}
void BlockAllocator::block_reserved(Block &block, const Train *tr)
{
if(&block==pending_block && !tr && !reserving)
- reserve_more();
+ reserve_pending = true;
}
void BlockAllocator::sensor_state_changed(Sensor &sensor, Sensor::State state)
advance_front(next_sensor);
if(active)
- reserve_more();
+ reserve_pending = true;
}
else if(!is_block_current(*block))
train.get_layout().emergency(block, "Sensor for "+train.get_name()+" triggered out of order");
st.push_back((DataFile::Statement("hint"), prev->get_id()));
- for(BlockList::const_iterator i=cur_blocks.begin(); i!=cur_blocks.end(); ++i)
+ for(BlockList::const_iterator i=cur_blocks.begin(); (i!=cur_blocks.end() && i->block()!=pending_block); ++i)
st.push_back((DataFile::Statement("block"), (*i)->get_id()));
}
}