float brake_dist = next_ctrl->get_braking_distance();
float approach_margin = 50*scale;
float approach_speed = 5*scale;
- float margin = 10*scale;
+ float margin = 1*scale;
State old_state = state;
bool Train::free_block(Block &block)
{
- float margin = 10*layout.get_catalogue().get_scale();
- if(get_reserved_distance_until(&block, false)<controller->get_braking_distance()*1.3+margin)
+ if(get_reserved_distance_until(&block, false)<controller->get_braking_distance()*1.3)
return false;
unsigned nsens = 0;
float Train::get_reserved_distance() const
{
- return get_reserved_distance_until(0, false);
+ if(blocks.empty())
+ return 0;
+
+ float margin = 0;
+ TrackIter next = blocks.back().next().track_iter();
+ if(next->get_type().is_turnout())
+ margin = 15*layout.get_catalogue().get_scale();
+
+ return max(get_reserved_distance_until(0, false)-margin, 0.0f);
}
void Train::tick(const Time::TimeStamp &t, const Time::TimeDelta &dt)