- /* There's another train ahead of us. If it wants to exit the block
- from the same endpoint we're trying to enter from or the other way
- around, treat it as coming towards us. Otherwise treat it as going
- in the same direction. */
- int other_entry = other_train->get_entry_to_block(*b_iter_next);
- if(other_entry<0)
- throw logic_error("block reservation inconsistency");
-
- unsigned exit = b_iter_next.reverse().entry();
- unsigned other_exit = BlockIter(b_iter_next.block(), other_entry).reverse().entry();
- bool entry_conflict = (b_iter_next.entry()==other_exit);
- bool exit_conflict = (exit==static_cast<unsigned>(other_entry));
- // TODO: speed matching with preceding train
-
- // XXX Should invent a better way to get our counterpart from the other train
- TrainRouter *other_router = dynamic_cast<TrainRouter *>(other_train->get_tagged_ai("router"));
- int other_prio = (other_router ? other_router->get_priority() : 0);
-
- if(!entry_conflict && !exit_conflict && other_prio<priority)
- {
- /* Ask a lesser priority train going to the same direction to free
- the block for us */
- other_train->free_block(*b_iter_next);
- }
- else if(other_train!=yielding_to && (other_prio<priority || (other_prio==priority && entry_conflict)))