X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Fblockallocator.cpp;h=7e992e00f41b65f6aecdc6afd6e89ec03e899bd0;hb=7f63edbdf0d3c08893bdd2341ec3e50fb1ccc6f8;hp=5870a6d00474ccdcffa2478da7bb38ffc425e958;hpb=e8d2abb48b5236cc3455a035628292ae7908240e;p=r2c2.git diff --git a/source/libr2c2/blockallocator.cpp b/source/libr2c2/blockallocator.cpp index 5870a6d..7e992e0 100644 --- a/source/libr2c2/blockallocator.cpp +++ b/source/libr2c2/blockallocator.cpp @@ -354,6 +354,8 @@ void BlockAllocator::advance_back() 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(); + bool pending_cleared = false; + /* Sensors aren't guaranteed to be detriggered in order. Go through the block list and locate the first sensor that's still active. */ BlockList::iterator end = blocks.end(); @@ -387,6 +389,9 @@ void BlockAllocator::advance_back() end = i; } + if(block==pending_block) + pending_cleared = true; + // Stop if we encounter an active sensor or the train's last vehicle if(block==&veh_block || active_sensor) { @@ -399,6 +404,10 @@ void BlockAllocator::advance_back() release_blocks_begin(end); signal_rear_advanced.emit(*last()); } + + if(pending_cleared) + reserve_more(); + return; } }