30 if (it == std::end(t->
supplied))
return 0;
49 auto it = t->GetCargoSupplied(cargo);
50 if (it == std::end(t->
supplied))
return 0;
70 if (it == std::end(t->
accepted))
return 0;
90 if (this->
t ==
nullptr) {
99 if (this->
t->larger_town)
return 1;
103 case 0x41:
return this->
t->index.base();
129 if (this->
ro.grffile ==
nullptr)
return 0;
130 grfid = this->
ro.grffile->grfid;
133 for (
auto &it : this->
t->psa_list) {
134 if (it->grfid == grfid)
return it->GetValue(parameter);
141 case 0x80:
return this->
t->xy.base();
142 case 0x81:
return GB(this->
t->xy.base(), 8, 8);
146 case 0x92:
return this->
t->flags.base();
158 case 0x9E:
return this->
t->ratings[CompanyID{0}];
159 case 0x9F:
return GB(this->
t->ratings[CompanyID{0}], 8, 8);
160 case 0xA0:
return this->
t->ratings[CompanyID{1}];
161 case 0xA1:
return GB(this->
t->ratings[CompanyID{1}], 8, 8);
162 case 0xA2:
return this->
t->ratings[CompanyID{2}];
163 case 0xA3:
return GB(this->
t->ratings[CompanyID{2}], 8, 8);
164 case 0xA4:
return this->
t->ratings[CompanyID{3}];
165 case 0xA5:
return GB(this->
t->ratings[CompanyID{3}], 8, 8);
166 case 0xA6:
return this->
t->ratings[CompanyID{4}];
167 case 0xA7:
return GB(this->
t->ratings[CompanyID{4}], 8, 8);
168 case 0xA8:
return this->
t->ratings[CompanyID{5}];
169 case 0xA9:
return GB(this->
t->ratings[CompanyID{5}], 8, 8);
170 case 0xAA:
return this->
t->ratings[CompanyID{6}];
171 case 0xAB:
return GB(this->
t->ratings[CompanyID{6}], 8, 8);
172 case 0xAC:
return this->
t->ratings[CompanyID{7}];
173 case 0xAD:
return GB(this->
t->ratings[CompanyID{7}], 8, 8);
174 case 0xAE:
return this->
t->have_ratings.base();
175 case 0xB2:
return this->
t->statues.base();
204 case 0xD4:
return this->
t->road_build_months;
205 case 0xD5:
return this->
t->fund_buildings_months;
208 this->
ro.UnhandledVariable(variable);
218 assert(this->
t !=
nullptr);
220 if (this->
ro.grffile ==
nullptr)
return;
227 if (grfid != this->
ro.grffile->grfid)
return;
230 for (
auto &it :
t->psa_list) {
231 if (it->grfid == grfid) {
232 it->StoreValue(pos, value);
241 t->psa_list.push_back(psa);
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Label< struct CargoLabelTag > CargoLabel
Globally unique label of a cargo type.
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
static constexpr CargoLabel CT_MAIL
Cargo label for mail.
static constexpr CargoLabel CT_PASSENGERS
Cargo label for passengers.
CargoType
Cargo slots to indicate a cargo type within a game.
CargoType GetCargoTypeByLabel(CargoLabel label)
Get cargo assigned to a label.
@ Food
Cargo behaves food/fizzy-drinks-like.
@ 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.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
@ TownOuterSuburb
Outer suburbs; roads with pavement.
@ TownInnerSuburb
Inner suburbs; roads with pavement and trees.
@ TownOutskirt
Outskirts of a town; roads without pavement.
@ TownEdge
Edge of the town; roads without pavement.
@ TownCentre
Centre of town; roads with pavement and streetlights.
constexpr To ClampTo(From value)
Clamp the given value down to lie within the requested type.
constexpr T UnflattenNewGRFLabel(uint32_t value)
Unflatten a NewGRF related label from a 32 bits integer.
@ FakeTowns
Fake town GrfSpecFeature for NewGRF debugging (parent scope).
CargoType GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit)
Translate a GRF-local cargo slot/bitnum into a CargoType.
Cargo support for NewGRFs.
uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8)
Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62,...
TileIndex GetNearbyTile(uint8_t parameter, TileIndex tile, bool signed_offsets, Axis axis)
Get the tile at the given offset.
static uint32_t TownProductionHistoryHelperCargoID(const Town *t, uint32_t parameter, const GRFFile *grffile, uint period, auto proj)
Get cargo production/transport history for a town via cargo translation table.
static uint32_t TownAcceptanceHistoryHelperCargoID(const Town *t, uint32_t parameter, const GRFFile *grffile, uint period, auto proj)
Get cargo acceptance history for a town via cargo translation table.
static uint16_t TownProductionHistoryHelper(const Town *t, CargoLabel label, uint period, auto proj)
Get cargo production/transport history for a town via cargo label.
static uint32_t GetNearbyTileInformation(uint8_t parameter, TileIndex tile, bool grf_version8)
Get information about a nearby tile.
Functions to handle the town part of NewGRF towns.
static const GrfID INVALID_GRFID
An invalid NewGRF.
Label< struct GrfIDTag > GrfID
The unique identifier of a NewGRF.
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.
Dynamic data of a loaded NewGRF.
void StoreValue(uint pos, int32_t value)
Stores some value at a given position.
Class for pooled persistent storage of data.
static T * Create(Targs &&... args)
static bool CanAllocateItem(size_t n=1)
const GRFFile * grffile
GRFFile the resolved SpriteGroup belongs to.
ResolverObject(const GRFFile *grffile, CallbackID callback=CBID_NO_CALLBACK, uint32_t callback_param1=0, uint32_t callback_param2=0)
Resolver constructor.
ResolverObject & ro
Surrounding resolver object.
TownScopeResolver town_scope
Scope resolver specific for towns.
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.
uint32_t accepted
Total accepted.
uint32_t transported
Total transported.
uint32_t production
Total produced.
SuppliedCargoes supplied
Cargo statistics about supplied cargo.
AcceptedCargoes::const_iterator GetCargoAccepted(CargoType cargo) const
Get iterator to the storage for an accepted cargo.
AcceptedCargoes accepted
Cargo statistics about accepted cargo.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
Definition of the tick-based game-timer.