# newgrf_callbacks.h File Reference

Go to the source code of this file.

## Enumerations
enum | CallbackID { CBID_NO_CALLBACK = 0x00, CBID_RANDOM_TRIGGER = 0x01, CBID_TRAIN_WAGON_POWER = 0x10, CBID_VEHICLE_LENGTH = 0x11, CBID_VEHICLE_LOAD_AMOUNT = 0x12, CBID_STATION_AVAILABILITY = 0x13, CBID_STATION_SPRITE_LAYOUT = 0x14, CBID_VEHICLE_REFIT_CAPACITY = 0x15, CBID_VEHICLE_ARTIC_ENGINE = 0x16, CBID_HOUSE_ALLOW_CONSTRUCTION = 0x17, CBID_GENERIC_AI_PURCHASE_SELECTION = 0x18, CBID_VEHICLE_CARGO_SUFFIX = 0x19, CBID_HOUSE_ANIMATION_NEXT_FRAME = 0x1A, CBID_HOUSE_ANIMATION_START_STOP = 0x1B, CBID_HOUSE_CONSTRUCTION_STATE_CHANGE = 0x1C, CBID_TRAIN_ALLOW_WAGON_ATTACH = 0x1D, CBID_HOUSE_COLOUR = 0x1E, CBID_HOUSE_CARGO_ACCEPTANCE = 0x1F, CBID_HOUSE_ANIMATION_SPEED = 0x20, CBID_HOUSE_DESTRUCTION = 0x21, CBID_INDUSTRY_AVAILABLE = 0x22, CBID_VEHICLE_ADDITIONAL_TEXT = 0x23, CBID_STATION_TILE_LAYOUT = 0x24, CBID_INDTILE_ANIM_START_STOP = 0x25, CBID_INDTILE_ANIM_NEXT_FRAME = 0x26, CBID_INDTILE_ANIMATION_SPEED = 0x27, CBID_INDUSTRY_LOCATION = 0x28, CBID_INDUSTRY_PRODUCTION_CHANGE = 0x29, CBID_HOUSE_ACCEPT_CARGO = 0x2A, CBID_INDTILE_CARGO_ACCEPTANCE = 0x2B, CBID_INDTILE_ACCEPT_CARGO = 0x2C, CBID_VEHICLE_COLOUR_MAPPING = 0x2D, CBID_HOUSE_PRODUCE_CARGO = 0x2E, CBID_INDTILE_SHAPE_CHECK = 0x2F, CBID_INDUSTRY_DRAW_FOUNDATIONS = 0x30, CBID_VEHICLE_START_STOP_CHECK = 0x31, CBID_VEHICLE_32DAY_CALLBACK = 0x32, CBID_VEHICLE_SOUND_EFFECT = 0x33, CBID_VEHICLE_AUTOREPLACE_SELECTION = 0x34, CBID_INDUSTRY_MONTHLYPROD_CHANGE = 0x35, CBID_VEHICLE_MODIFY_PROPERTY = 0x36, CBID_INDUSTRY_CARGO_SUFFIX = 0x37, CBID_INDUSTRY_FUND_MORE_TEXT = 0x38, CBID_CARGO_PROFIT_CALC = 0x39, CBID_INDUSTRY_WINDOW_MORE_TEXT = 0x3A, CBID_INDUSTRY_SPECIAL_EFFECT = 0x3B, CBID_INDUSTRY_AUTOSLOPE = 0x3C, CBID_INDUSTRY_REFUSE_CARGO = 0x3D, CBID_STATION_ANIM_START_STOP = 0x140, CBID_STATION_ANIM_NEXT_FRAME = 0x141, CBID_STATION_ANIMATION_SPEED = 0x142, CBID_HOUSE_DENY_DESTRUCTION = 0x143, CBID_SOUNDS_AMBIENT_EFFECT = 0x144, CBID_CARGO_STATION_RATING_CALC = 0x145, CBID_NEW_SIGNALS_SPRITE_DRAW = 0x146, CBID_CANALS_SPRITE_OFFSET = 0x147, CBID_HOUSE_WATCHED_CARGO_ACCEPTED = 0x148, CBID_STATION_LAND_SLOPE_CHECK = 0x149, CBID_INDUSTRY_DECIDE_COLOUR = 0x14A, CBID_INDUSTRY_INPUT_CARGO_TYPES = 0x14B, CBID_INDUSTRY_OUTPUT_CARGO_TYPES = 0x14C }
| List of implemented NewGRF callbacks. More...
enum | VehicleCallbackMask { CBM_TRAIN_WAGON_POWER = 0, CBM_VEHICLE_LENGTH = 1, CBM_VEHICLE_LOAD_AMOUNT = 2, CBM_VEHICLE_REFIT_CAPACITY = 3, CBM_VEHICLE_ARTIC_ENGINE = 4, CBM_VEHICLE_CARGO_SUFFIX = 5, CBM_VEHICLE_COLOUR_REMAP = 6, CBM_VEHICLE_SOUND_EFFECT = 7 }
| Callback masks for vehicles, indicates which callbacks are used by a vehicle. More...
enum | StationCallbackMask { CBM_STATION_AVAIL = 0, CBM_STATION_SPRITE_LAYOUT = 1, CBM_STATION_ANIMATION_NEXT_FRAME = 2, CBM_STATION_ANIMATION_SPEED = 3, CBM_STATION_SLOPE_CHECK = 4 }
| Callback masks for stations. More...
enum | HouseCallbackMask { CBM_HOUSE_ALLOW_CONSTRUCTION = 0, CBM_HOUSE_ANIMATION_NEXT_FRAME = 1, CBM_HOUSE_ANIMATION_START_STOP = 2, CBM_HOUSE_CONSTRUCTION_STATE_CHANGE = 3, CBM_HOUSE_COLOUR = 4, CBM_HOUSE_CARGO_ACCEPTANCE = 5, CBM_HOUSE_ANIMATION_SPEED = 6, CBM_HOUSE_DESTRUCTION = 7, CBM_HOUSE_ACCEPT_CARGO = 8, CBM_HOUSE_PRODUCE_CARGO = 9, CBM_HOUSE_DENY_DESTRUCTION = 10 }
| Callback masks for houses.
enum | CargoCallbackMask { CBM_CARGO_PROFIT_CALC = 0, CBM_CARGO_STATION_RATING_CALC = 1 }
| Callback masks for cargos. More...
enum | IndustryCallbackMask { CBM_IND_AVAILABLE = 0, CBM_IND_PRODUCTION_CARGO_ARRIVAL = 1, CBM_IND_PRODUCTION_256_TICKS = 2, CBM_IND_LOCATION = 3, CBM_IND_PRODUCTION_CHANGE = 4, CBM_IND_MONTHLYPROD_CHANGE = 5, CBM_IND_CARGO_SUFFIX = 6, CBM_IND_FUND_MORE_TEXT = 7, CBM_IND_WINDOW_MORE_TEXT = 8, CBM_IND_SPECIAL_EFFECT = 9, CBM_IND_REFUSE_CARGO = 10, CBM_IND_DECIDE_COLOUR = 11, CBM_IND_INPUT_CARGO_TYPES = 12, CBM_IND_OUTPUT_CARGO_TYPES = 13 }
| Callback masks for Industries. More...
enum | IndustryTileCallbackMask { CBM_INDT_ANIM_NEXT_FRAME = 0, CBM_INDT_ANIM_SPEED = 1, CBM_INDT_CARGO_ACCEPTANCE = 2, CBM_INDT_ACCEPT_CARGO = 3, CBM_INDT_SHAPE_CHECK = 4, CBM_INDT_DRAW_FOUNDATIONS = 5, CBM_INDT_AUTOSLOPE = 6 }
| Callback masks for industry tiles. More...
enum | { CALLBACK_FAILED = 0xFFFF, CALLBACK_HOUSEPRODCARGO_END = 0x20FF }
| Different values for Callback result evaluations. More...

## Detailed Description

Definition in file newgrf_callbacks.h.

## Enumeration Type Documentation

anonymous enum

Different values for Callback result evaluations.

Enumerator:

  CALLBACK_FAILED | Result of a failed callback.
  CALLBACK_HOUSEPRODCARGO_END | Sentinel indicating that the loop for CBID_HOUSE_PRODUCE_CARGO has ended.

Definition at line 307 of file newgrf_callbacks.h.

enum CallbackID

List of implemented NewGRF callbacks.

Most of these callbacks are only triggered when the corresponding bit is set in the callback flags/trigger for a vehicle, house, industry, etc. Names are formatted as CBID_<CLASS>_<CALLBACK>

Note:
  Do not forget to add 15 bits callbacks to the switch in newgrf_spritegroup.cpp (search for "15 bits callback").

Enumerator:

  CBID_NO_CALLBACK | Set when using the callback resolve system, but not to resolve a callback.
  CBID_RANDOM_TRIGGER | Set when calling a randomizing trigger (almost undocumented).
  CBID_TRAIN_WAGON_POWER | Powered wagons, if the result is lower as 0x40 then the wagon is powered. Todo: : interpret the rest of the result, aka "visual effects".
  CBID_VEHICLE_LENGTH | Vehicle length, returns the amount of 1/8's the vehicle is shorter for trains and RVs.
  CBID_VEHICLE_LOAD_AMOUNT | Determine the amount of cargo to load per unit of time when using gradual loading.
  CBID_STATION_AVAILABILITY | Determine whether a newstation should be made available to build.
  CBID_STATION_SPRITE_LAYOUT | Choose a sprite layout to draw, instead of the standard 0-7 range.
  CBID_VEHICLE_REFIT_CAPACITY | Refit capacity, the passed vehicle needs to have its ->cargo_type set to the cargo we are refitting to, returns the new cargo capacity.
  CBID_VEHICLE_ARTIC_ENGINE | Builds articulated engines for trains and RVs.
  CBID_HOUSE_ALLOW_CONSTRUCTION | Determine whether the house can be built on the specified tile.
  CBID_GENERIC_AI_PURCHASE_SELECTION | AI construction/purchase selection.
  CBID_VEHICLE_CARGO_SUFFIX | Determine the cargo "suffixes" for each refit possibility of a cargo.
  CBID_HOUSE_ANIMATION_NEXT_FRAME | Determine the next animation frame for a house.
  CBID_HOUSE_ANIMATION_START_STOP | Called for periodically starting or stopping the animation.
  CBID_HOUSE_CONSTRUCTION_STATE_CHANGE | Called whenever the construction state of a house changes.
  CBID_TRAIN_ALLOW_WAGON_ATTACH | Determine whether a wagon can be attached to an already existing train.
  CBID_HOUSE_COLOUR | Called to determine the colour of a town building.
  CBID_HOUSE_CARGO_ACCEPTANCE | Called to decide how much cargo a town building can accept.
  CBID_HOUSE_ANIMATION_SPEED | Called to indicate how long the current animation frame should last.
  CBID_HOUSE_DESTRUCTION | Called periodically to determine if a house should be destroyed.
  CBID_INDUSTRY_AVAILABLE | Called to determine if the given industry type is available.
  CBID_VEHICLE_ADDITIONAL_TEXT | This callback is called from vehicle purchase lists. It returns a value to be used as a custom string ID in the 0xD000 range.
  CBID_STATION_TILE_LAYOUT | Called when building a station to customize the tile layout.
  CBID_INDTILE_ANIM_START_STOP | Called for periodically starting or stopping the animation.
  CBID_INDTILE_ANIM_NEXT_FRAME | Called to determine industry tile next animation frame.
  CBID_INDTILE_ANIMATION_SPEED | Called to indicate how long the current animation frame should last.
  CBID_INDUSTRY_LOCATION | Called to determine if the given industry can be built on specific area.
  CBID_INDUSTRY_PRODUCTION_CHANGE | Called on production changes, so it can be adjusted.
  CBID_HOUSE_ACCEPT_CARGO | Called to determine which cargoes a town building should accept.
  CBID_INDTILE_CARGO_ACCEPTANCE | Called to query the cargo acceptance of the industry tile.
  CBID_INDTILE_ACCEPT_CARGO | Called to determine which cargoes an industry should accept.
  CBID_VEHICLE_COLOUR_MAPPING | Called to determine if a specific colour map should be used for a vehicle instead of the default livery.
  CBID_HOUSE_PRODUCE_CARGO | Called to determine how much cargo a town building produces.
  CBID_INDTILE_SHAPE_CHECK | Called to determine if the given industry tile can be built on specific tile.
  CBID_INDUSTRY_DRAW_FOUNDATIONS | Called to determine the type (if any) of foundation to draw for industry tile.
  CBID_VEHICLE_START_STOP_CHECK | Called when the player (or AI) tries to start or stop a vehicle. Mainly used for preventing a vehicle from leaving the depot.
  CBID_VEHICLE_32DAY_CALLBACK | Called for every vehicle every 32 days (not all on same date though).
  CBID_VEHICLE_SOUND_EFFECT | Called to play a special sound effect.
  CBID_VEHICLE_AUTOREPLACE_SELECTION | Return the vehicles this given vehicle can be "upgraded" to.
  CBID_INDUSTRY_MONTHLYPROD_CHANGE | Called monthly on production changes, so it can be adjusted more frequently.
  CBID_VEHICLE_MODIFY_PROPERTY | Called to modify various vehicle properties. Callback parameter 1 specifies the property index, as used in Action 0, to change.
  CBID_INDUSTRY_CARGO_SUFFIX | Called to determine text to display after cargo name.
  CBID_INDUSTRY_FUND_MORE_TEXT | Called to determine more text in the fund industry window.
  CBID_CARGO_PROFIT_CALC | Called to calculate the income of delivered cargo.
  CBID_INDUSTRY_WINDOW_MORE_TEXT | Called to determine more text in the industry window.
  CBID_INDUSTRY_SPECIAL_EFFECT | Called to determine industry special effects.
  CBID_INDUSTRY_AUTOSLOPE | Called to determine if industry can alter the ground below industry tile.
  CBID_INDUSTRY_REFUSE_CARGO | Called to determine if the industry can still accept or refuse more cargo arrival.
  CBID_STATION_ANIM_START_STOP | Called for periodically starting or stopping the animation.
  CBID_STATION_ANIM_NEXT_FRAME | Called to determine station tile next animation frame.
  CBID_STATION_ANIMATION_SPEED | Called to indicate how long the current animation frame should last.
  CBID_HOUSE_DENY_DESTRUCTION | Called to determine whether a town building can be destroyed.
  CBID_SOUNDS_AMBIENT_EFFECT | Select an ambient sound to play for a given type of tile.
  CBID_CARGO_STATION_RATING_CALC | Called to calculate part of a station rating.
  CBID_NEW_SIGNALS_SPRITE_DRAW | Allow signal sprites to be replaced dynamically.
  CBID_CANALS_SPRITE_OFFSET | Add an offset to the default sprite numbers to show another sprite.
  CBID_HOUSE_WATCHED_CARGO_ACCEPTED | Called when a cargo type specified in property 20 is accepted.
  CBID_STATION_LAND_SLOPE_CHECK | Callback done for each tile of a station to check the slope.
  CBID_INDUSTRY_DECIDE_COLOUR | Called to determine the color of an industry.
  CBID_INDUSTRY_INPUT_CARGO_TYPES | Customize the input cargo types of a newly build industry.
  CBID_INDUSTRY_OUTPUT_CARGO_TYPES | Customize the output cargo types of a newly build industry.

Definition at line 20 of file newgrf_callbacks.h.

enum CargoCallbackMask

Callback masks for cargos.

Enumerator:

  CBM_CARGO_PROFIT_CALC | custom profit calculation
  CBM_CARGO_STATION_RATING_CALC | custom station rating for this cargo type

Definition at line 266 of file newgrf_callbacks.h.

enum IndustryCallbackMask

Callback masks for Industries.

Enumerator:

  CBM_IND_AVAILABLE | industry availability callback
  CBM_IND_PRODUCTION_CARGO_ARRIVAL | call production callback when cargo arrives at the industry
  CBM_IND_PRODUCTION_256_TICKS | call production callback every 256 ticks
  CBM_IND_LOCATION | check industry construction on given area
  CBM_IND_PRODUCTION_CHANGE | controls random production change
  CBM_IND_MONTHLYPROD_CHANGE | controls monthly random production change
  CBM_IND_CARGO_SUFFIX | cargo sub-type display
  CBM_IND_FUND_MORE_TEXT | additional text in fund window
  CBM_IND_WINDOW_MORE_TEXT | additional text in industry window
  CBM_IND_SPECIAL_EFFECT | control special effects
  CBM_IND_REFUSE_CARGO | option out of accepting cargo
  CBM_IND_DECIDE_COLOUR | give a custom colour to newly build industries
  CBM_IND_INPUT_CARGO_TYPES | customize the cargos the industry requires
  CBM_IND_OUTPUT_CARGO_TYPES | customize the cargos the industry produces

Definition at line 274 of file newgrf_callbacks.h.

enum IndustryTileCallbackMask

Callback masks for industry tiles.

Enumerator:

  CBM_INDT_ANIM_NEXT_FRAME | decides next animation frame
  CBM_INDT_ANIM_SPEED | decides animation speed
  CBM_INDT_CARGO_ACCEPTANCE | decides amount of cargo acceptance
  CBM_INDT_ACCEPT_CARGO | decides accepted types
  CBM_INDT_SHAPE_CHECK | decides slope suitability
  CBM_INDT_DRAW_FOUNDATIONS | decides if default foundations need to be drawn
  CBM_INDT_AUTOSLOPE | decides allowance of autosloping

Definition at line 294 of file newgrf_callbacks.h.

enum StationCallbackMask

Callback masks for stations.

Enumerator:

  CBM_STATION_AVAIL | Availability of station in construction window.
  CBM_STATION_SPRITE_LAYOUT | Use callback to select a sprite layout to use.
  CBM_STATION_ANIMATION_NEXT_FRAME | Use a custom next frame callback.
  CBM_STATION_ANIMATION_SPEED | Customize the animation speed of the station.
  CBM_STATION_SLOPE_CHECK | Check slope of new station tiles.

Definition at line 238 of file newgrf_callbacks.h.

enum VehicleCallbackMask

Callback masks for vehicles, indicates which callbacks are used by a vehicle.

Some callbacks are always used and don't have a mask.

Enumerator:

  CBM_TRAIN_WAGON_POWER | Powered wagons (trains only).
  CBM_VEHICLE_LENGTH | Vehicle length (trains and road vehicles).
  CBM_VEHICLE_LOAD_AMOUNT | Load amount.
  CBM_VEHICLE_REFIT_CAPACITY | Cargo capacity after refit.
  CBM_VEHICLE_ARTIC_ENGINE | Add articulated engines (trains only).
  CBM_VEHICLE_CARGO_SUFFIX | Show suffix after cargo name.
  CBM_VEHICLE_COLOUR_REMAP | Change colour mapping of vehicle.
  CBM_VEHICLE_SOUND_EFFECT | Vehicle uses custom sound effects.

Definition at line 224 of file newgrf_callbacks.h.