]> git.tdb.fi Git - r2c2.git/commitdiff
Don't eat away departure delay while halted
authorMikko Rasa <tdb@tdb.fi>
Fri, 13 Feb 2015 00:50:36 +0000 (02:50 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 13 Feb 2015 00:50:36 +0000 (02:50 +0200)
source/libr2c2/trainrouter.cpp

index a5a63b4f7754f18f7f688616696a3a4a924359ae..4a5c2bb084a43ce6977d6145f448027364a34aba 100644 (file)
@@ -1,3 +1,4 @@
+#include "driver.h"
 #include "layout.h"
 #include "route.h"
 #include "trackiter.h"
@@ -225,24 +226,27 @@ void TrainRouter::message(const Message &msg)
 
 void TrainRouter::tick(const Time::TimeDelta &dt)
 {
-       if(delay)
-       {
-               delay -= dt;
-               if(delay<Time::zero)
-               {
-                       duration = max(duration+delay, Time::zero);
-                       delay = Time::zero;
-               }
-       }
-       else if(duration)
-               duration = max(duration-dt, Time::zero);
-
        if(waypoints_changed && !planner)
                start_planning(train.get_layout());
 
        if(planner && planner->check()!=TrainRoutePlanner::PENDING)
                apply_plan(train.get_layout(), *planner);
 
+       if(!train.get_layout().get_driver().is_halted())
+       {
+               if(delay)
+               {
+                       delay -= dt;
+                       if(delay<Time::zero)
+                       {
+                               duration = max(duration+delay, Time::zero);
+                               delay = Time::zero;
+                       }
+               }
+               else if(duration)
+                       duration = max(duration-dt, Time::zero);
+       }
+
        if(sequence_check_pending)
        {
                if(sequence_points.front().is_cleared())