From: Mikko Rasa Date: Fri, 18 Feb 2011 05:19:04 +0000 (+0000) Subject: Use different stopping margin depending on whether the next track is a turnout X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=dbaa67c30705a9993d2626cec588c7320f1eef17;p=r2c2.git Use different stopping margin depending on whether the next track is a turnout --- diff --git a/source/libr2c2/aicontrol.cpp b/source/libr2c2/aicontrol.cpp index 7829937..d1a69aa 100644 --- a/source/libr2c2/aicontrol.cpp +++ b/source/libr2c2/aicontrol.cpp @@ -100,7 +100,7 @@ void AIControl::tick(const Time::TimeDelta &dt) 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; diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index 218b686..122ea9b 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -443,8 +443,7 @@ void Train::unplace() bool Train::free_block(Block &block) { - float margin = 10*layout.get_catalogue().get_scale(); - if(get_reserved_distance_until(&block, false)get_braking_distance()*1.3+margin) + if(get_reserved_distance_until(&block, false)get_braking_distance()*1.3) return false; unsigned nsens = 0; @@ -534,7 +533,15 @@ int Train::get_entry_to_block(Block &block) const 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)