OpenTTD Source: VehicleResolverObject Struct Reference

OpenTTD Source 15.0-RC2

Public Types | Public Member Functions | Data Fields
VehicleResolverObject Struct Reference

Resolver for a vehicle (chain) More...

`#include <newgrf_engine.h>`

Inheritance diagram for VehicleResolverObject:

## Public Types
enum | WagonOverride : uint8_t { WO_NONE , WO_UNCACHED , WO_CACHED , WO_SELF }
| Application of 'wagon overrides'. More...

## Public Member Functions
| VehicleResolverObject (EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui=false, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
| Resolver of a vehicle (chain).
ScopeResolver * | GetScope (VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0) override
| Get a resolver for the scope.
const SpriteGroup * | ResolveReal (const RealSpriteGroup &group) const override
| Get the real sprites of the grf.
GrfSpecFeature | GetFeature () const override
| Get the feature number being resolved for.
uint32_t | GetDebugID () const override
| Get an identifier for the item being resolved.
Public Member Functions inherited from SpecializedResolverObject< VehicleRandomTriggers >
void | SetWaitingRandomTriggers (VehicleRandomTriggers triggers)
| Set waiting triggers for rerandomisation.
VehicleRandomTriggers | GetUsedRandomTriggers () const
| Get the triggers, which were "consumed" by some rerandomisation.
| ResolverObject (const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
| Resolver constructor.
Public Member Functions inherited from ResolverObject
| ResolverObject (const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
| Resolver constructor.
ResolverResult | DoResolve ()
int32_t | GetRegister (uint i) const
| Gets the value of a so-called newgrf "register".
void | SetRegister (uint i, int32_t value)
| Sets the value of a so-called newgrf "register".
template<class TSpriteGroup >
const TSpriteGroup * | Resolve ()
| Resolve SpriteGroup.
void | ResolveRerandomisation ()
| Resolve bits to be rerandomised.
CallbackResult | ResolveCallback (std::span< int32_t > regs100)
| Resolve callback.
uint32_t | GetWaitingRandomTriggers () const
| Used by RandomizedSpriteGroup: Triggers for rerandomisation.
void | AddUsedRandomTriggers (uint32_t triggers)
| Used by RandomizedSpriteGroup: Consume triggers.
uint32_t | GetReseedSum () const
| Returns the OR-sum of all bits that need reseeding independent of the scope they were accessed with.

## Data Fields
VehicleScopeResolver | self_scope
| Scope resolver for the indicated vehicle.
VehicleScopeResolver | parent_scope
| Scope resolver for its parent vehicle.
VehicleScopeResolver | relative_scope
| Scope resolver for an other vehicle in the chain.
uint8_t | cached_relative_count
| Relative position of the other vehicle.
Data Fields inherited from ResolverObject
ScopeResolver | default_scope
| Default implementation of the grf scope.
CallbackID | callback {}
| Callback being resolved.
uint32_t | callback_param1 = 0
| First parameter (var 10) of the callback.
uint32_t | callback_param2 = 0
| Second parameter (var 18) of the callback.
uint32_t | last_value = 0
| Result of most recent DeterministicSpriteGroup (including procedure calls)
std::array< uint32_t, VSG_END > | reseed
| Collects bits to rerandomise while triggering triggers.
const GRFFile * | grffile = nullptr
| GRFFile the resolved SpriteGroup belongs to.
const SpriteGroup * | root_spritegroup = nullptr
| Root SpriteGroup to use for resolving.

## Additional Inherited Members
Protected Attributes inherited from ResolverObject
uint32_t | waiting_random_triggers = 0
| Waiting triggers to be used by any rerandomisation. (scope independent)
uint32_t | used_random_triggers = 0
| Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent)

## Detailed Description

Resolver for a vehicle (chain)

Definition at line 47 of file newgrf_engine.h.

## Member Enumeration Documentation

## ◆ WagonOverride

enum VehicleResolverObject::WagonOverride : uint8_t

Application of 'wagon overrides'.

Enumerator
WO_NONE | Resolve no wagon overrides.
WO_UNCACHED | Resolve wagon overrides.
WO_CACHED | Resolve wagon overrides using TrainCache::cached_override.
WO_SELF | Resolve self-override (helicopter rotors and such).

Definition at line 49 of file newgrf_engine.h.

## Constructor & Destructor Documentation

## ◆ VehicleResolverObject()

VehicleResolverObject::VehicleResolverObject | ( | EngineID | engine_type,
|  | const Vehicle * | v,
|  | WagonOverride | wagon_override,
|  | bool | rotor_in_gui = `false`,
|  | CallbackID | callback = `CBID_NO_CALLBACK`,
|  | uint32_t | callback_param1 = `0`,
|  | uint32_t | callback_param2 = `0`
| ) |  |

Resolver of a vehicle (chain).

Parameters

  engine_type | Engine type
  v | Vehicle being resolved.
  wagon_override | Application of wagon overrides.
  rotor_in_gui | Helicopter rotor is drawn in GUI.
  callback | Callback ID.
  callback_param1 | First parameter (var 10) of the callback.
  callback_param2 | Second parameter (var 18) of the callback.

Definition at line 1073 of file newgrf_engine.cpp.

References Vehicle::cargo_type, Vehicle::engine_type, GroundVehicleCache::first_engine, SpecializedVehicle< T, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), VariableGRFFileProps< Tkey >::GetFirstSpriteGroupOf(), Vehicle::GetGroundVehicleCache(), Engine::grf_prop, Vehicle::IsGroundVehicle(), ResolverObject::root_spritegroup, CargoGRFFileProps::SG_DEFAULT, CargoGRFFileProps::SG_PURCHASE, BaseVehicle::type, VEH_TRAIN, WO_CACHED, WO_NONE, and WO_SELF.

## Member Function Documentation

## ◆ GetDebugID()

uint32_t VehicleResolverObject::GetDebugID | ( |  | ) | const
| overridevirtual

Get an identifier for the item being resolved.

This function is mainly intended for the callback profiling feature, and should return an identifier recognisable by the NewGRF developer.

Reimplemented from ResolverObject.

Definition at line 1047 of file newgrf_engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), self_scope, and VehicleScopeResolver::self_type.

## ◆ GetFeature()

GrfSpecFeature VehicleResolverObject::GetFeature | ( |  | ) | const
| overridevirtual

Get the feature number being resolved for.

This function is mainly intended for the callback profiling feature.

Reimplemented from ResolverObject.

Definition at line 1036 of file newgrf_engine.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::Get(), GSF_INVALID, self_scope, VehicleScopeResolver::self_type, VEH_AIRCRAFT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

## ◆ GetScope()

ScopeResolver * VehicleResolverObject::GetScope | ( | VarSpriteGroupScope | scope = `VSG_SCOPE_SELF`,
|  | uint8_t | relative = `0`
| ) |  |
| overridevirtual

Get a resolver for the scope.

Returns
  The resolver for the requested scope.

Reimplemented from ResolverObject.

Definition at line 318 of file newgrf_engine.cpp.

References Vehicle::engine_type, Vehicle::First(), GB(), ResolverObject::GetRegister(), ResolverObject::GetScope(), Vehicle::Move(), Vehicle::Next(), parent_scope, relative_scope, self_scope, VehicleScopeResolver::v, VSG_SCOPE_PARENT, VSG_SCOPE_RELATIVE, and VSG_SCOPE_SELF.

Referenced by FillNewGRFVehicleCache(), and NIHVehicle::Resolve().

## ◆ ResolveReal()

const SpriteGroup * VehicleResolverObject::ResolveReal | ( | const RealSpriteGroup & | group | ) | const
| overridevirtual

Get the real sprites of the grf.

Parameters

  group | Group to get.

Returns
  The available sprite group.

Reimplemented from ResolverObject.

Definition at line 1012 of file newgrf_engine.cpp.

References Vehicle::cargo, Vehicle::cargo_cap, Vehicle::current_order, Vehicle::First(), Order::GetLoadType(), Order::GetUnloadType(), Order::IsType(), RealSpriteGroup::loaded, RealSpriteGroup::loading, NoLoad, NoUnload, self_scope, VehicleCargoList::StoredCount(), and VehicleScopeResolver::v.

## Field Documentation

## ◆ cached_relative_count

uint8_t VehicleResolverObject::cached_relative_count

Relative position of the other vehicle.

Definition at line 60 of file newgrf_engine.h.

## ◆ parent_scope

VehicleScopeResolver VehicleResolverObject::parent_scope

Scope resolver for its parent vehicle.

Definition at line 57 of file newgrf_engine.h.

Referenced by GetScope().

## ◆ relative_scope

VehicleScopeResolver VehicleResolverObject::relative_scope

Scope resolver for an other vehicle in the chain.

Definition at line 59 of file newgrf_engine.h.

Referenced by GetScope().

## ◆ self_scope

VehicleScopeResolver VehicleResolverObject::self_scope

Scope resolver for the indicated vehicle.

Definition at line 56 of file newgrf_engine.h.

Referenced by GetDebugID(), GetFeature(), GetScope(), and ResolveReal().

The documentation for this struct was generated from the following files:

- src/newgrf_engine.h
- src/newgrf_engine.cpp