Callback: Custom refit

From GRFSpecs
Jump to navigationJump to search

Custom refit (163)

The custom refit callback allows overriding the refittablity of each cargo as defined by the standard vehicle properties. It will be called for each defined cargo type once after the game has loaded all NewGRF files. It needs to be enabled by a callback flag.

The callback is run in purchase list scope, i.e. for cargotype FF. No variables of an actual vehicle are available. Information about the cargo type the callback is called for is available in variables 10 and 18:

  • variable 10:
bit numbers Meaning
0..15 Cargo classes of the cargo type
other bits reserved for future use
  • variable 18:
bit numbers Meaning
0..7 Index of the cargo type in the cargo translation table, or FF if the cargo is not present in the translation table
other bits reserved for future use


The callback has to return one of the following values:

Value Meaning
0 Don't change refittability (i.e. use whatever the evaluation of the various refittability vehicle props has determined).
1 Allow cargo type as a refit.
2 Disallow cargo type as a refit.

A failed callback is treated like a 0 return value.

Note: As this callback is not re-evaluated after game initialization, using any dynamic variables like e.g. game date will lead to undefined and faulty behaviour.

This callback is available starting with Supported by OpenTTD 15 (gd2496b6ec4)15 Not supported by TTDPatch OpenTTD 15.