Skip to content

Add: [Badges] Vehicle variable to query badges of current rail or road types. - #14312

Merged
PeterN merged 1 commit into
OpenTTD:masterfrom
PeterN:engines-query-rail-road-type-badges
Aug 11, 2025
Merged

PeterN merged 1 commit into
OpenTTD:masterfrom
PeterN:engines-query-rail-road-type-badges

Conversation

@PeterN

@PeterN PeterN commented May 30, 2025

Copy link
Copy Markdown
Member

Motivation / Problem

Badges can be set on rail and road types. Vehicles can only query their own badges, or badges of other vehicles in their chain.

Description

Add a new variable, 0x65, which allows querying the badges of rail or road type of the current type occupied by the vehicle.

This works the same as variable 0x7A, taking a badge table index as a parameter.

Limitations

Foot-guns. Desyncs. Bending the spec.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

@PeterN
PeterN force-pushed the engines-query-rail-road-type-badges branch from 6361662 to 0cc6896 Compare May 30, 2025 17:09
@PeterN
PeterN marked this pull request as ready for review May 30, 2025 17:49
@andythenorth

Copy link
Copy Markdown
Contributor

I have tested this with trains querying railtypes, and it works as expected for that case.

@2TallTyler

Copy link
Copy Markdown
Member

Looking for opinions from @andythenorth and other GRF authors: Does #14357 fulfil your needs in lieu of this?

@andythenorth

Copy link
Copy Markdown
Contributor

Looking for opinions from @andythenorth and other GRF authors: Does #14357 fulfil your needs in lieu of this?

Separate concerns 😄

Railtype badges aren't a solution for compatibility. Labels are the solution for that, per #14357.

But railtype badges can be used for purposes like

  • visual effects ("railtype is electrified" -> use sparks effect)
  • sprite selections ("railtype has catenary" -> raise pantograph)
  • stats adjustment (untested, but as an example, badges might be a better way to implement some types of rack rail)

@2TallTyler 2TallTyler left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#YOLO, curious to see what mischief GRF developers do with this. 🙂

@PeterN
PeterN merged commit 1af721a into OpenTTD:master Aug 11, 2025
@PeterN
PeterN deleted the engines-query-rail-road-type-badges branch August 11, 2025 18:08
@andythenorth

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants