question: protected void ensureRouteConsecutivity ( ) { boolean deAllocateRestOfRoute = false ; for ( int i = _idxCurrentOrder + 1 ; i < _orders . size ( ) ; i ++ ) { log . debug ( _trainName + " ensureRouteConsecutivity for loop #" + i ) ; BlockOrder bo = getBlockOrderAt ( i ) ; OBlock block = bo . getBlock ( ) ; if ( ! block . isAllocatedTo ( this ) || ( block . getState ( ) & OBlock . OCCUPIED ) != 0 ) { deAllocateRestOfRoute = true ; } if ( deAllocateRestOfRoute ) { if ( block . isAllocatedTo ( this ) ) { log . info ( _trainName + " deallocating " + block . getDisplayName ( ) + " due to risk of deadlock" ) ; block . deAllocate ( this ) ; } } } }
target:  This should not be necessary, but it turns out that if three or more trains are running on a small layout,  at some point in time a deadlock will occur where more trains want to run on the same line in the same direction, but the train behind have allocated a block ahead of the front train. The task of this function is therefore to deallocate any such block.