NIMBY Rails devblog 2021-07

“Long” path signals

When a train stops at (or comes up to) a path signal, a path check is performed. This path traces the tracks between the train and its current destination (or a blocking/facing signal) and checks if said path touches any reservation or train. This is the basic principle of how path signals work. By default this rule is sufficiently powerful to regulate many scenarios, but it cannot look beyond the next destination of the train. This is sometimes required, for example to regulate access to single track segments.

Path signals now have an optional flag to enable ignoring the train destination. This makes the path signal check to keep looking past the train destination and down its list of stops, until a blocking signal or properly facing signal stops the trace, or a loop of the line is completed. This way the train can “see” beyond its destination and refuse to enter a single track section with a train several stations away that would collide with it. Other games call this mode a “long” path signal.

Explicit track layers

Most of July was devoted to enabling track mods. But before that was possible, a mini review of the track system was required. The full review was done before v1.2 became public, to enable single track. But an aspect of that review was left for later: decoupling the concept of track kind from the concept of track layer.

In v1.1 and the first builds of v1.2, a track kind specified both technical parameters of the track like max. speed, and which layer that track was built on (tunnel, ground, viaduct). After this mini review track kinds are now always possible to build in all track layers.

Additionally the layers themselves were reviewed and made more interesting. Ground is still just a single layer on ground level. But viaduct and tunnel have gained 3 discrete layers each with track-track collision enabled, like ground track does. This enables diamonds in tunnels, which were sorely needed, and also enables to stack levels of viaduct. They also have a final “infinite” layer which behaves like the old tunnel layer did, for save compatibility and for when the normal 3 layers are not enough.

Track kind picker

The next step was to remove the harcoded track kinds in the base game and make track kinds a dynamically loadable rules object, just like train units. The technical side of this also required its UI equivalent. It was no longer possible to have a small button bar with all the track kinds. A listing is now required, since players will be able to subscribe to any number of track mods.

A favorite bar is now displayer to replace the old hardcoded track kinds bar. The player can select any combination of track and layer in the listing and in the layer toolbar, and then select a favorite slot. It’s then mapped to that button and to the keyboard key of that number. This is a first pass at track organization and time will tell if it’s enough or more structure is required.

Track mods

After the previous features were implemented all the pieces for track mods were in place, except for the dynamic texture manager required to potentially juggle thousands of track textures. The game already had a dynamic texture cache in place for trains, but tracks posed and extra challenge, since track geometry can run into the hundreds of MB for complex builds and it’s both slow to recreate, and itself subject to a cache system. So the first task was to develop a texture manager capable of caching track textures as they come and go into view, but also make it possible for track geometry to use textures without any knowledge of how those textures are mapped into the cache texture array, and without changing a single byte of cached geometry.

After the texture manager was up and running, it was time to transform the hardcoded track kinds into a mod itself, and determine a mod.txt specification which exposed enough variables to be interesting and useful to modders. Some variables are not exposed since they will become obsolete in the future, specially around stations and depots.

v1.2.26 was finally released in the beta branch with support for track mods, and a dozen were uploaded to the workshop in the first 24h, so I would say the introduction of track mods has gone well.

Thank to all modders!

Straight track modifier

Some features are so often requested that they become a meme, and having some kind of tool or snapping mode to draw straight tracks could be one of them. While creating new track it’s now possible to hold control to line up the new node with its two previous siblings, creating a straight track. Finally.