]> git.tdb.fi Git - r2c2.git/commitdiff
Avoid creating needlessly long lead routes
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:58:16 +0000 (17:58 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 15:58:16 +0000 (17:58 +0200)
Mostly a cosmetic fix.

source/libr2c2/trainrouter.cpp

index a0f30e92ae43d9a7f2bde2a6a85046245d836dfa..1c05f829906ee7933432a80709927acf864751b1 100644 (file)
@@ -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);