From: Mikko Rasa Date: Wed, 26 Mar 2014 20:32:30 +0000 (+0200) Subject: Drop waypoints once the train has fully covered them X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e81351269ddecee26368bf8eed410b5ac01999ba;p=r2c2.git Drop waypoints once the train has fully covered them --- 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();