News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Two-ways signals

Started by Nazalassa, April 29, 2026, 04:07:15 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nazalassa

Makes it possible for trains to ignore some signals when they go in the opposite direction, rather than blocking them. This could be useful at junctions, or on single-tracked lines (e.g choose signal at the end). Each signal can do either this or the default behaviour through a new checkbox in the signal info window.

Examples:
two_ways_signals_scr.png  two-ways-signals-scr-2.png
Making paks since October 2023  |  pak48.bitlit | pak32.box | MLM for pak64 | Empire F7 cars | Pneumatic tubes | More pak64 vehicles and industries

Life is like a multi-tasking OS: you know you'll eventually get back to everything, but you don't know when.

poppo

Interesting :) .
I'd like to ask a few questions and make some suggestions (just my personal opinion).
  • How does a signal behave when placed on a railroad switch? And can we edit the signal-running direction on the railroad switch?
  • Is a choose signal of the opposite direction placed after a choose signal found in route_t::find_route()? (It should not be.)
  • Is it possible to place different signals on the opposite sides of the same tile?
    (I know that current signal system doesn't allow this. But I think it would be more useful if, on a single-track line, one direction could be set to "choose" while the other could be set to "longblock" or "pre-signal".)

prissi

You mean that a single direction signal should no block traffic in the other direction? This is dangerous territorium.

How is this useful for junctions?

As for choose signals, if a train is waiting at a choose signal, the other train can still not go through this train since it reserves the track. And end_of _choose sign would have the same effect without this patch.

As to the above questions, a second choose signal will revert the first signal to a normal signal.
Signals on switches are not allowed in the first place. They can be made, buit are anyway no supported officially.

Nazalassa

#3
First, remind that this is per-signal configuration and is disabled by default: for a signal to allow traffic in the other direction this must explicitely be enabled in the signal's info window.

I noticed signals with two-ways enabled are not ignored when looking for signals in the choose signal's preliminary checks, here's a patch that fixes that.

This could be useful on single tracks that branch from a line (e.g service to industries) because this is now possible:

==================mainline====
 signal -> |-o
           \____[station]


Trains from the mainline entering the branch will ignore the signal and must reserve all of it, whereas trains leaving the branch will first go to the signal and then attempt to reserve their way on the mainline. Using a bidirectional signal instead of a unidirectional one with two-ways enabled means trains may enter the branch while it is not free and then stop at the signal, preventing the train inside from leaving and causing deadlocks.
The current workaround to this is building a short double-track section at the beginning of the branch.


Regarding junctions, I was also considering implementing a "crossing" signal that only reserves the few next tiles of track at the last moment (when the train checks whether the signal is clear) instead of when the train reserves its route. Example:  (x = reserved track)

train    ǫ | |    .---.     Only reserve when next to signal             ǫ | |    .---.
<==>xxxxxxx+-+xxxxxxxx-*--              ------>                 -----<==>xxxxxxxxxxxxx-*--
           | |                                                             | |


the bit in the middle is only reserved when the train arrives at the signal. This way it is possible to have single-track lines cross other lines without risking deadlocks.
But such a "crossing" signal would require allowing traffic in the opposite direction to be useful on single tracks.

(I probably meant "crossing" instead of "junction". But then there are often junctions near crossings.)
Making paks since October 2023  |  pak48.bitlit | pak32.box | MLM for pak64 | Empire F7 cars | Pneumatic tubes | More pak64 vehicles and industries

Life is like a multi-tasking OS: you know you'll eventually get back to everything, but you don't know when.

poppo

It would be helpful if end_of_choose could also specify the "end of choose" direction

poppo

By the way, for a single-track line, you can simply make a choose signal that allows traffic in both directions just before the station and a pre-signal on the platform.

However, since longblock signals cannot be used with choose signal in this case, the proposed feature would indeed improve practicality.

prissi

I do not see how a longblock signal would work together even with a one-directional choose signal. It will be impossible to determine if a route is free or not. Maybe the through route is free, because the train before chose another platform. But then the route is blocked as soon as it leaves, because the longblock signal only checks and not reserve the route.

poppo

-----[stop]----[stop]----|C>-<L|--[two-platform terminal with pre-signal]
like above situation, we cannot avoid deadlock in current version (without using departure time settings).

But if choose signal can only active for one-way, we can avoid this problem!

prissi

You cannot avoid a deadlock ever, as soon as a second train enters the section.

Longblock signals only work without deadlocks if there is never more than a single train in the single track section. So two platforms with longblock signals is a no go in any configuration, as the longblock signal from the entering side only checks one of the platforms and might not see a train on another one.

It can work with a situation when have an exit only longblock and an entry only choose as long as there are never more than two trains ever in this branch. Three train will deadlock, even with longblock and choose signals because a longblock signal stops checking at the last stop before reversing OR at any signal. So it will allow a third train to enter even if both platforms are occupied.