From 4478cbc5af4112238d5c579a0404938569f151df Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 3 Feb 2015 17:58:16 +0200 Subject: [PATCH] Avoid creating needlessly long lead routes Mostly a cosmetic fix. --- source/libr2c2/trainrouter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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); -- 2.45.2