OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
22 std::vector<T> id_count;
23 std::vector<T> class_count;
31 static const TownID INVALID_TOWN = 0xFFFF;
50 auto operator<=>(
const TownCache &)
const =
default;
60 uint32_t townnamegrfid;
61 uint16_t townnametype;
62 uint32_t townnameparts;
85 inline uint8_t GetPercentTransported(
CargoID cid)
const
88 return this->supplied[cid].
old_act * 256 / (this->supplied[cid].
old_max + 1);
106 std::list<PersistentStorage *> psa_list;
135 inline const std::string &GetCachedName()
const
137 if (!this->name.empty())
return this->
name;
138 if (this->cached_name.empty()) this->FillCachedName();
151 void FillCachedName()
const;
158 void ShowTownViewWindow(TownID town);
159 void ExpandTown(
Town *t);
161 void RebuildTownKdtree();
165 TOWN_COUNCIL_LENIENT = 0,
166 TOWN_COUNCIL_TOLERANT = 1,
167 TOWN_COUNCIL_HOSTILE = 2,
168 TOWN_COUNCIL_PERMISSIVE = 3,
184 TDIWD_POPULATION_CHANGE,
256 assert(obj->name.empty() || obj->town_cn == UINT16_MAX);
277 T *lobj = T::GetIfValid(cid);
280 if (lobj !=
nullptr && obj != lobj) {
282 if (lobj->town == obj->town && lobj->IsOfType(obj)) {
284 uint i = (uint)lobj->town_cn - next;
294 }
while (
HasBit(used, 0));
305 if (cid == T::GetPoolSize()) cid = 0;
306 }
while (cid != idx);
308 obj->town_cn = (uint16_t)next;
315 inline uint16_t TownTicksToGameTicks(uint16_t ticks)
323 std::span<const DrawBuildingsTileStruct> GetTownDrawTileData();
@ TACT_BRIBE
Try to bribe the council.
CompanyMask have_ratings
which companies have a rating
@ TACT_BUILD_STATUE
Build a statue.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
static Titem * Get(size_t index)
Returns Titem with given index.
void InitializeLayout(TownLayout layout)
Assign the town layout.
TownDirectoryInvalidateWindowData
Special values for town list window for the data parameter of InvalidateWindowData.
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
CompanyMask statues
which companies have a statue?
Owner
Enum for all companies/owners.
Tindex index
Index of this pool item.
@ TACT_FUND_BUILDINGS
Fund new buildings.
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
@ TACT_ADVERTISE
All possible advertising actions.
DifficultySettings difficulty
settings related to the difficulty
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
bool CheckTownRoadTypes()
Check if towns are able to build road.
uint16_t growth_rate
town growth rate
uint8_t town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
PartOfSubsidy part_of_subsidy
Is this town a source/destination of a subsidy?
Data structure with cached data of towns.
TileIndex xy
town center tile
Specification of a cargo type.
static const uint16_t MAX_TOWN_GROWTH_TICKS
Max amount of original town ticks that still fit into uint16_t, about equal to UINT16_MAX / TOWN_GROW...
uint16_t town_noise_population[4]
population to base decision on noise evaluation (
void UpdateTownRadius(Town *t)
Update the cached town zone radii of a town, based on the number of houses.
@ TACT_FUNDS
All possible funding actions.
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
static const uint16_t TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
bool show_zone
NOSAVE: mark town to show the local authority zone in the viewports.
@ TOWN_HAS_STADIUM
There can be only one stadium by town.
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road,...
DoCommandFlag
List of flags for a command.
void UpdateVirtCoord()
Resize the sign (label) of the town after it changes population.
uint8_t road_build_months
fund road reconstruction in action?
static Town * GetRandom()
Return a random valid town.
uint8_t flags
See TownFlags.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
RoadType GetTownRoadType()
Get the road type that towns should build at this current moment.
@ TACT_ADVERTISE_MEDIUM
Medium advertising campaign.
Town(TileIndex tile=INVALID_TILE)
Creates a new town.
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
TransportedCargoStat< uint32_t > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
static const uint CUSTOM_TOWN_MAX_NUMBER
this is the maximum number of towns a user can specify in customisation
@ TOWN_RATING_CHECK_TYPE_COUNT
Number of town checking action types.
Common return value for all commands.
uint16_t grow_counter
counter to count when to grow, value is smaller than or equal to growth_rate
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
TownRatingCheckType
Action types that a company must ask permission for to a town authority.
StationList stations_near
NOSAVE: List of nearby stations.
@ TACT_ROAD_REBUILD
Rebuild the roads.
uint16_t MaxTownNoise() const
Calculate the max town noise.
TownFlags
This enum is used in conjunction with town->flags.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
TownActions GetMaskOfTownActions(CompanyID cid, const Town *t)
Get a list of available town authority actions.
RoadType
The different roadtypes we support.
EconomySettings economy
settings to change the economy
uint8_t unwanted[MAX_COMPANIES]
how many months companies aren't wanted by towns (bribe)
void ClearAllTownCachedNames()
Clear the cached_name of all towns.
int32_t TileIndexDiff
An offset value between two tiles.
@ NUM_TAE
Amount of town effects.
const CargoSpec * FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
Determines the first cargo with a certain town effect.
std::set< Station *, StationCompare > StationList
List of stations.
@ TACT_ADVERTISE_LARGE
Large advertising campaign.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
@ TACT_CONSTRUCTION
All possible construction actions.
uint32_t population
Current population of people.
uint16_t time_until_rebuild
time until we rebuild a house
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).
Tstorage old_max
Maximum amount last month.
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
static void PostDestructor(size_t index)
Invalidating of the "nearest town cache" has to be done after removing item from the pool.
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
std::string text
General text with additional information.
TownAcceptanceEffect
Town growth effect when delivering cargo.
BuildingCounts< uint16_t > building_counts
The number of each type of building in the town.
Base class for all pools.
bool GenerateTowns(TownLayout layout)
Generate a number of towns with a given layout.
@ TACT_COUNT
Number of available town actions.
@ TACT_ADVERTISE_SMALL
Small advertising campaign.
uint32_t goal[NUM_TAE]
Amount of cargo required for the town to grow.
Tstorage old_act
Actually transported last month.
TownCache cache
Container for all cacheable data.
@ TOWN_IS_GROWING
Conditions for town growth are met. Grow according to Town::growth_rate.
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
uint16_t HouseID
OpenTTD ID of house types.
uint32_t num_houses
Amount of houses.
@ TACT_NONE
Empty action set.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
const uint8_t _town_action_costs[TACT_COUNT]
Factor in the cost of each town action.
std::array< uint32_t, HZB_END > squared_town_zone_radius
UpdateTownRadius updates this given the house count.
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.
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
TownLayout layout
town specific road layout
uint16_t noise_reached
level of noise that all the airports are generating
void UpdateTownMaxPass(Town *t)
Update the maximum amount of montly passengers and mail for a town, based on its population.
TownCouncilAttitudes
Settings for town council attitudes.
@ MAX_COMPANIES
Maximum number of companies.
bool larger_town
if this is a larger town and should grow more quickly
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
@ TUNNELBRIDGE_REMOVE
Removal of a tunnel or bridge owned by the towb.
uint32_t GetWorldPopulation()
Get the total population, the sum of all towns in the world.
@ ROAD_REMOVE
Removal of a road owned by the town.
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
CompanyID exclusivity
which company has exclusivity
@ TACT_ALL
All possible actions.
Base class for all PoolItems.
@ TOWN_CUSTOM_GROWTH
Growth rate is controlled by GS.
void SetTownRatingTestMode(bool mode)
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings...
@ TOWN_HAS_CHURCH
There can be only one church by town.
uint8_t exclusive_counter
months till the exclusivity expires
std::string cached_name
NOSAVE: Cache of the resolved name of the town, if not using a custom town name.
void ClearTownHouse(Town *t, TileIndex tile)
Clear a town house.
TownActions
Town actions of a company.
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
TrackedViewportSign sign
Location of name sign, UpdateVirtCoord updates this.
@ TACT_BUY_RIGHTS
Buy exclusive transport rights.
TownID GetTownIndex(Tile t)
Get the index of which town this house/street is attached to.
PartOfSubsidy
What part of a subsidy is something?
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.