]> git.tdb.fi Git - r2c2.git/commitdiff
Drop waypoints once the train has fully covered them
authorMikko Rasa <tdb@tdb.fi>
Wed, 26 Mar 2014 20:32:30 +0000 (22:32 +0200)
committerMikko Rasa <tdb@tdb.fi>
Wed, 26 Mar 2014 20:32:30 +0000 (22:32 +0200)
source/libr2c2/trainrouter.cpp

index da3b7d515fe253b79db3412ea0e98d2bd062d6ea..7ed90992457a1a329fe12b815fa859ee2997eec5 100644 (file)
@@ -242,6 +242,25 @@ void TrainRouter::train_advanced(Block &block)
                }
        }
 
+       if(!waypoints.empty())
+       {
+               const TrackChain &wp = *waypoints.front();
+               TrackIter t_iter = b_iter.track_iter();
+               if(wp.has_track(*t_iter))
+               {
+                       for(; t_iter; t_iter=t_iter.next())
+                       {
+                               if(!wp.has_track(*t_iter))
+                               {
+                                       waypoints.erase(waypoints.begin());
+                                       break;
+                               }
+                               else if(!block.has_track(*t_iter))
+                                       break;
+                       }
+               }
+       }
+
        if(!routes.empty())
        {
                b_iter = b_iter.next();