}
else if(end_of_route)
set_route(0);
+
+ if(!cur_blocks.empty() && !cur_blocks.front().block->get_sensor_id())
+ {
+ Vehicle &veh = *(reverse ? vehicles.front() : vehicles.back());
+
+ list<BlockRef>::iterator i = cur_blocks.begin();
+ const Block::Endpoint &bep = i->block->get_endpoints()[i->entry];
+
+ Track *track = bep.track;
+ unsigned entry = bep.track_ep;
+
+ bool found = false;
+ float dist = veh.get_offset()-veh.get_type().get_length()/2;
+ while(1)
+ {
+ if(track==veh.get_track())
+ {
+ found = true;
+ break;
+ }
+
+ if(i!=cur_blocks.begin())
+ {
+ float path_len = track->get_type().get_path_length(track->get_active_path());
+ dist += path_len;
+ }
+
+ unsigned exit = track->traverse(entry);
+ Track *next = track->get_link(exit);
+ entry = next->get_endpoint_by_link(*track);
+ track = next;
+
+ if(!i->block->get_tracks().count(track))
+ {
+ ++i;
+ if(i==cur_blocks.end())
+ break;
+ }
+ }
+
+ if(found && i!=cur_blocks.begin() && dist>10*layout.get_catalogue().get_scale())
+ {
+ cur_blocks.front().block->reserve(0);
+ cur_blocks.erase(cur_blocks.begin());
+ }
+ }
}
void Train::save(list<DataFile::Statement> &st) const
if(layout.get_driver().get_sensor(i->block->get_sensor_id()))
break;
else
+ {
end = i;
+ ++end;
+ }
}
if(end!=cur_blocks.begin())
- {
// Free blocks up to the last inactive sensor
- ++end;
release_blocks(cur_blocks, cur_blocks.begin(), end);
- }
}
}