summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2fe7cbc)
Don't crash if rsv_blocks is empty at the end of reserve_more
while(nsens<2)
{
int exit = last->block->traverse(last->entry);
while(nsens<2)
{
int exit = last->block->traverse(last->entry);
+ if(exit<0)
+ break;
+
+ Block *link = last->block->get_link(exit);
+ if(!link || !link->reserve(this))
+ break;
+
+ if(route && link->get_turnout_id())
- Block *link = last->block->get_link(exit);
- if(link && link->reserve(this))
- {
- if(route && link->get_turnout_id())
- {
- int path = route->get_turnout(link->get_turnout_id());
- if(path>=0)
- trfc_mgr.get_control().get_turnout(link->get_turnout_id()).set_path(path);
- }
- rsv_blocks.push_back(BlockRef(link, link->get_endpoint_by_link(*last->block)));
- last = &rsv_blocks.back();
- if(last->block->get_sensor_id())
- {
- ++nsens;
- result = true;
- }
- }
- else
- break;
+ int path = route->get_turnout(link->get_turnout_id());
+ if(path>=0)
+ trfc_mgr.get_control().get_turnout(link->get_turnout_id()).set_path(path);
+ }
+ rsv_blocks.push_back(BlockRef(link, link->get_endpoint_by_link(*last->block)));
+ last = &rsv_blocks.back();
+ if(last->block->get_sensor_id())
+ {
+ ++nsens;
+ result = true;
- while(last && !last->block->get_sensor_id())
+ while(!rsv_blocks.empty() && !last->block->get_sensor_id())
{
last->block->reserve(0);
rsv_blocks.erase(--rsv_blocks.end());
{
last->block->reserve(0);
rsv_blocks.erase(--rsv_blocks.end());