Skip to content

Change: Use explicit (Var)Action2 results for "callback failed" and "calculated result".#432

Open
Rito13 wants to merge 1 commit into
OpenTTD:masterfrom
Rito13:ottd_14149
Open

Change: Use explicit (Var)Action2 results for "callback failed" and "calculated result".#432
Rito13 wants to merge 1 commit into
OpenTTD:masterfrom
Rito13:ottd_14149

Conversation

@Rito13

@Rito13 Rito13 commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Motivation

OpenTTD/OpenTTD#14149 has been merged and released in OTTD 15.0.

Problem

  • NML has a hard time to return "failure" from switches.
    • To fail callbacks, you have to return a fake/empty sprite set.
    • To fail sprite resolving, you have to return a dummy callback result.
  • There is an infamous trap: Defining only a "default" result in VarAction2 makes it not branch to the references group, but instead returns a calculated result.

Description

Instead of generating special action2 for failure result and then returning its id return 0x7FFF.
Instead of generating special action2 for querying the result from most recent VarAction2 and then returning its id return 0x7FFE
Remove related methods used for generating failure action2.

Limitations

Will make NewGRFs that use CB_FAILED or "calculated result" incompatible with OpenTTD older than 15.0 and TTDP.

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.

1 participant