|
OpenTTD Source 20260208-master-g43af8e94d0
|
#include <town.h>
Data Structures | |
| struct | SuppliedHistory |
| struct | SuppliedCargo |
Public Types | |
| using | SuppliedCargoes = std::vector<SuppliedCargo> |
Public Member Functions | |
| SuppliedCargo & | GetOrCreateCargoSupplied (CargoType cargo) |
| SuppliedCargoes::const_iterator | GetCargoSupplied (CargoType cargo) const |
| uint8_t | GetPercentTransported (CargoType cargo_type) const |
| Town (TownID index, 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 |
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. | |
Data Fields | |
| TileIndex | xy = INVALID_TILE |
| town center tile | |
| TownCache | cache {} |
| Container for all cacheable data. | |
| uint32_t | townnamegrfid = 0 |
| uint16_t | townnametype = 0 |
| uint32_t | townnameparts = 0 |
| 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. | |
| TownFlags | flags {} |
| See TownFlags. | |
| uint16_t | noise_reached = 0 |
| level of noise that all the airports are generating | |
| CompanyMask | statues {} |
| which companies have a statue? | |
| CompanyMask | have_ratings {} |
| which companies have a rating | |
| TypedIndexContainer< std::array< uint8_t, MAX_COMPANIES >, CompanyID > | unwanted {} |
| how many months companies aren't wanted by towns (bribe) | |
| CompanyID | exclusivity = CompanyID::Invalid() |
| which company has exclusivity | |
| uint8_t | exclusive_counter = 0 |
| months till the exclusivity expires | |
| TypedIndexContainer< std::array< int16_t, MAX_COMPANIES >, CompanyID > | ratings {} |
| ratings of each company for this town | |
| SuppliedCargoes | supplied {} |
| Cargo statistics about supplied cargo. | |
| std::array< TransportedCargoStat< uint16_t >, NUM_TAE > | received {} |
| Cargo statistics about received cargotypes. | |
| std::array< uint32_t, NUM_TAE > | goal {} |
| Amount of cargo required for the town to grow. | |
| ValidHistoryMask | valid_history = 0 |
| Mask of valid history records. | |
| EncodedString | text {} |
| General text with additional information. | |
| StationList | stations_near {} |
| NOSAVE: List of nearby stations. | |
| uint16_t | time_until_rebuild = 0 |
| time until we rebuild a house | |
| uint16_t | grow_counter = 0 |
| counter to count when to grow, value is smaller than or equal to growth_rate | |
| uint16_t | growth_rate = 0 |
| town growth rate | |
| uint8_t | fund_buildings_months = 0 |
| fund buildings program in action? | |
| uint8_t | road_build_months = 0 |
| fund road reconstruction in action? | |
| bool | larger_town = false |
| if this is a larger town and should grow more quickly | |
| TownLayout | layout {} |
| town specific road layout | |
| bool | show_zone = false |
| NOSAVE: mark town to show the local authority zone in the viewports. | |
| std::vector< PersistentStorage * > | psa_list {} |
Private Member Functions | |
| void | FillCachedName () const |
| using Town::SuppliedCargoes = std::vector<SuppliedCargo> |
|
inline |
Creates a new town.
| index | the index within the town pool |
| tile | center tile of the town |
Definition at line 162 of file town.h.
References INVALID_TILE, and xy.
Referenced by GetRandom().
| Town::~Town | ( | ) |
Destroy the town.
Definition at line 115 of file town_cmd.cpp.
References CloseWindowById(), DeleteNewGRFInspectWindow(), DeleteSubsidyWith(), GetTileType(), GetTownIndex(), GSF_FAKE_TOWNS, HasTownOwnedRoad(), House, CargoPacket::InvalidateAllFrom(), Map::Iterate(), MarkWholeScreenDirty(), Road, TestTownOwnsBridge(), Town, TunnelBridge, WC_TOWN_CARGO_GRAPH, and WC_TOWN_VIEW.
|
private |
Definition at line 223 of file town_cmd.cpp.
|
inline |
|
inline |
|
inline |
|
static |
Return a random valid town.
Definition at line 203 of file town_cmd.cpp.
References RandomRange(), and Town().
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 189 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 175 of file town.h.
References _settings_game, ClampTo(), and TownCache::population.
Referenced by CmdBuildAirport().
|
static |
Invalidating of the "nearest town cache" has to be done after removing item from the pool.
Definition at line 174 of file town_cmd.cpp.
References CalcClosestTownFromTile(), InvalidateWindowData(), UpdateNearestTownForRoadTiles(), and WC_TOWN_DIRECTORY.
| void Town::UpdateVirtCoord | ( | ) |
Resize the sign (label) of the town after it changes population.
Definition at line 398 of file town_cmd.cpp.
References _settings_client, cache, GetString(), larger_town, Point, RemapCoords2(), SetWindowDirty(), TILE_SIZE, TileX(), TileY(), WC_TOWN_VIEW, Coord2D< T >::x, xy, and Coord2D< T >::y.
Referenced by ChangePopulation(), CmdFoundTown(), CmdRenameTown(), and DoCreateTown().
| TownCache Town::cache {} |
Container for all cacheable data.
Definition at line 66 of file town.h.
Referenced by BuildTownHouse(), ChangePopulation(), CheckIfIndustryIsAllowed(), CheckSubsidised(), ClearTownHouse(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), CmdDeleteTown(), CmdExpandTown(), CreateRandomTown(), DecreaseBuildingCount(), DoCreateTown(), TownDirectoryWindow::DrawWidget(), TownViewWindow::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 73 of file town.h.
Referenced by CmdRenameTown().
| uint8_t Town::exclusive_counter = 0 |
months till the exclusivity expires
Definition at line 85 of file town.h.
Referenced by DoCreateTown(), StationViewWindow::DrawCargoRatings(), GetMaskOfTownActions(), MayLoadUnderExclusiveRights(), TownActionBribe(), and TownActionBuyRights().
| CompanyID Town::exclusivity = CompanyID::Invalid() |
which company has exclusivity
Definition at line 84 of file town.h.
Referenced by DoCreateTown(), StationViewWindow::DrawCargoRatings(), TownAuthorityWindow::DrawRatings(), GetMaskOfTownActions(), MayLoadUnderExclusiveRights(), TownActionBribe(), and TownActionBuyRights().
| TownFlags Town::flags {} |
See TownFlags.
Definition at line 75 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 = 0 |
fund buildings program in action?
Definition at line 147 of file town.h.
Referenced by DoCreateTown(), TownViewWindow::DrawWidget(), GetNormalGrowthRate(), GetTownRadiusGroup(), TownScopeResolver::GetVariable(), TownActionFundBuildings(), and UpdateTownGrowth().
| std::array<uint32_t, NUM_TAE> Town::goal {} |
Amount of cargo required for the town to grow.
Definition at line 111 of file town.h.
Referenced by CmdTownCargoGoal(), DoCreateTown(), TownViewWindow::DrawWidget(), TownViewWindow::GetDesiredInfoHeight(), and UpdateTownGrowth().
| uint16_t Town::grow_counter = 0 |
counter to count when to grow, value is smaller than or equal to growth_rate
Definition at line 144 of file town.h.
Referenced by CmdTownGrowthRate(), DoCreateTown(), TownScopeResolver::GetVariable(), TownActionFundBuildings(), TownTickHandler(), and UpdateTownGrowCounter().
| uint16_t Town::growth_rate = 0 |
town growth rate
Definition at line 145 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 82 of file town.h.
Referenced by ChangeTownRating(), DoCreateTown(), TownAuthorityWindow::DrawRatings(), TownDirectoryWindow::DrawWidget(), TownScopeResolver::GetVariable(), and TownDirectoryWindow::TownRatingSorter().
| bool Town::larger_town = false |
if this is a larger town and should grow more quickly
Definition at line 150 of file town.h.
Referenced by DoCreateTown(), GetNormalGrowthRate(), TownDirectoryWindow::GetTownString(), TownScopeResolver::GetVariable(), TownViewWindow::GetWidgetString(), and UpdateVirtCoord().
| TownLayout Town::layout {} |
town specific road layout
Definition at line 151 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 72 of file town.h.
Referenced by CmdFoundTown(), CmdRenameTown(), FormatString(), GenerateCompanyName(), and IsUniqueTownName().
| uint16_t Town::noise_reached = 0 |
level of noise that all the airports are generating
Definition at line 77 of file town.h.
Referenced by CmdBuildAirport(), TownViewWindow::DrawWidget(), RemoveAirport(), and UpdateAirportsNoise().
| std::vector<PersistentStorage *> Town::psa_list {} |
| TypedIndexContainer<std::array<int16_t, MAX_COMPANIES>, CompanyID> Town::ratings {} |
ratings of each company for this town
Definition at line 86 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().
| std::array<TransportedCargoStat<uint16_t>, NUM_TAE> Town::received {} |
Cargo statistics about received cargotypes.
Definition at line 110 of file town.h.
Referenced by DeliverGoods(), TownViewWindow::DrawWidget(), TownScopeResolver::GetVariable(), SlTownReceived::Load(), SlTownReceived::Save(), and UpdateTownGrowth().
| uint8_t Town::road_build_months = 0 |
fund road reconstruction in action?
Definition at line 148 of file town.h.
Referenced by TownScopeResolver::GetVariable(), and TownActionRoadRebuild().
| bool Town::show_zone = false |
NOSAVE: mark town to show the local authority zone in the viewports.
Definition at line 153 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 140 of file town.h.
Referenced by Station::RecomputeCatchment(), and RemoveNearbyStations().
| CompanyMask Town::statues {} |
which companies have a statue?
Definition at line 79 of file town.h.
Referenced by DoCreateTown(), GetMaskOfTownActions(), TownScopeResolver::GetVariable(), TownActionBuildStatue(), and UpdateStationRating().
| SuppliedCargoes Town::supplied {} |
Cargo statistics about supplied cargo.
Definition at line 109 of file town.h.
Referenced by TownViewWindow::DrawWidget(), SlTownSupplied::GetVector(), CITYChunkHandler::Load(), and SlTownOldSupplied::Load().
| EncodedString Town::text {} |
General text with additional information.
Definition at line 114 of file town.h.
Referenced by CmdTownSetText(), TownViewWindow::DrawWidget(), and TownViewWindow::GetDesiredInfoHeight().
| uint16_t Town::time_until_rebuild = 0 |
time until we rebuild a house
Definition at line 142 of file town.h.
Referenced by DoCreateTown(), and TileLoop_Town().
| TypedIndexContainer<std::array<uint8_t, MAX_COMPANIES>, CompanyID> Town::unwanted {} |
how many months companies aren't wanted by towns (bribe)
Definition at line 83 of file town.h.
Referenced by GetMaskOfTownActions(), and TownActionBribe().
| ValidHistoryMask Town::valid_history = 0 |
Mask of valid history records.
Definition at line 112 of file town.h.
Referenced by CITYChunkHandler::Load().
| TileIndex Town::xy = INVALID_TILE |
town center tile
Definition at line 64 of file town.h.
Referenced by AirportGetNearestTown(), CalcClosestTownFromTile(), CheckIfIndustryIsAllowed(), ClosestTownFromTile(), CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), DoCreateTown(), TownDirectoryWindow::DrawWidget(), TownViewWindow::DrawWidget(), FindSubsidyCargoDestination(), FindSubsidyPassengerRoute(), FindSubsidyTownCargoRoute(), GenerateStationName(), TownViewWindow::GetDesiredInfoHeight(), GetTownRadiusGroup(), GetTownRoadGridElement(), ObjectScopeResolver::GetVariable(), RoadStopScopeResolver::GetVariable(), TownScopeResolver::GetVariable(), GrowTown(), HighlightTownLocalAuthorityTiles(), InitializeLayout(), IsCloseToTown(), TownAuthorityWindow::OnClick(), TownDirectoryWindow::OnClick(), TownViewWindow::OnClick(), TownViewWindow::OnResize(), TownScopeResolver::StorePSA(), TileLoop_Town(), Town(), TownActionAdvertiseLarge(), TownActionAdvertiseMedium(), TownActionAdvertiseSmall(), TownActionBuildStatue(), TownActionBuyRights(), TownLayoutAllows2x2HouseHere(), TownLayoutAllowsHouseHere(), UpdateTownGrowth(), and UpdateVirtCoord().