20 if (this->
t ==
nullptr) {
34 case 0x41:
return this->
t->
index;
40 if (grfid == 0xFFFFFFFF) {
41 if (this->
ro.
grffile ==
nullptr)
return 0;
45 for (
auto &it : this->
t->psa_list) {
46 if (it->grfid == grfid)
return it->GetValue(parameter);
53 case 0x80:
return this->
t->
xy.base();
54 case 0x81:
return GB(this->
t->
xy.base(), 8, 8);
58 case 0x92:
return this->
t->
flags;
70 case 0x9E:
return this->
t->
ratings[0];
71 case 0x9F:
return GB(this->
t->
ratings[0], 8, 8);
72 case 0xA0:
return this->
t->
ratings[1];
73 case 0xA1:
return GB(this->
t->
ratings[1], 8, 8);
74 case 0xA2:
return this->
t->
ratings[2];
75 case 0xA3:
return GB(this->
t->
ratings[2], 8, 8);
76 case 0xA4:
return this->
t->
ratings[3];
77 case 0xA5:
return GB(this->
t->
ratings[3], 8, 8);
78 case 0xA6:
return this->
t->
ratings[4];
79 case 0xA7:
return GB(this->
t->
ratings[4], 8, 8);
80 case 0xA8:
return this->
t->
ratings[5];
81 case 0xA9:
return GB(this->
t->
ratings[5], 8, 8);
82 case 0xAA:
return this->
t->
ratings[6];
83 case 0xAB:
return GB(this->
t->
ratings[6], 8, 8);
84 case 0xAC:
return this->
t->
ratings[7];
85 case 0xAD:
return GB(this->
t->
ratings[7], 8, 8);
106 case 0xCA:
return this->
t->GetPercentTransported(GetCargoIDByLabel(
CT_PASSENGERS));
107 case 0xCB:
return this->
t->GetPercentTransported(GetCargoIDByLabel(CT_MAIL));
120 Debug(grf, 1,
"Unhandled town variable 0x{:X}", variable);
130 assert(this->
t !=
nullptr);
138 if (grfid == 0xFFFFFFFF) grfid = this->
ro.
grffile->grfid;
139 if (grfid != this->
ro.
grffile->grfid)
return;
142 for (
auto &it :
t->psa_list) {
143 if (it->grfid == grfid) {
144 it->StoreValue(pos, value);
153 t->psa_list.push_back(psa);
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
static constexpr CargoLabel CT_PASSENGERS
Available types of cargo Labels may be re-used between different climates.
@ TAE_FOOD
Cargo behaves food/fizzy-drinks-like.
@ TAE_WATER
Cargo behaves water-like.
static constexpr TimerGameTick::Ticks TOWN_GROWTH_TICKS
Cycle duration for towns trying to grow (this originates from the size of the town array in TTD).
Functions related to debugging.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
@ GSF_FAKE_TOWNS
Fake town GrfSpecFeature for NewGRF debugging (parent scope)
uint32_t GetRegister(uint i)
Gets the value of a so-called newgrf "register".
Functions to handle the town part of NewGRF towns.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of base types and functions in a cross-platform compatible way.
uint8_t larger_towns
the number of cities to build. These start off larger and grow twice as fast
Dynamic data of a loaded NewGRF.
EconomySettings economy
settings to change the economy
void StoreValue(uint pos, int32_t value)
Stores some value at a given position.
Class for pooled persistent storage of data.
Tindex index
Index of this pool item.
static bool CanAllocateItem(size_t n=1)
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function()
Interface for SpriteGroup-s to access the gamestate.
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
ResolverObject & ro
Surrounding resolver object.
uint32_t population
Current population of people.
uint32_t num_houses
Amount of houses.
std::array< uint32_t, HZB_END > squared_town_zone_radius
UpdateTownRadius updates this given the house count.
TownResolverObject(const struct GRFFile *grffile, Town *t, bool readonly)
Resolver for a town.
uint32_t GetVariable(uint8_t variable, uint32_t parameter, bool &available) const override
Get a variable value.
bool readonly
When set, persistent storage of the town is read-only,.
void StorePSA(uint reg, int32_t value) override
Store a value into the persistent storage area (PSA).
Town * t
Town of the scope.
bool larger_town
if this is a larger town and should grow more quickly
TransportedCargoStat< uint32_t > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
CompanyMask statues
which companies have a statue?
TileIndex xy
town center tile
uint8_t fund_buildings_months
fund buildings program in action?
int16_t ratings[MAX_COMPANIES]
ratings of each company for this town
TransportedCargoStat< uint16_t > received[NUM_TAE]
Cargo statistics about received cargotypes.
uint16_t grow_counter
counter to count when to grow, value is smaller than or equal to growth_rate
uint8_t flags
See TownFlags.
TownCache cache
Container for all cacheable data.
CompanyMask have_ratings
which companies have a rating
uint16_t growth_rate
town growth rate
uint8_t road_build_months
fund road reconstruction in action?
Tstorage new_max
Maximum amount this month.
Tstorage old_max
Maximum amount last month.
Tstorage old_act
Actually transported last month.
Tstorage new_act
Actually transported this month.
Definition of the tick-based game-timer.