Breaking changes to cargo?

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1769
Joined: 30 Mar 2005 09:43

Breaking changes to cargo?

Post by peter1138 »

Repost of this thread to try to get more feedback

tl;dr If a NewGRF doesn't setup a cargo translation table, then a climate-default table will be used instead of no translation table.

Back in the mists of time, TTDPatch had already gone through various compatibility stages, using IDs, introducing "bitnum" for some semblance of compatibility, and finally settling on 4-character labels.

All this was before OpenTTD gained support for NewGRF defined cargo types in 2007, yet we attempted to support bare IDs, bitnums and cargo labels.

There are currently very few NewGRFs that implement cargo types that don't use labels, and those that do do not really work very well these days. They didn't work very well back then either, which is why labels were created.

Since OpenTTD 14.0, we've moved to defining built-in data with cargo labels instead of bare IDs. This had a few hiccups but mostly works pretty well, and some of the undocumented restrictions placed on cargo sets become lifted. There is (at least) one remaining niggle which is that some older sets don't install a cargo translation table and assume the default cargo types (and positions). These can end up with incorrect cargo types being used.

My proposal to fix this issue is forget about about cargo slot positions, and always install a default cargo translation table. This default table matches the original cargo types, but does it by label instead of slot, which means that if cargo types are moved or removed, the set still behaves correctly. This is implemented in https://github.com/OpenTTD/OpenTTD/pull/12646.

For sets that define a cargo translation table, there is no change. Any set that has any business with cargo types (including setting cargo types of vehicles) should be setting up cargo translation table these days.

So the potential breaking change here is that some very old sets that DO intend to use different cargo types, but pre-date cargo labels, and that probably don't work very well already, will end up not working any more.

I'm not sure what the scope of breakage is, but things like Michael Blunck's NewCargo Set, and Cargo set are notable, as they are from the 2003-2005 era predating labels.
He's like, some kind of OpenTTD developer.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1769
Joined: 30 Mar 2005 09:43

Re: Breaking changes to cargo?

Post by peter1138 »

Well, "no objections" I guess...
He's like, some kind of OpenTTD developer.
User avatar
PikkaBird
Graphics Moderator
Graphics Moderator
Posts: 5621
Joined: 13 Sep 2004 13:21
Location: The Moon

Re: Breaking changes to cargo?

Post by PikkaBird »

Do it! :evil:
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1769
Joined: 30 Mar 2005 09:43

Re: Breaking changes to cargo?

Post by peter1138 »

This was done.
He's like, some kind of OpenTTD developer.
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 0 guests