OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Enumerations | Functions | Variables
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"`
`#include "newgrf_spritegroup.h"`

Go to the source code of this file.

## Data Structures
struct | VehicleScopeResolver
| Resolver for a vehicle scope. More...
struct | VehicleResolverObject
| Resolver for a vehicle (chain) More...

## Macros
#define | GetCustomVehicleSprite(v, direction, image_type, result) GetCustomEngineSprite(v->engine_type, v, direction, image_type, result)
#define | GetCustomVehicleIcon(et, direction, image_type, result) GetCustomEngineSprite(et, NULL, direction, image_type, result)
#define | GetCustomRotorSprite(v, i, image_type, result) GetRotorOverrideSprite(v->engine_type, v, i, image_type, result)
#define | GetCustomRotorIcon(et, image_type, result) GetRotorOverrideSprite(et, NULL, true, image_type, result)

## 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)
void | GetCustomEngineSprite (EngineID engine, const Vehicle *v, Direction direction, EngineImageType image_type, VehicleSpriteSeq *result)
void | GetRotorOverrideSprite (EngineID engine, const struct Aircraft *v, bool info_view, EngineImageType image_type, VehicleSpriteSeq *result)
void | SetEngineGRF (EngineID engine, const struct GRFFile *file)
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, const Vehicle *v=NULL)
void | TriggerVehicle (Vehicle *veh, VehicleTrigger trigger)
void | UnloadWagonOverrides (Engine *e)
| Unload all wagon override sprite groups.
void | AlterVehicleListOrder (EngineID engine, uint target)
| Record a vehicle ListOrderChange.
void | CommitVehicleListOrderChanges ()
| Deternine default engine sorting and execute recorded ListOrderChanges from AlterVehicleListOrder.
EngineID | GetNewEngineID (const GRFFile *file, VehicleType type, uint16 internal_id)
| Return the ID of a new engine.

## Variables
static const uint | TRAININFO_DEFAULT_VEHICLE_WIDTH = 29
static const uint | ROADVEHINFO_DEFAULT_VEHICLE_WIDTH = 32
static const uint | VEHICLEINFO_FULL_VEHICLE_WIDTH = 32

## Detailed Description

Functions for NewGRF engines.

Definition in file newgrf_engine.h.

## Function Documentation

void AlterVehicleListOrder | ( | EngineID | engine,
|  | uint | target
| ) |  |

Record a vehicle ListOrderChange.

Parameters

  engine | Engine to move
  target | Local engine ID to move engine in front of

Note
  All sorting is done later in CommitVehicleListOrderChanges

Definition at line 1211 of file newgrf_engine.cpp.

References SmallVector< T, S >::Append(), and ListOrderChange::target.

Referenced by AircraftVehicleChangeInfo(), RailVehicleChangeInfo(), RoadVehicleChangeInfo(), and ShipVehicleChangeInfo().

EngineID GetNewEngineID | ( | const GRFFile * | file,
|  | VehicleType | type,
|  | uint16 | internal_id
| ) |  |

Return the ID of a new engine.

Parameters

  file | The NewGRF file providing the engine.
  type | The Vehicle type.
  internal_id | NewGRF-internal ID of the engine.

Returns
  The new EngineID.

Note
  depending on the dynamic_engine setting and a possible override property the grfID may be unique or overwriting or partially re-defining properties of an existing engine.

Definition at line 694 of file newgrf.cpp.

References _settings_game, VehicleSettings::dynamic_engines, EngineOverrideManager::GetID(), and GameSettings::vehicle.

Referenced by GetNextArticulatedPart().

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

Evaluate a newgrf callback for vehicles.

Parameters

  callback | The callback to evaluate
  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 1082 of file newgrf_engine.cpp.

References VehicleResolverObject::WO_UNCACHED.

Referenced by CmdStartStopVehicle(), Train::ConsistChanged(), Engine::DetermineCapacity(), GetCargoSubtypeText(), GetLoadAmount(), GetNextArticulatedPart(), GetRefitCostFactor(), GetRoadVehLength(), PlayVehicleSound(), RunVehicleDayProc(), ShowAdditionalText(), SpawnAdvancedVisualEffect(), and Vehicle::UpdateVisualEffect().

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 evaluate
  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 doesn't 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 1098 of file newgrf_engine.cpp.

References VehicleResolverObject::WO_NONE.

Referenced by CheckTrainAttachment().

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

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

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