From e81351269ddecee26368bf8eed410b5ac01999ba Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 26 Mar 2014 22:32:30 +0200 Subject: [PATCH] Drop waypoints once the train has fully covered them --- source/libr2c2/trainrouter.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index da3b7d5..7ed9099 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -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(); -- 2.45.2