]> git.tdb.fi Git - r2c2.git/commitdiff
Count reserved distance correctly in reverse direction
authorMikko Rasa <tdb@tdb.fi>
Sun, 30 Jun 2013 20:19:38 +0000 (23:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 30 Jun 2013 20:19:38 +0000 (23:19 +0300)
source/libr2c2/train.cpp

index 4f6c2046d7d9e0528158bc5d5c6af560816e3cd0..25dcae97da9580cea1946315674fb9bd36c5c3ed 100644 (file)
@@ -490,8 +490,7 @@ float Train::get_reserved_distance_until(const Block *until_block) const
        if(!track)  // XXX Probably unnecessary
                return 0;
 
-       BlockIter block = track.block_iter();
-       if(&*block==until_block)
+       if(&track->get_block()==until_block)
                return 0;
 
        // Account for the vehicle's offset on its current track
@@ -502,6 +501,8 @@ float Train::get_reserved_distance_until(const Block *until_block) const
                result = track->get_type().get_path_length(track->get_active_path())-result;
        result -= veh.get_type().get_length()/2;
 
+       BlockIter block = track.block_iter();
+
        // Count remaining distance in the vehicle's current block
        for(track=track.next(); &track->get_block()==&*block; track=track.next())
                result += track->get_type().get_path_length(track->get_active_path());