OpenTTD Source 20260311-master-g511d3794ce
ObjectScopeResolver Struct Reference

Object scope resolver. More...

#include <newgrf_object.h>

Inheritance diagram for ObjectScopeResolver:
ScopeResolver

Public Member Functions

 ObjectScopeResolver (ResolverObject &ro, Object *obj, const ObjectSpec *spec, TileIndex tile, uint8_t view=0)
 Constructor of an object scope resolver.
uint32_t GetRandomBits () const override
 Get a few random bits.
uint32_t GetVariable (uint8_t variable, uint32_t parameter, bool &available) const override
 Get a variable value.
Public Member Functions inherited from ScopeResolver
 ScopeResolver (ResolverObject &ro)
virtual ~ScopeResolver ()=default
 Ensure the destructor of the sub classes are called as well.
virtual uint32_t GetRandomTriggers () const
 Get the triggers.
virtual void StorePSA (uint reg, int32_t value)
 Store a value into the persistent storage area (PSA).

Data Fields

struct Objectobj
 The object the callback is ran for.
const ObjectSpecspec
 Specification of the object type.
TileIndex tile
 The tile related to the object.
uint8_t view
 The view of the object.
Data Fields inherited from ScopeResolver
ResolverObjectro
 Surrounding resolver object.

Detailed Description

Object scope resolver.

Definition at line 106 of file newgrf_object.h.

Constructor & Destructor Documentation

◆ ObjectScopeResolver()

ObjectScopeResolver::ObjectScopeResolver ( ResolverObject & ro,
Object * obj,
const ObjectSpec * spec,
TileIndex tile,
uint8_t view = 0 )
inline

Constructor of an object scope resolver.

Parameters
roSurrounding resolver.
objObject being resolved.
specThe specification of the object type.
tileTile of the object.
viewView of the object.

Definition at line 120 of file newgrf_object.h.

References obj, ScopeResolver::ro, spec, tile, and view.

Member Function Documentation

◆ GetRandomBits()

uint32_t ObjectScopeResolver::GetRandomBits ( ) const
overridevirtual

Get a few random bits.

Default implementation has no random bits.

Returns
Random bits.

Reimplemented from ScopeResolver.

Definition at line 159 of file newgrf_object.cpp.

References GetObjectRandomBits(), IsTileType(), IsValidTile(), Object, and tile.

◆ GetVariable()

uint32_t ObjectScopeResolver::GetVariable ( uint8_t variable,
uint32_t parameter,
bool & available ) const
overridevirtual

Get a variable value.

Default implementation has no available variables.

Parameters
variableVariable to read
parameterParameter for 60+x variables
[out]availableSet to false, in case the variable does not exist.
Returns
Value

Reimplemented from ScopeResolver.

Definition at line 261 of file newgrf_object.cpp.

References _current_company, ClampTo(), ClosestTownFromTile(), TimerGameCalendar::date, Debug, DistanceManhattan(), DistanceSquare(), GetAnimationFrame(), GetBadgeVariableResult(), Object::GetByTile(), GetCountAndDistanceOfClosestInstance(), GetNearbyObjectTileInformation(), GetNearbyTile(), GetObjectIDAtOffset(), GetObjectRandomBits(), GetTerrainType(), GetTileOwner(), GetTileSlope(), GetTownRadiusGroup(), IsTileType(), IsValidTile(), obj, Object, ScopeResolver::ro, tile, TileX(), TileY(), to_underlying(), view, and Town::xy.

Field Documentation

◆ obj

struct Object* ObjectScopeResolver::obj

The object the callback is ran for.

Definition at line 107 of file newgrf_object.h.

Referenced by GetVariable(), and ObjectScopeResolver().

◆ spec

const ObjectSpec* ObjectScopeResolver::spec

Specification of the object type.

Definition at line 108 of file newgrf_object.h.

Referenced by ObjectScopeResolver().

◆ tile

TileIndex ObjectScopeResolver::tile

The tile related to the object.

Definition at line 109 of file newgrf_object.h.

Referenced by GetRandomBits(), GetVariable(), and ObjectScopeResolver().

◆ view

uint8_t ObjectScopeResolver::view

The view of the object.

Definition at line 110 of file newgrf_object.h.

Referenced by GetVariable(), and ObjectScopeResolver().


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