#include <town.h>
Public Types | |
typedef bool(* | EnumTownProc )(const Town *t, void *data) |
Callback function for Town::GetRandom. | |
Public Member Functions | |
Town (TileIndex tile=INVALID_TILE) | |
Creates a new town. | |
~Town () | |
Destroy the town. | |
void | InitializeLayout (TownLayout layout) |
Assigns town layout. | |
SourceType | GetType () const |
Get the type of this entity. | |
SourceID | GetID () const |
Get the source ID corresponding with this entity. | |
bool | AcceptsCargo (CargoID cid) const |
Is this cargo accepted? | |
bool | SuppliesCargo (CargoID cid) const |
Is this cargo produced? | |
uint | GetDestinationWeight (CargoID cid, byte weight_mod) const |
Get the link weight for this as a destination for a specific cargo. | |
void | CreateSpecialLinks (CargoID cid) |
Create the special cargo links for a cargo if not already present. | |
TileArea | GetTileForDestination (CargoID cid) |
Get a random destination tile index for this cargo. | |
uint16 | MaxTownNoise () const |
Calculate the max town noise. | |
void | UpdateVirtCoord () |
Resize the sign(label) of the town after changes in population (creation or growth or else). | |
Static Public Member Functions | |
static FORCEINLINE Town * | GetByTile (TileIndex tile) |
static Town * | GetRandom (EnumTownProc enum_proc=NULL, TownID skip=INVALID_TOWN, void *data=NULL) |
Return a random town that statisfies some criteria specified with a callback function. | |
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 |
TileIndex | xy_aligned |
NOSAVE: Town centre aligned to the AcceptanceMatrix grid. | |
uint32 | num_houses |
uint32 | population |
uint32 | townnamegrfid |
uint16 | townnametype |
uint32 | townnameparts |
char * | name |
ViewportSign | sign |
byte | flags |
uint16 | noise_reached |
CompanyMask | statues |
CompanyMask | have_ratings |
uint8 | unwanted [MAX_COMPANIES] |
how many months companies aren't wanted by towns (bribe) | |
CompanyByte | exclusivity |
which company has exclusivity | |
uint8 | exclusive_counter |
months till the exclusivity expires | |
int16 | ratings [MAX_COMPANIES] |
Ratings of each company for this town. | |
TransportedCargoStat | pass |
TransportedCargoStat | |
byte | pct_pass_transported |
byte | pct_mail_transported |
uint16 | act_food |
uint16 | act_water |
uint16 | new_act_food |
uint16 | new_act_water |
uint16 | time_until_rebuild |
uint16 | grow_counter |
int16 | growth_rate |
byte | fund_buildings_months |
byte | road_build_months |
bool | larger_town |
TownLayoutByte | layout |
town specific road layout | |
uint32 | cargo_produced |
Bitmap of all cargos produced by houses in this town. | |
AcceptanceMatrix | cargo_accepted |
Bitmap of cargos accepted by houses for each 4*4 map square of the town. | |
uint32 | cargo_accepted_total |
NOSAVE: Bitmap of all cargos accepted by houses in this town. | |
uint32 | cargo_accepted_weights [NUM_CARGO] |
NOSAVE: Weight sum of accepting squares per cargo. | |
uint32 | cargo_accepted_max_weight |
NOSAVE: Cached maximum weight for an accepting square. | |
PartOfSubsidyByte | part_of_subsidy |
NOSAVE: is this town a source/destination of a subsidy? | |
uint32 | squared_town_zone_radius [HZB_END] |
BuildingCounts< uint16 > | building_counts |
NOSAVE: The number of each type of building in the town. |
Town data structure.
Definition at line 40 of file town.h.
typedef bool(* Town::EnumTownProc)(const Town *t, void *data) |
Callback function for Town::GetRandom.
void Town::CreateSpecialLinks | ( | CargoID | cid | ) | [virtual] |
Create the special cargo links for a cargo if not already present.
Reimplemented from CargoSourceSink.
Definition at line 330 of file cargodest.cpp.
References AcceptsCargo(), SmallVector< T, S >::Append(), CargoSourceSink::cargo_links, SmallVector< T, S >::Erase(), SmallVector< T, S >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), and LWM_INTOWN.
Referenced by UpdateExpectedLinks().
uint Town::GetDestinationWeight | ( | CargoID | cid, | |
byte | weight_mod | |||
) | const [virtual] |
Get the link weight for this as a destination for a specific cargo.
Implements CargoSourceSink.
Definition at line 564 of file cargodest.cpp.
References _settings_game, CargodestSettings::big_town_pop, BIG_TOWN_POP_MAIL, BIG_TOWN_POP_PAX, EconomySettings::cargodest, GameSettings::economy, IsPassengerCargo(), min(), MIN_WEIGHT_TOWN, CargodestSettings::min_weight_town, MIN_WEIGHT_TOWN_PAX, TransportedCargoStat::old_max, SCALE_TOWN, SCALE_TOWN_BIG, SCALE_TOWN_BIG_PAX, SCALE_TOWN_PAX, and CargodestSettings::weight_scale_town.
SourceID Town::GetID | ( | ) | const [inline, virtual] |
Get the source ID corresponding with this entity.
Implements CargoSourceSink.
Definition at line 136 of file town.h.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::index.
Town * Town::GetRandom | ( | EnumTownProc | enum_proc = NULL , |
|
TownID | skip = INVALID_TOWN , |
|||
void * | data = NULL | |||
) | [static] |
Return a random town that statisfies some criteria specified with a callback function.
enum_proc | Callback function. Return true for a matching town and false to continue iterating. | |
skip | Skip over this town id when searching. | |
data | Optional data passed to the callback function. |
Definition at line 144 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< Tpool >::index, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), and MAX_UVALUE.
Referenced by FindSupplySource(), FindTownDestination(), and MoveCargoWithDestinationToStationWorker().
Get a random destination tile index for this cargo.
Implements CargoSourceSink.
Definition at line 773 of file cargodest.cpp.
References cargo_accepted, cargo_accepted_max_weight, cargo_accepted_weights, DistanceMax(), TileMatrix< T, N >::GetArea(), TILE_AREA_LOOP, TileDiffXY(), TileX(), TileY(), and xy_aligned.
SourceType Town::GetType | ( | ) | const [inline, virtual] |
Get the type of this entity.
Implements CargoSourceSink.
Definition at line 131 of file town.h.
References ST_TOWN.
void Town::InitializeLayout | ( | TownLayout | layout | ) |
Assigns town layout.
If Random, generates one based on TileHash.
Definition at line 125 of file town_cmd.cpp.
References NUM_TLS, TileHash(), TileX(), TileY(), and TL_RANDOM.
Referenced by DoCreateTown().
uint16 Town::MaxTownNoise | ( | ) | const [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 161 of file town.h.
References _settings_game, GameSettings::difficulty, GameSettings::economy, DifficultySettings::town_council_tolerance, and EconomySettings::town_noise_population.
Referenced by CmdBuildAirport(), TownViewWindow::DrawWidget(), and AITown::GetAllowedNoise().
void Town::PostDestructor | ( | size_t | index | ) | [static] |
Invalidating of the "nearest town cache" has to be done after removing item from the pool.
index | index of deleted item |
Reimplemented from Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >.
Definition at line 110 of file town_cmd.cpp.
References CalcClosestTownFromTile(), InvalidateWindowData(), Object::location, TileArea::tile, Object::town, and UpdateNearestTownForRoadTiles().