NIMBY Rails devblog 2023-02

Custom train compositions

Starting in version 1.7 players can compose their own trains, both from stock carriages (named from now and in-game as “cars” for brevity, beyond the various regional naming) and from mod cars. It was always possible for mod authors to provide pre-made compositions in their mods. Indeed it was the only way to provide a train for players. For this reason the game has always internally supported arbitrary compositions of cars.

Mods can now flag TrainUnits (the rules objects which represents a train car model) as being able to be used by players in custom compositions. This flag defaults to false, so modders will need to explicitly opt-in into this new feature. I understand some modders feel strongly about how their creations are used so making this opt-in is the right choice.

On top of this all-or-nothing flag, there is a new system of rules for combining cars: couplers. Cars can declare a front and a back coupler set, and the train editor won’t allow to purchase or apply changes to a train if one or more adjacent cars have incompatible couplers. Unlike the previous setting, couplers default to the most permissive option, the universal coupler with optional coupling. Modders can choose to restrict their couplers to more specific options, or even to introduce their own private couplers. This might be useful to restrict multiple unit inner train cars from combining with any other cars, while still allowing the head cars to declare an universal coupler in the front.

Custom train editor

Players can create and edit custom composed trains in the train editor:

The basic view of the train editor now gains a new panel to inspect each individual car of a train. And if all the cars are flagged as editable, it also becomes the train composition editor. The usual options seen in other UI editors of the game are present here: multiple selection, clipboard copy/paste (including between trains), reordering of selected cars, etc.

In the right side a new panel appears, the “car shop”, although using it does not spend any money. Here all the (flagged as editable) car models in the game are shown in a listing. This listing has the same filter options as the train purchase mode. Once you select a car model it is possible to append it to the currently edited train, or to replace the current selection of cars with the new car.

The editor allows the player to make any change they desire, but none of these changes are actually applied to the train. In order to do so the player must explicitly apply the changes with a dedicated option, which makes them pay for the price of the changes (or get refunded if the new composition is cheaper than the original one.) If the new composition is invalid, the option to apply the changes is disabled. The new train purchase mode of this system is very similar, with the usual train bill acting as the apply option.

Arriving to this final design for the custom train editor was a long process. What you will see in 1.7.1 is the third rewrite of this UI. The main constraints were making sure the train editor remains usable for 1366x768 users (who have been very vocal in the past about UI changes), and trying to fit the car shop as a permanent panel in the interface, rather than some mode you must toggle for lack of space. This last part is very important to give immediate feedback when appending trains and for previewing possible coupling conflicts. I succeeded, but barely. Lower resolutions will probably see some clipping in the car shop panel but it should remain functional. I’ve also made the top panel of the train editor collapsible, to gain more vertical space if desired.

The train editor now also supports whole train replacing, both for individual trains and as a batch option when selecting more than one train. Trains can be replaced with both pre-defined trains and custom trains.

Line timing fixes

New version, new batch of line timing fixes. I dedicated several days of doing nothing but reproducing, investigating and fixing line timings. I considered them a bug when the predicted timing differed by enough from the train AI behavior as to be an impediment to other trains, like when stopping at stations for a whole extra minute despite not being timetabled for it.

The main fixes in this area for 1.7 is line timing path traces being able to properly trace train bounces in fully connected station tracks. In 1.6 a whole track segment was missing from the timing. Braking, as fake as it is, still needed to be better simulated in the line timing, and 1.7 is much better in this regard. Finally very slow track segments were combining with the previous problems and making them worse, and they should now be better handled.

These changes mean that even if you had a very tightly timed 1.6 save, you will see lots of flashing red on first loading it on 1.7. It is for the best, and I hope these timing fixes are the last major ones required before advanced signals are introduced.

Shared games home

Shared games were implemented back in January, but there was no home page to see them all. The “real” home page will be a new in-game mode accessed from the main menu, but a simpler web version was needed, and the underlying database will be shared with the game, so I implemented it:

The map displays shared games as a single icon, which when clicked opens another tab with the dedicated map for the specific save. Merging all tracks for a world map would be a huge mess and impossible to make sense of, but I have some ideas for intermediate options which might keep the map clean. I will test more sharing ideas during the 1.7 beta. Let’s see this map fill up!