]> git.tdb.fi Git - r2c2.git/commitdiff
Avoid going past the end of route when a new one is set
authorMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 14:23:01 +0000 (16:23 +0200)
committerMikko Rasa <tdb@tdb.fi>
Tue, 3 Feb 2015 14:23:01 +0000 (16:23 +0200)
Calling stop_at(0) causes the block allocator to immediately resume
allocating blocks.  In certain circumstances this would cause an
allocation past the end of the route.

source/libr2c2/trainrouter.cpp

index ca3e93d97d6f8b7126c10fa64f3c8aa212b00463..d1cb6ff4a3a9b8eca35c439edcf8db3258e6e17b 100644 (file)
@@ -111,8 +111,9 @@ void TrainRouter::route_changed()
        {
                // We are not at the end of the route now, but might have been before.
                arrival = ON_THE_WAY;
-               train.stop_at(0);
                train.refresh_blocks_from(*fncb);
+               if(!arrival)
+                       train.stop_at(0);
        }
        else if(!arrival)
        {