# newgrf_engine.h File Reference

Functions for NewGRF engines. More...

`#include "direction_type.h"`
`#include "newgrf_callbacks.h"`
`#include "newgrf_properties.h"`
`#include "vehicle_type.h"`
`#include "engine_type.h"`
`#include "gfx_type.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 | { TRAININFO_DEFAULT_VEHICLE_WIDTH = 29, ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 28, VEHICLEINFO_FULL_VEHICLE_WIDTH = 32 }
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 struct Aircraft *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, PropertyID property, uint orig_value)
uint | GetEngineProperty (EngineID engine, PropertyID 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)

## 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 121 of file newgrf_engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get().

Referenced by GetEngineGRFID(), and GetNextArticPart().

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 132 of file newgrf_engine.cpp.

References GetEngineGRF().

Referenced by CheckTrainAttachment(), 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 1000 of file newgrf_engine.cpp.

References CALLBACK_FAILED, GetVehicleSpriteGroup(), and SpriteGroup::Resolve().

Referenced by BuildRefitList(), CmdStartStopVehicle(), Train::ConsistChanged(), GetBestFittingSubType(), GetCargoSubtypeText(), GetNextArticPart(), GetVehicleCapacity(), LoadUnloadVehicle(), RunVehicleDayProc(), and ShowAdditionalText().

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 1027 of file newgrf_engine.cpp.

References CALLBACK_FAILED, GetVehicleSpriteGroup(), and SpriteGroup::Resolve().

Referenced by CheckTrainAttachment().

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 1148 of file newgrf_engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_engine_pool >::Get().

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 985 of file newgrf_engine.cpp.

References SpecializedVehicle< Train, VEH_TRAIN >::From(), BaseVehicle::type, and VEH_TRAIN.

Referenced by Train::ConsistChanged(), and GetEngineLivery().