]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/aicontrol.cpp
Copy speed only if the preceding train is active
[r2c2.git] / source / libr2c2 / aicontrol.cpp
index 782993752ab94cd504261b5522a7211b936b92b5..59126d8505b193cafea380401b5c7db0edf3ffc4 100644 (file)
@@ -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;
 
@@ -124,7 +124,7 @@ void AIControl::tick(const Time::TimeDelta &dt)
                        speed_limit = 0;
                else if(state==APPROACH)
                        speed_limit = approach_speed;
-               else if(state==FOLLOW)
+               else if(state==FOLLOW && train.get_preceding_train()->is_active())
                        speed_limit = train.get_preceding_train()->get_speed();
 
                if(speed_limit>=0 && target_speed.value>speed_limit)