Add: Support for NewGRF badges.
Add support for NewGRF badge feature in https://github.com/OpenTTD/OpenTTD/pull/13073
Use badge_table { } to create the translation table.
Use badges property to assign a list of badges to an entity.
See 042_badges.nml for slightly more info.
The regression test 042_badges will add a badge to the "Chaney 'Jubilee' (Steam)" engine, which will appear like so:
Checking badges on a nearby tile for now would require something like this
switch(FEAT_STATIONS, SELF, _sw_check_yard_p1n1, [
STORE_TEMP(1, 0x100),
STORE_TEMP(bitmask(4), 0x101),
var[0x79, 0, 0x1, 0xF1]]){return;}
better if we can simplify it to
nearby_tile_has_badge(x, y, badge, features)
whereas features is bitmask(FEAT_1, FEAT_2, ...)
action 0 flags... badge_flags.patch
More than happy to push these patches to my fork for cherrypick, but eh, they're tiny.
Been using this for Iron Horse since the PR opened, works for me.
No warning/error is thrown when creating a FEAT_BADGES item, whereby the label is not in the badgetable. Unless I'm msissing something here, I can't think why I would define a badge item that isn't in the badge table (and therefore isn't used on a vehicle?
I'm not sure if that should be considered an error, but it certainly feels like something that should trigger a warning since it's most likely a typo
A similar "A warning would be nice" situation
If I have a badge eg "power/steam", but no "power" badge defined, the "power/steam" badge does show up in the newGRF debug menu but doesn't show up in the purchase menu as either a sprite or text. If the user's intention was to add text that's kinda obvious ("Power: steam" can't displayed if "Power" doesn't exist to have text), but it's a little counter-intuitive if the user is mostly thinking about adding a sprite but didn't want text
I assume this is a limitation of the implementation in OpenTTD rather than NML, but it would be good if NML threw a warning if a nested badge was defined without a parent badge already being defined
No warning/error is thrown when creating a FEAT_BADGES item, whereby the label is not in the badgetable. Unless I'm msissing something here, I can't think why I would define a badge item that isn't in the badge table (and therefore isn't used on a vehicle?
I'm not sure if that should be considered an error, but it certainly feels like something that should trigger a warning since it's most likely a typo
Much like defining railtypes and roadtypes, there's no requirement to use badges when defining them. Maybe you wanted to make a collection of badges to be used in other NewGRFs. A badge table is only required to use badges, not to define them.
It's also not an error to not define a class badge.
No warning/error is thrown when creating a FEAT_BADGES item, whereby the label is not in the badgetable. Unless I'm msissing something here, I can't think why I would define a badge item that isn't in the badge table (and therefore isn't used on a vehicle?
I'm not sure if that should be considered an error, but it certainly feels like something that should trigger a warning since it's most likely a typo
Much like defining railtypes and roadtypes, there's no requirement to use badges when defining them. Maybe you wanted to make a collection of badges to be used in other NewGRFs. A badge table is only required to use badges, not to define them.
It's also not an error to not define a class badge.
Lots of other NML warnings aren't really errors, either ... that's the point of a warning, surely? "You might be doing this intentionally but there's a good chance you aren't, maybe take a look?"