OpenTTD Source 20261112-master-gbcbec5e63f
TownScopeResolver Struct Reference

Scope resolver for a town. More...

#include <newgrf_town.h>

Inheritance diagram for TownScopeResolver:
ScopeResolver

Public Member Functions

 TownScopeResolver (ResolverObject &ro, Town *t, bool readonly)
 Resolver of a town scope.
uint32_t GetVariable (uint8_t variable, uint32_t parameter, bool &available) const override
 Get a variable value.
void StorePSA (uint reg, int32_t value) override
 Store a value into the persistent storage area (PSA).
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 GetRandomBits () const
 Get a few random bits.
virtual uint32_t GetRandomTriggers () const
 Get the triggers.

Data Fields

Town * t
 Town of the scope.
bool readonly
 When set, persistent storage of the town is read-only,.
Data Fields inherited from ScopeResolver
ResolverObject & ro
 Surrounding resolver object.

Detailed Description

Scope resolver for a town.

Note
Currently there is no direct town resolver; we only need to get town variable results from inside stations, house tiles and industries, and to check the town's persistent storage.

Definition at line 22 of file newgrf_town.h.

Constructor & Destructor Documentation

◆ TownScopeResolver()

TownScopeResolver::TownScopeResolver ( ResolverObject & ro,
Town * t,
bool readonly )
inline

Resolver of a town scope.

Parameters
roSurrounding resolver.
tTown of the scope.
readonlyScope may change persistent storage of the town.

Definition at line 32 of file newgrf_town.h.

References readonly, ScopeResolver::ro, and t.

Member Function Documentation

◆ GetVariable()

uint32_t TownScopeResolver::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 88 of file newgrf_town.cpp.

References _settings_game, Town::AcceptedHistory::accepted, ClampTo(), CT_MAIL, CT_PASSENGERS, Food, GB(), GetCargoTypeByLabel(), GetNearbyTileInformation(), INVALID_GRFID, Town::SuppliedHistory::production, ScopeResolver::ro, t, to_underlying(), Ticks::TOWN_GROWTH_TICKS, TownAcceptanceHistoryHelperCargoID(), TownCentre, TownEdge, TownInnerSuburb, TownOuterSuburb, TownOutskirt, TownProductionHistoryHelper(), TownProductionHistoryHelperCargoID(), Town::SuppliedHistory::transported, UnflattenNewGRFLabel(), and Water.

◆ StorePSA()

void TownScopeResolver::StorePSA ( uint pos,
int32_t value )
overridevirtual

Store a value into the persistent storage area (PSA).

Default implementation does nothing (for newgrf classes without storage).

Parameters
posThe position into the storage area.
valueThe new value to store.

Reimplemented from ScopeResolver.

Definition at line 214 of file newgrf_town.cpp.

References FakeTowns, INVALID_GRFID, readonly, ScopeResolver::ro, PersistentStorageArray< TYPE, SIZE >::StoreValue(), t, and UnflattenNewGRFLabel().

Field Documentation

◆ readonly

bool TownScopeResolver::readonly

When set, persistent storage of the town is read-only,.

Definition at line 24 of file newgrf_town.h.

Referenced by StorePSA(), and TownScopeResolver().

◆ t

Town* TownScopeResolver::t

Town of the scope.

Definition at line 23 of file newgrf_town.h.

Referenced by GetVariable(), StorePSA(), and TownScopeResolver().


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