Rail Signal Planner


[QoL] Automatically place rail signals on rails and intersections.

Utilities
1 year, 8 months ago
0.17 - 1.1
23.4K
Logistics Trains

FAQ

How does this mod work‽

7 phases:

  1. Extending the network. It adds all blocks of the selected/build rails. Then it will recursively add blocks until all outbound signals of the network are chain signals, or have a stretch with no branches for <max-train-length> distance. Ghost signals are ignored during this phase. Here the initial state of all signals are saved.
  2. Marking rail direction. It will check all signals on rails of the network. If there is a single signal it will mark that side as "allowed" and the other as "disallowed". It will then propagate forward/backward along the network the "disallowed" flag (it will stop at merges/splits until all incoming branches are marked as "disallowed". Raising errors if it tries to mark something "allowed" that was already marked "disallowed" or vice versa.
    Once done all non marked sides are marked as "allowed"
  3. Placing signals and checking for overlaps. It tries to place signals everywhere where allowed and possible. Similar as the previous step propagating through the network starting at the signal positions that contained a signal originally. Once done it checks the amount of overlaps each (small) block contains.
    If there are overlaps then the inbound signals of that block are marked "entrance"and the outbound as "exit". The entrances are immediately changed to a chain signal
  4. Clearing exits. Starting from the exits it propagates forward. Removing all signals until an entrance is found, or the total rail length passed passes <max-train-length>. If an entrance is found it changes the exit signal to chain and removes the entrance signal. (This prevents a train stopping in an intersection)
  5. Cleaning up long stretches. In the following order it cleans up long stretches: exits (forward), entrances (backwards), original signals (both directions), others (forwards). Starting from a signal it removes signals for a <rail-signal-distance> distance. If it exceeds this distance it replaces the previous possible signal or if it reaches 0 it keeps that signal. It then recursively calls the clean up on the last possible signal.
  6. Ghostification. The original signals are restored, and marked for deconstruction/upgrade when needed. Signals that didn't have a on original signal are placed as ghosts.
  7. Revivication. If the signals were build while building rails, then all ghost and signals marked for deconstruction/upgrade that are within 3 times the player's reach distance are automatically placed/upgraded/deconstructed if the players inventory allows for it.

Does this mod place signals perfectly?

Almost. It will place chain signals before merges and signals when they are not always necessary. But that is the only imperfection. Adding checks for that is (for now) outside of the scope. It will only be a minor throughput issue.
The reason why that is done is in cases like this, which do require chain signals to prevent deadlocks.

Also in rare cases a signal is placed on for one direction, taking up the only spot left to divide a rail going in an other direction.

If there are signals placed where they shouldn't be (unless it is the scenarios mentioned here) or no signals where there should then, please report it as a bug.

Are deadlocks possible with this mod?

No. If all your rails are signalled with the planner, and you have set the maximum possible train in the settings, then deadlocks are not possible.
The mod will check for exits of intersections, and will clear all signals after this intersection for the length of your longest train, or until it finds an entrance to another crossing.
If you do find a deadlock, please report is as bug.

My length is set to <an odd number>, but the rails are placed after every <even number>, how come?

During the "detect overlaps" phase, signals are placed where-ever possible. Since two signals can't be 1 distance apart, most signals will be a distance of 2 apart. After the "detect overlaps" phase, signals are only removed. So most signals on long straight tracks will stay an even number apart.

How do I remove the menu button?

There is a setting in the mod settings to toggle the button.

Why does the mod say I can't place bidirectional rails?

You have toggled "one-way rails only" on. This setting is there for those maps where you know you'll never build bidirectional rails, so having that setting makes marking which side of rail signals are placed easier.

Why does the mod say there it cannot connect rails with different rail directions?

This means that if you place the rail with the currently placed signals, that in one direction all branches until the first signal are placed on the left, while in the other direction there is at least one branches that end/start with a signal on the right, or vice versa.
A train won't be able to pass this signal on the right side, as it can't enter/exit the other direction through this direction.
For example in this scenario on the right all southern branches (there is only one) end with a signal on the right. However there is a signal on the left in the northeastern branch. A train coming from the north east won't be able to cross to the south, so this signal is on the north eastern branch is inconsistent if you want to place a rail at that position.
The left scenario can be placed because there are both paths from south to north and from north to south.

This is similar to trying to mix pipes with different fluids.

Can you add support for my modded rails?

If you are the mod developer:
Rails that are placed using the rail-planner prototype are automatically supported.
Other rails can be added through a remote call

remote.call("RailSignalPlanner", "add_supported_rail", rail_name, rail_prototype_name?, overwrite?)

If the rail_prototype_name is empty it will take the vanilla name ("rail")
If rail_prototype_name is set to false, it will remove already supported rails if they don't have a planner.

If you are a user:
Please let me know the mod name and I will look if I can add support for it.