OpenTTD Source: ResolverObject Struct Reference

OpenTTD Source 13.1

Public Member Functions | Data Fields
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 callback_param1=0, uint32 callback_param2=0)
| Resolver constructor. More...
const SpriteGroup * | Resolve ()
| Resolve SpriteGroup. More...
uint16 | ResolveCallback ()
| Resolve callback. More...
virtual const SpriteGroup * | ResolveReal (const RealSpriteGroup *group) const
| Get the real sprites of the grf. More...
virtual ScopeResolver * | GetScope (VarSpriteGroupScope scope=VSG_SCOPE_SELF, byte relative=0)
| Get a resolver for the scope. More...
uint32 | GetRemainingTriggers () const
| Returns the waiting triggers that did not trigger any rerandomisation.
uint32 | GetReseedSum () const
| Returns the OR-sum of all bits that need reseeding independent of the scope they were accessed with. More...
void | ResetState ()
| Resets the dynamic state of the resolver object. More...
virtual GrfSpecFeature | GetFeature () const
| Get the feature number being resolved for. More...
virtual uint32 | GetDebugID () const
| Get an identifier for the item being resolved. More...

## Data Fields
ScopeResolver | default_scope
| Default implementation of the grf scope.
CallbackID | callback
| Callback being resolved.
uint32 | callback_param1
| First parameter (var 10) of the callback.
uint32 | callback_param2
| Second parameter (var 18) of the callback.
uint32 | last_value
| Result of most recent DeterministicSpriteGroup (including procedure calls)
uint32 | waiting_triggers
| Waiting triggers to be used by any rerandomisation. (scope independent)
uint32 | used_triggers
| Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent)
uint32 | reseed [VSG_END]
| Collects bits to rerandomise while triggering triggers.
const GRFFile * | grffile
| GRFFile the resolved SpriteGroup belongs to.
const SpriteGroup * | root_spritegroup
| Root SpriteGroup to use for resolving.

## 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 307 of file newgrf_spritegroup.h.

## Constructor & Destructor Documentation

## ◆ ResolverObject()

ResolverObject::ResolverObject | ( | const GRFFile * | grffile,
|  | CallbackID | callback = `CBID_NO_CALLBACK`,
|  | uint32 | callback_param1 = `0`,
|  | uint32 | 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 315 of file newgrf_spritegroup.h.

References ResetState().

## Member Function Documentation

## ◆ GetDebugID()

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

Definition at line 405 of file newgrf_spritegroup.h.

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

Definition at line 399 of file newgrf_spritegroup.h.

References GSF_INVALID.

## ◆ GetReseedSum()

uint32 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 374 of file newgrf_spritegroup.h.

## ◆ GetScope()

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

Get a resolver for the scope.

Parameters

  scope | Scope to return.
  relative | Additional parameter for VSG_SCOPE_RELATIVE.

Returns
  The resolver for the requested scope.

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

Definition at line 139 of file newgrf_spritegroup.cpp.

References default_scope.

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

## ◆ ResetState()

void ResolverObject::ResetState | ( |  | ) |
| inline

Resets the dynamic state of the resolver object.

To be called before resolving an Action-1-2-3 chain.

Definition at line 387 of file newgrf_spritegroup.h.

Referenced by ResolverObject().

## ◆ Resolve()

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

Resolve SpriteGroup.

Returns
  Result spritegroup.

Definition at line 342 of file newgrf_spritegroup.h.

References SpriteGroup::Resolve().

## ◆ ResolveCallback()

uint16 ResolverObject::ResolveCallback | ( |  | ) |
| inline

Resolve callback.

Returns
  Callback result.

Definition at line 351 of file newgrf_spritegroup.h.

## ◆ 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 StationResolverObject, and VehicleResolverObject.

Definition at line 125 of file newgrf_spritegroup.cpp.

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

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

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