]> git.tdb.fi Git - r2c2.git/commitdiff
Immediately process sequence points that are already covered
authorMikko Rasa <tdb@tdb.fi>
Fri, 6 Feb 2015 14:23:05 +0000 (16:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Fri, 6 Feb 2015 14:48:14 +0000 (16:48 +0200)
The planner starts from the front buffer of the train, so it may generate
sequence points in the existing critical blocks.

source/libr2c2/trainrouter.cpp

index cef98eebbe46c3a5793579b168d970e4e6734957..38027dbe896942f6b232b1abcd565393a99d9ca5 100644 (file)
@@ -77,6 +77,7 @@ void TrainRouter::route_changed()
                can't rely on the resync code in block_reserved since we may need to
                clear the stop marker to continue allocation. */
                TrackIter track = train.get_block_allocator().first().track_iter();
+               list<SequencePoint>::iterator seq_begin = sequence_points.begin();
                for(; track; track=track.next())
                {
                        if(!advance_to_track(reserving_route, track))
@@ -86,7 +87,15 @@ void TrainRouter::route_changed()
                        }
                        if(&track->get_block()==fncb.block())
                                break;
+
+                       if(seq_begin!=sequence_points.end() && seq_begin->block==&track->get_block())
+                       {
+                               current_sequence = seq_begin->sequence_out;
+                               ++seq_begin;
+                       }
                }
+
+               sequence_points.erase(sequence_points.begin(), seq_begin);
        }
 
        if(!already_at_end)