# newgrf_engine.h File Reference

Functions for NewGRF engines. More...

`#include "newgrf.h"`
`#include "direction_type.h"`
`#include "newgrf_cargo.h"`

Go to the source code of this file.

## Defines
#define | GetCustomRotorSprite(v, i) GetRotorOverrideSprite(v->engine_type, v, i)
#define | GetCustomRotorIcon(et) GetRotorOverrideSprite(et, NULL, true)
#define | GetCustomVehicleSprite(v, direction) GetCustomEngineSprite(v->engine_type, v, direction)
#define | GetCustomVehicleIcon(et, direction) GetCustomEngineSprite(et, NULL, direction)
## Enumerations
enum | VehicleTrigger { VEHICLE_TRIGGER_NEW_CARGO = 0x01, VEHICLE_TRIGGER_DEPOT = 0x02, VEHICLE_TRIGGER_EMPTY = 0x04, VEHICLE_TRIGGER_ANY_NEW_CARGO = 0x08, VEHICLE_TRIGGER_CALLBACK_32 = 0x10 }
## Functions
void | SetWagonOverrideSprites (EngineID engine, CargoID cargo, const struct SpriteGroup *group, EngineID *train_id, uint trains)
const SpriteGroup * | GetWagonOverrideSpriteSet (EngineID engine, CargoID cargo, EngineID overriding_engine)
void | SetCustomEngineSprites (EngineID engine, byte cargo, const struct SpriteGroup *group)
SpriteID | GetCustomEngineSprite (EngineID engine, const Vehicle *v, Direction direction)
SpriteID | GetRotorOverrideSprite (EngineID engine, const Vehicle *v, bool info_view)
void | SetEngineGRF (EngineID engine, const struct GRFFile *file)
struct GRFFile * | GetEngineGRF (EngineID engine)
| Retrieve the GRFFile tied to an engine.
uint32 | GetEngineGRFID (EngineID engine)
| Retrieve the GRF ID of the GRFFile tied to an engine.
uint16 | GetVehicleCallback (CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v)
| Evaluate a newgrf callback for vehicles.
uint16 | GetVehicleCallbackParent (CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent)
| Evaluate a newgrf callback for vehicles with a different vehicle for parent scope.
bool | UsesWagonOverride (const Vehicle *v)
| Check if a wagon is currently using a wagon override.
uint | GetVehicleProperty (const Vehicle *v, uint8 property, uint orig_value)
uint | GetEngineProperty (EngineID engine, uint8 property, uint orig_value)
void | TriggerVehicle (Vehicle *veh, VehicleTrigger trigger)
void | UnloadWagonOverrides (Engine *e)
| Unload all wagon override sprite groups.
uint | ListPositionOfEngine (EngineID engine)
| Get the list position of an engine.
void | AlterVehicleListOrder (EngineID engine, EngineID target)
void | CommitVehicleListOrderChanges ()
EngineID | GetNewEngineID (const GRFFile *file, VehicleType type, uint16 internal_id)
## Variables
int | _traininfo_vehicle_pitch
int | _traininfo_vehicle_width

## Detailed Description

Functions for NewGRF engines.

Definition in file newgrf_engine.h.

## Function Documentation

struct GRFFile* GetEngineGRF | ( | EngineID | engine | ) | `[read]`

Retrieve the GRFFile tied to an engine.

Parameters:

  | engine | Engine ID to retrieve.

Returns:
  Pointer to GRFFile.

Definition at line 112 of file newgrf_engine.cpp.

Referenced by GetEngineGRFID(), GetIntersectionOfArticulatedRefitMasks(), GetUnionOfArticulatedRefitMasks(), and IsArticulatedVehicleRefittable().

uint32 GetEngineGRFID | ( | EngineID | engine | ) |

Retrieve the GRF ID of the GRFFile tied to an engine.

Parameters:

  | engine | Engine ID to retrieve.

Returns:
  32 bit GRFID value.

Definition at line 123 of file newgrf_engine.cpp.

References GetEngineGRF().

Referenced by CmdMoveRailVehicle(), CmdStartStopVehicle(), DrawVehicleRefitWindow(), GetCargoSubtypeText(), and ShowAdditionalText().

uint16 GetVehicleCallback | ( | CallbackID | callback,
|  | uint32 | param1,
|  | uint32 | param2,
|  | EngineID | engine,
|  | const Vehicle * | v |
| ) |  |  |

Evaluate a newgrf callback for vehicles.

Parameters:

  | callback | The callback to evalute
  | param1 | First parameter of the callback
  | param2 | Second parameter of the callback
  | engine | Engine type of the vehicle to evaluate the callback for
  | v | The vehicle to evaluate the callback for, or NULL if it doesnt exist yet

Returns:
  The value the callback returned, or CALLBACK_FAILED if it failed

Definition at line 958 of file newgrf_engine.cpp.

References CALLBACK_FAILED, and GetVehicleSpriteGroup().

Referenced by CmdBuildAircraft(), CmdRefitAircraft(), CmdRefitRailVehicle(), CmdRefitRoadVeh(), CmdRefitShip(), CmdStartStopVehicle(), GetCargoSubtypeText(), GetIntersectionOfArticulatedRefitMasks(), GetUnionOfArticulatedRefitMasks(), IsArticulatedVehicleRefittable(), LoadUnloadVehicle(), ShowAdditionalText(), and TrainConsistChanged().

uint16 GetVehicleCallbackParent | ( | CallbackID | callback,
|  | uint32 | param1,
|  | uint32 | param2,
|  | EngineID | engine,
|  | const Vehicle * | v,
|  | const Vehicle * | parent |
| ) |  |  |

Evaluate a newgrf callback for vehicles with a different vehicle for parent scope.

Parameters:

  | callback | The callback to evalute
  | param1 | First parameter of the callback
  | param2 | Second parameter of the callback
  | engine | Engine type of the vehicle to evaluate the callback for
  | v | The vehicle to evaluate the callback for, or NULL if it doesnt exist yet
  | parent | The vehicle to use for parent scope

Returns:
  The value the callback returned, or CALLBACK_FAILED if it failed

Definition at line 985 of file newgrf_engine.cpp.

References CALLBACK_FAILED, and GetVehicleSpriteGroup().

Referenced by CmdMoveRailVehicle().

uint ListPositionOfEngine | ( | EngineID | engine | ) |

Get the list position of an engine.

Used when sorting a list of engines.

Parameters:

  | engine | ID of the engine.

Returns:
  The list position of the engine.

Definition at line 1104 of file newgrf_engine.cpp.

bool UsesWagonOverride | ( | const Vehicle * | v | ) |

Check if a wagon is currently using a wagon override.

Parameters:

  | v | The wagon to check

Returns:
  true if it is using an override, false otherwise

Definition at line 943 of file newgrf_engine.cpp.

Referenced by TrainConsistChanged().