Hey JGR,
thank you for maintaining the code! Are you open to "feature requests"?
I played around with the routing restrictions, especially the deny condition and I want it to force trains into a reverser. In vanilla this works with setting "rail_firstred_twoway_eol" to 1 and putting a twoway signal in the usual path of the train (like in
https://wiki.openttdcoop.org/images/9/9 ... rimary.png note the twoway exit signals where usually a PBS signal would be used)
Now I tried a remotely similar setup with slots and "deny" trains entering a section when they are not able to aqcuire a slot (and send them into a reverser and then into an overflow depot). But they tried to go on nevertheless and ended up blocking the way so I had to resort to the twoway signal thing again which does not integrate well into the slot setup so I wondered what the difference is between the red twoway and the routing restriction "deny" since I would like to get it working without abusing pre-signals and tracks as priorities again.
So I did a bit of digging in the pathfinder and found out that the twoway signal is using this code:
Code: Select all
if (!IsPbsSignal(sig_type) && Yapf().TreatFirstRedTwoWaySignalAsEOL() && n.flags_u.flags_s.m_choice_seen && has_signal_against && n.m_num_signals_passed == 0) {
/* yes, the first signal is two-way red signal => DEAD END. Prune this branch... */
Yapf().PruneIntermediateNodeBranch(&n);
n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
Yapf().m_stopped_on_first_two_way_signal = true;
return -1;
}
while the "deny" path is using this:
Code: Select all
if (out.flags & TRPRF_DENY) {
n.m_segment->m_end_segment_reason |= ESRB_DEAD_END;
return -1;
}
I then had a look at the function PruneIntermediateNodeBranch and found this comment:
Code: Select all
/**
* In some cases an intermediate node branch should be pruned.
* The most prominent case is when a red EOL signal is encountered, but
* there was a segment change (e.g. a rail type change) before that. If
* the branch would not be pruned, the rail type change location would
* remain the best intermediate node, and thus the vehicle would still
* go towards the red EOL signal.
*/
So adding Yapf().PruneIntermediateNodeBranch(&n) to the "deny" path might be a good way to "enforce" the deny, otherwise it seems only to heavily discourage a path instead of really preventing it (as the train still thinks it cannot reach its destination after passing the "deny").
I could also supply screenshots of my setup if that helps illustrating the issue.
Thanks for the consideration!