OpenTTD Source  20241108-master-g80f628063a
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. More...
 
uint32_t GetVariable (uint8_t variable, [[maybe_unused]] uint32_t parameter, bool &available) const override
 Get a variable value. More...
 
void StorePSA (uint reg, int32_t value) override
 Store a value into the persistent storage area (PSA). More...
 
- Public Member Functions inherited from ScopeResolver
 ScopeResolver (ResolverObject &ro)
 
virtual uint32_t GetRandomBits () const
 Get a few random bits. More...
 
virtual uint32_t GetTriggers () const
 Get the triggers. More...
 

Data Fields

Townt
 Town of the scope.
 
bool readonly
 When set, persistent storage of the town is read-only,.
 
- Data Fields inherited from ScopeResolver
ResolverObjectro
 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.

Member Function Documentation

◆ GetVariable()

uint32_t TownScopeResolver::GetVariable ( uint8_t  variable,
[[maybe_unused] ] 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 18 of file newgrf_town.cpp.

References _settings_game, Town::cache, GameSettings::economy, Town::flags, GB(), GetRegister(), ResolverObject::grffile, Town::grow_counter, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Town::larger_town, EconomySettings::larger_towns, TownCache::population, ScopeResolver::ro, TownCache::squared_town_zone_radius, t, Ticks::TOWN_GROWTH_TICKS, and Town::xy.

◆ StorePSA()

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

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

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

Reimplemented from ScopeResolver.

Definition at line 126 of file newgrf_town.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool >::CanAllocateItem(), GetRegister(), ResolverObject::grffile, GSF_FAKE_TOWNS, readonly, ScopeResolver::ro, PersistentStorageArray< TYPE, SIZE >::StoreValue(), t, and Town::xy.


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