OpenTTD Source: ResolverObject Struct Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Data Fields | Protected Attributes | Static Private Attributes
ResolverObject Struct Reference

Interface for SpriteGroup-s to access the gamestate. More...

`#include <newgrf_spritegroup.h>`

Inheritance diagram for ResolverObject:

## Public Member Functions
| 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.
virtual const SpriteGroup * | ResolveReal (const RealSpriteGroup &group) const
| Get the real sprites of the grf.
virtual ScopeResolver * | GetScope (VarSpriteGroupScope scope=VSG_SCOPE_SELF, uint8_t relative=0)
| Get a resolver for the scope.
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.
virtual GrfSpecFeature | GetFeature () const
| Get the feature number being resolved for.
virtual uint32_t | GetDebugID () const
| Get an identifier for the item being resolved.

## Data Fields
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.

## Protected Attributes
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)

## Static Private Attributes
static TemporaryStorageArray< int32_t, 0x110 > | temp_store

## Detailed Description

Interface for SpriteGroup-s to access the gamestate.

Using this interface SpriteGroup-chains (action 1-2-3 chains) can be resolved, to get the results of callbacks, rerandomisations or normal sprite lookups.

Definition at line 288 of file newgrf_spritegroup.h.

## Constructor & Destructor Documentation

## ◆ ResolverObject()

ResolverObject::ResolverObject | ( | const GRFFile * | grffile,
|  | CallbackID | callback = `CBID_NO_CALLBACK`,
|  | uint32_t | callback_param1 = `0`,
|  | uint32_t | callback_param2 = `0`
| ) |  |
| inline

Resolver constructor.

Parameters

  grffile | NewGRF file associated with the object (or `nullptr` if none).
  callback | Callback code being resolved (default value is CBID_NO_CALLBACK).
  callback_param1 | First parameter (var 10) of the callback (only used when callback is also set).
  callback_param2 | Second parameter (var 18) of the callback (only used when callback is also set).

Definition at line 300 of file newgrf_spritegroup.h.

## Member Function Documentation

## ◆ AddUsedRandomTriggers()

void ResolverObject::AddUsedRandomTriggers | ( | uint32_t | triggers | ) |
| inline

Used by RandomizedSpriteGroup: Consume triggers.

Definition at line 414 of file newgrf_spritegroup.h.

## ◆ DoResolve()

ResolverResult ResolverObject::DoResolve | ( |  | ) |
| inline

Definition at line 307 of file newgrf_spritegroup.h.

## ◆ GetDebugID()

virtual uint32_t ResolverObject::GetDebugID | ( |  | ) | const
| inlinevirtual

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 in AirportResolverObject, AirportTileResolverObject, BadgeResolverObject, CanalResolverObject, CargoResolverObject, VehicleResolverObject, GenericResolverObject, HouseResolverObject, IndustriesResolverObject, IndustryTileResolverObject, ObjectResolverObject, RailTypeResolverObject, RoadTypeResolverObject, and StationResolverObject.

Definition at line 443 of file newgrf_spritegroup.h.

Referenced by NewGRFProfiler::BeginResolve().

## ◆ GetFeature()

virtual GrfSpecFeature ResolverObject::GetFeature | ( |  | ) | const
| inlinevirtual

Get the feature number being resolved for.

This function is mainly intended for the callback profiling feature.

Reimplemented in AirportResolverObject, AirportTileResolverObject, BadgeResolverObject, CanalResolverObject, CargoResolverObject, VehicleResolverObject, GenericResolverObject, HouseResolverObject, IndustriesResolverObject, IndustryTileResolverObject, ObjectResolverObject, RailTypeResolverObject, RoadTypeResolverObject, and StationResolverObject.

Definition at line 437 of file newgrf_spritegroup.h.

References GSF_INVALID.

Referenced by NewGRFProfiler::BeginResolve().

## ◆ GetRegister()

int32_t ResolverObject::GetRegister | ( | uint | i | ) | const
| inline

Gets the value of a so-called newgrf "register".

Parameters

  i | index of the register

Returns
  the value of the register

Precondition
  i < 0x110

Definition at line 324 of file newgrf_spritegroup.h.

References TemporaryStorageArray< TYPE, SIZE >::GetValue().

Referenced by VehicleResolverObject::GetScope(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), ResolveCallback(), and TownScopeResolver::StorePSA().

## ◆ GetReseedSum()

uint32_t ResolverObject::GetReseedSum | ( |  | ) | const
| inline

Returns the OR-sum of all bits that need reseeding independent of the scope they were accessed with.

Returns
  OR-sum of the bits.

Definition at line 424 of file newgrf_spritegroup.h.

## ◆ GetScope()

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

Get a resolver for the scope.

Returns
  The resolver for the requested scope.

Reimplemented in AirportResolverObject, AirportTileResolverObject, BadgeResolverObject, CanalResolverObject, VehicleResolverObject, GenericResolverObject, HouseResolverObject, IndustriesResolverObject, IndustryTileResolverObject, ObjectResolverObject, RailTypeResolverObject, RoadStopResolverObject, RoadTypeResolverObject, StationResolverObject, and TownResolverObject.

Definition at line 133 of file newgrf_spritegroup.cpp.

References default_scope.

Referenced by AirportResolverObject::GetScope(), AirportTileResolverObject::GetScope(), BadgeResolverObject::GetScope(), CanalResolverObject::GetScope(), VehicleResolverObject::GetScope(), GenericResolverObject::GetScope(), HouseResolverObject::GetScope(), IndustriesResolverObject::GetScope(), IndustryTileResolverObject::GetScope(), ObjectResolverObject::GetScope(), RailTypeResolverObject::GetScope(), RoadStopResolverObject::GetScope(), RoadTypeResolverObject::GetScope(), StationResolverObject::GetScope(), and TownResolverObject::GetScope().

## ◆ GetWaitingRandomTriggers()

uint32_t ResolverObject::GetWaitingRandomTriggers | ( |  | ) | const
| inline

Used by RandomizedSpriteGroup: Triggers for rerandomisation.

Definition at line 406 of file newgrf_spritegroup.h.

References waiting_random_triggers.

## ◆ Resolve()

template<class TSpriteGroup >

const TSpriteGroup * ResolverObject::Resolve | ( |  | ) |
| inline

Resolve SpriteGroup.

Returns
  Result spritegroup.

Template Parameters

  TSpriteGroup | Sprite group type

Definition at line 361 of file newgrf_spritegroup.h.

## ◆ ResolveCallback()

CallbackResult ResolverObject::ResolveCallback | ( | std::span< int32_t > | regs100 | ) |
| inline

Resolve callback.

Parameters

  [out] | regs100 | Additional result values from registers 100+

Returns
  Callback result.

Definition at line 388 of file newgrf_spritegroup.h.

References CALLBACK_FAILED, and GetRegister().

## ◆ ResolveReal()

const SpriteGroup * ResolverObject::ResolveReal | ( | const RealSpriteGroup & | group | ) | const
| virtual

Get the real sprites of the grf.

Parameters

  group | Group to get.

Returns
  The available sprite group.

Reimplemented in VehicleResolverObject, and StationResolverObject.

Definition at line 121 of file newgrf_spritegroup.cpp.

References RealSpriteGroup::loaded, and RealSpriteGroup::loading.

## ◆ ResolveRerandomisation()

void ResolverObject::ResolveRerandomisation | ( |  | ) |
| inline

Resolve bits to be rerandomised.

Access results via:

- reseed: Bits to rerandomise per scope, for features with proper PARENT rerandomisation. (only industry tiles)
- GetReseedSum: Bits to rerandomise for SELF scope, for features with broken-by-design PARENT randomisation. (all but industry tiles)
- GetUsedRandomTriggers: Consumed random triggers to be reset.

Definition at line 376 of file newgrf_spritegroup.h.

## ◆ SetRegister()

void ResolverObject::SetRegister | ( | uint | i,
|  | int32_t | value
| ) |  |
| inline

Sets the value of a so-called newgrf "register".

Parameters

  i | index of the register
  value | the value of the register

Precondition
  i < 0x110

Definition at line 335 of file newgrf_spritegroup.h.

References TemporaryStorageArray< TYPE, SIZE >::StoreValue().

## Field Documentation

## ◆ callback

CallbackID ResolverObject::callback {}

Callback being resolved.

Definition at line 340 of file newgrf_spritegroup.h.

Referenced by NewGRFProfiler::BeginResolve(), and IndustriesScopeResolver::GetVariable().

## ◆ callback_param1

uint32_t ResolverObject::callback_param1 = 0

First parameter (var 10) of the callback.

Definition at line 341 of file newgrf_spritegroup.h.

## ◆ callback_param2

uint32_t ResolverObject::callback_param2 = 0

Second parameter (var 18) of the callback.

Definition at line 342 of file newgrf_spritegroup.h.

## ◆ default_scope

ScopeResolver ResolverObject::default_scope

Default implementation of the grf scope.

Definition at line 316 of file newgrf_spritegroup.h.

Referenced by GetScope().

## ◆ grffile

const GRFFile* ResolverObject::grffile = nullptr

GRFFile the resolved SpriteGroup belongs to.

Definition at line 352 of file newgrf_spritegroup.h.

Referenced by AirportScopeResolver::GetVariable(), AirportTileScopeResolver::GetVariable(), VehicleScopeResolver::GetVariable(), GenericScopeResolver::GetVariable(), HouseScopeResolver::GetVariable(), IndustriesScopeResolver::GetVariable(), IndustryTileScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), RailTypeScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), RoadTypeScopeResolver::GetVariable(), StationScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), AirportScopeResolver::StorePSA(), and TownScopeResolver::StorePSA().

## ◆ last_value

uint32_t ResolverObject::last_value = 0

Result of most recent DeterministicSpriteGroup (including procedure calls)

Definition at line 344 of file newgrf_spritegroup.h.

## ◆ reseed

std::array<uint32_t, VSG_END> ResolverObject::reseed

Collects bits to rerandomise while triggering triggers.

Definition at line 350 of file newgrf_spritegroup.h.

## ◆ root_spritegroup

const SpriteGroup* ResolverObject::root_spritegroup = nullptr

Root SpriteGroup to use for resolving.

Definition at line 353 of file newgrf_spritegroup.h.

Referenced by AirportResolverObject::AirportResolverObject(), AirportTileResolverObject::AirportTileResolverObject(), BadgeResolverObject::BadgeResolverObject(), NewGRFProfiler::BeginResolve(), CanalResolverObject::CanalResolverObject(), CargoResolverObject::CargoResolverObject(), HouseResolverObject::HouseResolverObject(), IndustriesResolverObject::IndustriesResolverObject(), IndustryTileResolverObject::IndustryTileResolverObject(), ObjectResolverObject::ObjectResolverObject(), RailTypeResolverObject::RailTypeResolverObject(), RoadTypeResolverObject::RoadTypeResolverObject(), StationResolverObject::StationResolverObject(), and VehicleResolverObject::VehicleResolverObject().

## ◆ temp_store

TemporaryStorageArray< int32_t, 0x110 > ResolverObject::temp_store
| staticprivate

Definition at line 290 of file newgrf_spritegroup.h.

## ◆ used_random_triggers

uint32_t ResolverObject::used_random_triggers = 0
| protected

Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent)

Definition at line 348 of file newgrf_spritegroup.h.

Referenced by SpecializedResolverObject< RandomTriggers >::GetUsedRandomTriggers().

## ◆ waiting_random_triggers

uint32_t ResolverObject::waiting_random_triggers = 0
| protected

Waiting triggers to be used by any rerandomisation. (scope independent)

Definition at line 347 of file newgrf_spritegroup.h.

Referenced by GetWaitingRandomTriggers(), and SpecializedResolverObject< RandomTriggers >::SetWaitingRandomTriggers().

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

- src/newgrf_spritegroup.h
- src/newgrf_spritegroup.cpp