OpenTTD Source 20241224-master-gee860a5c8e
|
#include <town.h>
Public Member Functions | |
uint8_t | GetPercentTransported (CargoID cid) const |
Town (TileIndex tile=INVALID_TILE) | |
Creates a new town. | |
~Town () | |
Destroy the town. | |
void | InitializeLayout (TownLayout layout) |
Assign the town layout. | |
uint16_t | MaxTownNoise () const |
Calculate the max town noise. | |
void | UpdateVirtCoord () |
Resize the sign (label) of the town after it changes population. | |
const std::string & | GetCachedName () const |
Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool > | |
void * | operator new (size_t size) |
Allocates space for new Titem. | |
void * | operator new (size_t size, size_t index) |
Allocates space for new Titem with given index. | |
void * | operator new (size_t, void *ptr) |
Allocates space for new Titem at given memory address. | |
void | operator delete (void *p) |
Marks Titem as free. | |
Static Public Member Functions | |
static Town * | GetByTile (TileIndex tile) |
static Town * | GetRandom () |
Return a random valid town. | |
static void | PostDestructor (size_t index) |
Invalidating of the "nearest town cache" has to be done after removing item from the pool. | |
Static Public Member Functions inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool > | |
static bool | CanAllocateItem (size_t n=1) |
Helper functions so we can use PoolItem::Function() instead of _poolitem_pool.Function() | |
static bool | CleaningPool () |
Returns current state of pool cleaning - yes or no. | |
static bool | IsValidID (size_t index) |
Tests whether given index can be used to get valid (non-nullptr) Titem. | |
static Titem * | Get (size_t index) |
Returns Titem with given index. | |
static Titem * | GetIfValid (size_t index) |
Returns Titem with given index. | |
static size_t | GetPoolSize () |
Returns first unused index. | |
static size_t | GetNumItems () |
Returns number of valid items in the pool. | |
static void | PostDestructor (size_t index) |
Dummy function called after destructor of each member. | |
static Pool::IterateWrapper< Titem > | Iterate (size_t from=0) |
Returns an iterable ensemble of all valid Titem. | |
Data Fields | |
TileIndex | xy |
town center tile | |
TownCache | cache |
Container for all cacheable data. | |
uint32_t | townnamegrfid |
uint16_t | townnametype |
uint32_t | townnameparts |
std::string | name |
Custom town name. If empty, the town was not renamed and uses the generated name. | |
std::string | cached_name |
NOSAVE: Cache of the resolved name of the town, if not using a custom town name. | |
uint8_t | flags |
See TownFlags. | |
uint16_t | noise_reached |
level of noise that all the airports are generating | |
CompanyMask | statues |
which companies have a statue? | |
CompanyMask | have_ratings |
which companies have a rating | |
uint8_t | unwanted [MAX_COMPANIES] |
how many months companies aren't wanted by towns (bribe) | |
CompanyID | exclusivity |
which company has exclusivity | |
uint8_t | exclusive_counter |
months till the exclusivity expires | |
int16_t | ratings [MAX_COMPANIES] |
ratings of each company for this town | |
TransportedCargoStat< uint32_t > | supplied [NUM_CARGO] |
Cargo statistics about supplied cargo. | |
TransportedCargoStat< uint16_t > | received [NUM_TAE] |
Cargo statistics about received cargotypes. | |
uint32_t | goal [NUM_TAE] |
Amount of cargo required for the town to grow. | |
std::string | text |
General text with additional information. | |
StationList | stations_near |
NOSAVE: List of nearby stations. | |
uint16_t | time_until_rebuild |
time until we rebuild a house | |
uint16_t | grow_counter |
counter to count when to grow, value is smaller than or equal to growth_rate | |
uint16_t | growth_rate |
town growth rate | |
uint8_t | fund_buildings_months |
fund buildings program in action? | |
uint8_t | road_build_months |
fund road reconstruction in action? | |
bool | larger_town |
if this is a larger town and should grow more quickly | |
TownLayout | layout |
town specific road layout | |
bool | show_zone |
NOSAVE: mark town to show the local authority zone in the viewports. | |
std::vector< PersistentStorage * > | psa_list |
Data Fields inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool > | |
Tindex | index |
Index of this pool item. | |
Private Member Functions | |
void | FillCachedName () const |
Additional Inherited Members | |
Public Types inherited from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool > | |
typedef struct Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero > | Pool |
Type of the pool this item is going to be part of. | |
|
inline |
Town::~Town | ( | ) |
Destroy the town.
Definition at line 110 of file town_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::CleaningPool(), CloseWindowById(), DeleteNewGRFInspectWindow(), DeleteSubsidyWith(), GetTileType(), GetTownIndex(), GSF_FAKE_TOWNS, HasTownOwnedRoad(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::index, CargoPacket::InvalidateAllFrom(), Map::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), MarkWholeScreenDirty(), MP_HOUSE, MP_ROAD, MP_TUNNELBRIDGE, TestTownOwnsBridge(), Town, and WC_TOWN_VIEW.
|
private |
Definition at line 216 of file town_cmd.cpp.
|
inline |
|
static |
Return a random valid town.
Definition at line 196 of file town_cmd.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetPoolSize(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), MAX_UVALUE, and RandomRange().
Referenced by FindSubsidyCargoDestination(), FindSubsidyPassengerRoute(), and FindSubsidyTownCargoRoute().
void Town::InitializeLayout | ( | TownLayout | layout | ) |
Assign the town layout.
layout | The desired layout. If TL_RANDOM, we pick one based on TileHash. |
Definition at line 182 of file town_cmd.cpp.
References layout, NUM_TLS, TileHash(), TileX(), TileY(), TL_RANDOM, and xy.
Referenced by DoCreateTown().
|
inline |
Calculate the max town noise.
The value is counted using the population divided by the content of the entry in town_noise_population corresponding to the town's tolerance.
Definition at line 125 of file town.h.
References _settings_game, GameSettings::difficulty, GameSettings::economy, TownCache::population, DifficultySettings::town_council_tolerance, and EconomySettings::town_noise_population.
Referenced by CmdBuildAirport(), and TownViewWindow::DrawWidget().
|
static |
Invalidating of the "nearest town cache" has to be done after removing item from the pool.
Definition at line 167 of file town_cmd.cpp.
References CalcClosestTownFromTile(), InvalidateWindowData(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), UpdateNearestTownForRoadTiles(), and WC_TOWN_DIRECTORY.
void Town::UpdateVirtCoord | ( | ) |
Resize the sign (label) of the town after it changes population.
Definition at line 409 of file town_cmd.cpp.
References _settings_client, cache, ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::index, Kdtree< T, TxyFunc, CoordT, DistT >::Insert(), TrackedViewportSign::kdtree_valid, TownCache::population, GUISettings::population_in_label, RemapCoords2(), Kdtree< T, TxyFunc, CoordT, DistT >::Remove(), SetDParam(), SetWindowDirty(), TownCache::sign, TILE_SIZE, TileX(), TileY(), TrackedViewportSign::UpdatePosition(), WC_TOWN_VIEW, and xy.
Referenced by ChangePopulation(), CmdFoundTown(), CmdRenameTown(), and DoCreateTown().
TownCache Town::cache |
Container for all cacheable data.
Definition at line 57 of file town.h.
Referenced by BuildTownHouse(), ChangePopulation(), CheckIfIndustryIsAllowed(), CheckSubsidised(), ClearTownHouse(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), CmdDeleteTown(), CmdExpandTown(), CreateRandomTown(), DecreaseBuildingCount(), DoCreateTown(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), FindSubsidyPassengerRoute(), FindSubsidyTownCargoRoute(), TownViewWindow::GetDesiredInfoHeight(), GetNormalGrowthRate(), TownScopeResolver::GetVariable(), GrowTownAtRoad(), GrowTownWithBridge(), GrowTownWithTunnel(), IncreaseBuildingCount(), InitializeBuildingCounts(), LoadTownData(), RebuildTownCaches(), TownDirectoryWindow::TownPopulationSorter(), TryBuildTownHouse(), UpdateTownGrowth(), UpdateTownMaxPass(), UpdateTownRadius(), and UpdateVirtCoord().
|
mutable |
NOSAVE: Cache of the resolved name of the town, if not using a custom town name.
Definition at line 64 of file town.h.
Referenced by CmdRenameTown().
uint8_t Town::exclusive_counter |
months till the exclusivity expires
Definition at line 76 of file town.h.
Referenced by DoCreateTown(), StationViewWindow::DrawCargoRatings(), GetMaskOfTownActions(), MayLoadUnderExclusiveRights(), TownActionBribe(), and TownActionBuyRights().
CompanyID Town::exclusivity |
which company has exclusivity
Definition at line 75 of file town.h.
Referenced by DoCreateTown(), StationViewWindow::DrawCargoRatings(), TownAuthorityWindow::DrawRatings(), GetMaskOfTownActions(), MayLoadUnderExclusiveRights(), TownActionBribe(), and TownActionBuyRights().
uint8_t Town::flags |
See TownFlags.
Definition at line 66 of file town.h.
Referenced by ClearTownHouse(), CmdTownGrowthRate(), DoCreateTown(), TownViewWindow::DrawWidget(), TownScopeResolver::GetVariable(), TileLoop_Town(), TownTickHandler(), TryBuildTownHouse(), UpdateTownGrowth(), and UpdateTownGrowthRate().
uint8_t Town::fund_buildings_months |
fund buildings program in action?
Definition at line 98 of file town.h.
Referenced by DoCreateTown(), TownViewWindow::DrawWidget(), GetNormalGrowthRate(), GetTownRadiusGroup(), TownScopeResolver::GetVariable(), TownActionFundBuildings(), and UpdateTownGrowth().
uint32_t Town::goal[NUM_TAE] |
Amount of cargo required for the town to grow.
Definition at line 81 of file town.h.
Referenced by CmdTownCargoGoal(), DoCreateTown(), TownViewWindow::DrawWidget(), TownViewWindow::GetDesiredInfoHeight(), and UpdateTownGrowth().
uint16_t Town::grow_counter |
counter to count when to grow, value is smaller than or equal to growth_rate
Definition at line 95 of file town.h.
Referenced by CmdTownGrowthRate(), DoCreateTown(), TownScopeResolver::GetVariable(), TownActionFundBuildings(), TownTickHandler(), and UpdateTownGrowCounter().
uint16_t Town::growth_rate |
town growth rate
Definition at line 96 of file town.h.
Referenced by CmdTownGrowthRate(), DoCreateTown(), TownViewWindow::DrawWidget(), TownScopeResolver::GetVariable(), TownActionFundBuildings(), TownTickHandler(), UpdateTownGrowCounter(), UpdateTownGrowth(), and UpdateTownGrowthRate().
CompanyMask Town::have_ratings |
which companies have a rating
Definition at line 73 of file town.h.
Referenced by ChangeTownRating(), DoCreateTown(), TownAuthorityWindow::DrawRatings(), TownDirectoryWindow::DrawWidget(), TownScopeResolver::GetVariable(), and TownDirectoryWindow::TownRatingSorter().
bool Town::larger_town |
if this is a larger town and should grow more quickly
Definition at line 101 of file town.h.
Referenced by DoCreateTown(), GetNormalGrowthRate(), TownDirectoryWindow::GetTownString(), and TownScopeResolver::GetVariable().
TownLayout Town::layout |
town specific road layout
Definition at line 102 of file town.h.
Referenced by GetTownRoadGridElement(), GrowTownAtRoad(), GrowTownInTile(), InitializeLayout(), IsRoadAllowedHere(), TownLayoutAllows2x2HouseHere(), and TownLayoutAllowsHouseHere().
std::string Town::name |
Custom town name. If empty, the town was not renamed and uses the generated name.
Definition at line 63 of file town.h.
Referenced by CmdFoundTown(), CmdRenameTown(), FormatString(), GenerateCompanyName(), IsUniqueTownName(), and MoveBuoysToWaypoints().
uint16_t Town::noise_reached |
level of noise that all the airports are generating
Definition at line 68 of file town.h.
Referenced by CmdBuildAirport(), TownViewWindow::DrawWidget(), RemoveAirport(), and UpdateAirportsNoise().
std::vector<PersistentStorage *> Town::psa_list |
int16_t Town::ratings[MAX_COMPANIES] |
ratings of each company for this town
Definition at line 77 of file town.h.
Referenced by ChangeTownRating(), CheckIfAuthorityAllowsNewStation(), ClearTile_Town(), CmdTownRating(), DoCreateTown(), TownAuthorityWindow::DrawRatings(), TownDirectoryWindow::DrawWidget(), GetMaskOfTownActions(), GetRating(), TownScopeResolver::GetVariable(), TownActionBribe(), TownDirectoryWindow::TownRatingSorter(), and UpdateTownRating().
TransportedCargoStat<uint16_t> Town::received[NUM_TAE] |
Cargo statistics about received cargotypes.
Definition at line 80 of file town.h.
Referenced by DeliverGoods(), TownViewWindow::DrawWidget(), TownScopeResolver::GetVariable(), and UpdateTownGrowth().
uint8_t Town::road_build_months |
fund road reconstruction in action?
Definition at line 99 of file town.h.
Referenced by TownScopeResolver::GetVariable(), and TownActionRoadRebuild().
bool Town::show_zone |
NOSAVE: mark town to show the local authority zone in the viewports.
Definition at line 104 of file town.h.
Referenced by DoCreateTown(), HighlightTownLocalAuthorityTiles(), TownAuthorityWindow::OnClick(), and TownAuthorityWindow::OnPaint().
StationList Town::stations_near |
NOSAVE: List of nearby stations.
Definition at line 91 of file town.h.
Referenced by GetTileHighlightType(), MakeTownHouse(), Station::RecomputeCatchment(), and RemoveNearbyStations().
CompanyMask Town::statues |
which companies have a statue?
Definition at line 70 of file town.h.
Referenced by DoCreateTown(), GetMaskOfTownActions(), TownScopeResolver::GetVariable(), and TownActionBuildStatue().
TransportedCargoStat<uint32_t> Town::supplied[NUM_CARGO] |
Cargo statistics about supplied cargo.
Definition at line 79 of file town.h.
Referenced by TownViewWindow::DrawWidget(), TownScopeResolver::GetVariable(), TownGenerateCargo(), and UpdateTownMaxPass().
std::string Town::text |
General text with additional information.
Definition at line 83 of file town.h.
Referenced by CmdTownSetText(), TownViewWindow::DrawWidget(), and TownViewWindow::GetDesiredInfoHeight().
uint16_t Town::time_until_rebuild |
time until we rebuild a house
Definition at line 93 of file town.h.
Referenced by DoCreateTown(), and TileLoop_Town().
uint8_t Town::unwanted[MAX_COMPANIES] |
how many months companies aren't wanted by towns (bribe)
Definition at line 74 of file town.h.
Referenced by GetMaskOfTownActions(), and TownActionBribe().
TileIndex Town::xy |
town center tile
Definition at line 55 of file town.h.
Referenced by AirportGetNearestTown(), CalcClosestTownFromTile(), CheckIfIndustryIsAllowed(), ClosestTownFromTile(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), DoCreateTown(), TownViewWindow::DrawWidget(), TownDirectoryWindow::DrawWidget(), FindSubsidyCargoDestination(), FindSubsidyPassengerRoute(), FindSubsidyTownCargoRoute(), GenerateStationName(), TownViewWindow::GetDesiredInfoHeight(), GetTownRadiusGroup(), GetTownRoadGridElement(), IndustriesScopeResolver::GetVariable(), ObjectScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), GrowTown(), HighlightTownLocalAuthorityTiles(), InitializeLayout(), IsCloseToTown(), TownAuthorityWindow::OnClick(), TownViewWindow::OnClick(), TownDirectoryWindow::OnClick(), TownViewWindow::OnResize(), TownScopeResolver::StorePSA(), TileLoop_Town(), TownActionAdvertiseLarge(), TownActionAdvertiseMedium(), TownActionAdvertiseSmall(), TownActionBuildStatue(), TownActionBuyRights(), TownLayoutAllows2x2HouseHere(), TownLayoutAllowsHouseHere(), UpdateTownGrowth(), and UpdateVirtCoord().