X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrain.cpp;h=0cbe306234c09b11a9535f1e21fe71673e4bed2e;hb=90f9efba8d88f41c7a180734b7bcbdd1501d995e;hp=ffa436b1d6a0c07795bf876d304077bb08a80fcd;hpb=7e27b311e33beda1746eb63e0945633f262427f6;p=r2c2.git diff --git a/source/libr2c2/train.cpp b/source/libr2c2/train.cpp index ffa436b..0cbe306 100644 --- a/source/libr2c2/train.cpp +++ b/source/libr2c2/train.cpp @@ -48,6 +48,7 @@ Train::Train(Layout &l, const VehicleType &t, unsigned a, const string &p): protocol(p), priority(0), yielding_to(0), + preceding_train(0), cur_blocks_end(blocks.end()), clear_blocks_end(blocks.end()), pending_block(0), @@ -841,6 +842,7 @@ void Train::reserve_more() BlockIter start = blocks.back(); pending_block = 0; + preceding_train = 0; // See how many sensor blocks and how much track we already have unsigned nsens = 0; @@ -952,10 +954,15 @@ void Train::reserve_more() bool entry_conflict = (block.entry()==other_exit); bool exit_conflict = (exit==static_cast(other_entry)); if(!entry_conflict && !last->get_turnout_id()) + { /* The other train is not coming to the blocks we're holding, so we can keep them. */ good_end = blocks.end(); + if(static_cast(other_entry)==block.entry()) + preceding_train = other_train; + } + int other_prio = other_train->get_priority(); if(!entry_conflict && !exit_conflict && other_prio