Trainset-side multi-system compatibility in NewGRFs

Got an idea for OpenTTD? Post it here!

Moderator: OpenTTD Developers

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

Trainset-side multi-system compatibility in NewGRFs

Post by Erato »

Hey,

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
Proposal
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.

Benefits
+ 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?

Realism
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.

Thanks
No pics no clicks. Seriously.
ImageImageImageImageImageImage

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

Re: Trainset-side multi-system compatibility in NewGRFs

Post by Hyronymus »

Sounds like a solid and sound suggestion!

User avatar
CMircea
Chairman
Chairman
Posts: 884
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
Tycoon
Tycoon
Posts: 3181
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.

User avatar
George
Tycoon
Tycoon
Posts: 4328
Joined: 16 Apr 2003 16:09
Skype: george-vb
Location: SPb, Russia.
Contact:

Re: Trainset-side multi-system compatibility in NewGRFs

Post by George »

Just to add my 5 cent
https://github.com/OpenTTD/OpenTTD/issues/8301
viewtopic.php?p=1235746#p1235746

I've frozen my work on rails sets support in xUSSR set, because of having it impossible to handle all these amount of labels correctly
Yes the track being powered / compatible works, but checking them does not work (As the example in the bug report there is a 4 system train, that has different power on different systems, that I can't code)
Image Image Image Image

User avatar
spajdy
Engineer
Engineer
Posts: 17
Joined: 28 Jan 2018 12:59

Re: Trainset-side multi-system compatibility in NewGRFs

Post by spajdy »

Hi guys,
I don't know if I am gonna help you or not, but I started making Slovak Train Set a while ago. My goal was that we have 3 kV DC, 25 kV AC, in Slovakia and 15 kV AC on the short route (Bratislava - border of Austria)

So we have locomotives that run on one of them, or two of them or well all three of them.

I abandoned standardized labels in the beginning because I would be lost in my own work.
So I did a bit of workaround so I can manage what I want: so for now it is like this:

RAIL (main railtype for almost everything with normal gauge)

ELRL for electric trains of 3kV DC and 25 kV AC (if trains use this label, of course) - track itself labeled ELRL is "service multiple electric system track"

SBAE (heh, leftovers from standardized labels), for electric trains of 3 kV DC only, nothing else will work on them (if train cannot find this it will look for ELRL), (there is SBET as sub-label for SBAE - because of ETCS option on my own set and speed-limit, but it won't affect trains without specific code for it).

SBBE electric trains for 25 kV AC. If this label is used by train it runs only on this type of rail. (ETCS as before, sub-label for ETCS affecting only trains with code for this, speed or something - we have this law that you need ETCS for speed of 160 km/h so.... )

(There are some narrow gauge tracks in my code too, but that is not figured out completely right now, so I will skip this one. And I have Hungarian HEV over there either, but I still didn't make anything with it so this is left out for now. (TREZ, NAAE (this one is actually standardized), MHEV are labels I don't want to talk about))

And last label is
AUKV for 15 kv AC and it actualy works as (master for multisystem locos supporting 3kv DC, 25 kV AC and 15 kV AC) So if you use this label it will run on ELRL, SBAE+SBET, SBBE+ETCS. We really don't have much lokos that would run 15+25 or 15+3 only, but I am considering using those sub-lables as little help if I ever wanted to create something like this. Like if i need 15+25 I would proably just add support to ETCS for that.

I understand that you are proposing this little bit differently but this is somewhat related to your topis. And if there is going to be ever some good scheme for this I all in for changing all my labels to it. For now I am stincking with my own decisions.

I read in this thread that somewhere is used 15 kV DC, so now I think I would love to add that, even if it isn't at Slovakia. Sort of want to make this possible for everyone. I have actually table that show what is compatible with what, so maybe I am able to pull something there :) just need to know lot of data before (as I don't know what voltage is used around Europe.)

Anyway I understand that you are asking to add functionalities to the game, but I don't think this is gonna happen if you can find work around by NewGRF... where is will there is way.

I hope I didn't waste your times people.

have a nice day.
Špajdy (Country of origin Slovakia)

Coming soon. Do not trust it, there is much work around here. Coming someday, hopefully.

User avatar
spajdy
Engineer
Engineer
Posts: 17
Joined: 28 Jan 2018 12:59

Re: Trainset-side multi-system compatibility in NewGRFs

Post by spajdy »

And yes, all of the ELRL classic labeled trains will run on both 3kV and 25kV tracks because I don't care about others sets much right now.
Špajdy (Country of origin Slovakia)

Coming soon. Do not trust it, there is much work around here. Coming someday, hopefully.

Eddi
Tycoon
Tycoon
Posts: 7503
Joined: 17 Jan 2007 00:14

Re: Trainset-side multi-system compatibility in NewGRFs

Post by Eddi »

please do yourself and other coders a favour and don't use labels of the standardized scheme if you're not actually following the standardized scheme.
You might not exactly be interested in Ferion, but if you are, have fun :)

Post Reply

Return to “OpenTTD Suggestions”

Who is online

Users browsing this forum: No registered users and 4 guests