Trainset-side multi-system compatibility in NewGRFs

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

Post Reply
User avatar
Route Supervisor
Route Supervisor
Posts: 478
Joined: 25 May 2015 09:09
Location: The Netherlands

Trainset-side multi-system compatibility in NewGRFs

Post by Erato »


The way things work right now, getting a train to be compatible with multiple voltages is a bloody pain. Let's say I have a train that's compatible with only 1.5kV DC, and 15kV AC. The way it's currently done is as such:
In the train you define a tracktype:

Code: Select all

track_type: [SAAE, ELRL];
and you also have to define an invisible tracktype SAAE with

Code: Select all

powered_railtype_list: ["SAAa","SAAd"]
And then if you have a trackset with SAAa and SAAd you get to use the train on both, and if you have neither you kind of have a problem.

This is dumb, and creates a massive headache for everyone involved, especially having had the displeasure of having to fix a related issue, because "powered_railtype_list" isn't as intuitive as I'd like.

So I propose a solution to allow for train-side multi-system compatibility
Currently the track_type label works as follows:
You put an array in, say [AAAA,BBBB,CCCC], it'll then check for AAAA, if there is none, then it'll check for BBBB, and if there's none it defaults to checking for CCCC, and if that isn't provided either, the train becomes unavailable. If there's a tracktype with label AAAA, then the train will never run on BBBB or CCCC, assuming no powered_railtype_list shenanigans.

What if we allow arrays in this?
Say [[AAAA,AABB],BBBB,CCCC]. It'll check for AAAA and AABB, and regardless of whether the other is available, it'll run on AAAA and/or AABB if they are defined. Only if neither is available, will it default to BBBB etc.

So in the example at the top, you would have [[SAAa,SAAd],SAAE,ELRL], so if there's 1.5kV DC tracks, it'll run on that, and if there's 15kV AC tracks, it'll run on that as well. If neither is available, it'll look for SAAE, which can be a legacy universal track, or the electrified rails of an unrelated trackset that just never bothered with voltages, and if that's not available it may default to ELRL, like normal.

+ It makes multi-system trains, which are becoming more common IRL, easier to implement for trainset developers.
+ It's backwards compatible.
+ It frees up railtype slots.
+ This makes it a lot easier to implement multi-system trains that are compatible with a different set of voltages.

Reasonable objections
Why bother with adding voltage-related complexity?

Why add new features to the base-game for things that can be done with NewGRFs already?
The existing way to do things is very inflexible, and can create a lot of problems and headaches for developers and players alike.
Players will have trouble understanding what the problem is, and who to report it to - should they choose to report it at all. - After all, if the train isn't compatible then it's the trainset's fault, right? Well not necessarily. For NewGRF developers, it can cost hours to figure out, what exactly causes the issue, and how to fix the issue, because of all the things that can go wrong, and sometimes it's a very specific issue that arises only when you use some train or tracksets with other train or tracksets.

No pics no clicks. Seriously. Also stop using Modern Maglev Trains. Use RIMS instead.

User avatar
Posts: 13221
Joined: 03 Dec 2002 10:36
Location: The Netherlands

Re: Trainset-side multi-system compatibility in NewGRFs

Post by Hyronymus »

Sounds like a solid and sound suggestion!

User avatar
Posts: 881
Joined: 29 Dec 2006 14:05

Re: Trainset-side multi-system compatibility in NewGRFs

Post by CMircea »

I agree, it would help a lot.

I just spent several days trying to update UKRS2 to be compatible with new track sets; trains that run on both 3rd rail and overhead wires use a bit of a hack and require a track type that has both, otherwise they fall back to just overhead wires. There are track sets that don't specify a dual-power track type and the set has to work around them, somehow.

And don't get me started of axle weight limits - I encountered a set that used a higher axle weight class than A for all tracktype labels. That was fun to work around too :)

There is a caveat: it will absolutely explode the number of checks to be done to see if a train can drive on every single piece of track. Even worse if a check is done by the trainset to change speed/power based on the track type :)

User avatar
Emperor Jake
Posts: 3172
Joined: 24 Apr 2007 09:37
Location: NSW Australia

Re: Trainset-side multi-system compatibility in NewGRFs

Post by Emperor Jake »

This is a great idea. In fact, many years ago I attempted to develop a train and track set called TOE-Trains of Europe, and I ran into this exact problem and subsequently abandoned that project. Here's the original bug report I made about it. I did manage to code 4 different voltages and a functional universal locomotive, but I wasn't able to code a train that would only travel on two or three of the voltages. (without many hidden railtypes and there were only 16 slots back then...) :roll:

While I won't likely restart that project in that form, I would welcome the addition of more multi-voltage/multi-gauge track sets (xUSSR does the multi voltage thing best at the moment) and maybe work on additions to the Japan Set which would split trains into their different voltages.

Even existing sets suffer from this sort of issue, for example the Shoeboxes from Iron Horse don't work properly on some 3rd rail sets.

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 3 guests