From: Mikko Rasa Date: Tue, 3 Feb 2015 15:58:16 +0000 (+0200) Subject: Avoid creating needlessly long lead routes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=4478cbc5af4112238d5c579a0404938569f151df;p=r2c2.git Avoid creating needlessly long lead routes Mostly a cosmetic fix. --- diff --git a/source/libr2c2/trainrouter.cpp b/source/libr2c2/trainrouter.cpp index a0f30e9..1c05f82 100644 --- a/source/libr2c2/trainrouter.cpp +++ b/source/libr2c2/trainrouter.cpp @@ -437,16 +437,16 @@ Route *TrainRouter::create_lead_route(Route *lead, const Route *target) lead->set_temporary(true); } - bool target_reached = false; - for(TrackIter i=train.get_block_allocator().first().track_iter(); i; i=i.next()) + bool target_tracks = 0; + for(TrackIter i=train.get_block_allocator().first().track_iter(); (target_tracks<2 && i); i=i.next()) { if(i->get_block().get_train()!=&train) break; if(target) { if(target->has_track(*i)) - target_reached = true; - else if(target_reached) + ++target_tracks; + else if(target_tracks>0) break; } lead->add_track(*i);