X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fblockallocator.cpp;h=547415aa965173ad5eeb68fb0966eceb6aff000c;hb=18c529dfdd34e07f4f6021151ddce29fa85437bc;hp=347960ee2ec584029a7bc66dffaaabb56de0cdad;hpb=bc9e941447da48905295192289bc09483a678180;p=r2c2.git diff --git a/source/libr2c2/blockallocator.cpp b/source/libr2c2/blockallocator.cpp index 347960e..547415a 100644 --- a/source/libr2c2/blockallocator.cpp +++ b/source/libr2c2/blockallocator.cpp @@ -316,8 +316,9 @@ void BlockAllocator::advance_front(const Sensor *sensor) void BlockAllocator::advance_back() { - const Vehicle &veh = train.get_vehicle(train.get_controller().get_reverse() ? 0 : train.get_n_vehicles()-1); - const Block &veh_block = veh.get_track()->get_block(); + bool rev = train.get_controller().get_reverse(); + const Vehicle &veh = train.get_vehicle(rev ? 0 : train.get_n_vehicles()-1); + const Block &veh_block = veh.get_placement().get_position(rev ? VehiclePlacement::FRONT_AXLE : VehiclePlacement::BACK_AXLE)->get_block(); /* Sensors aren't guaranteed to be detriggered in order. Go through the block list and locate the first sensor that's still active. */