Public Member Functions | Static Public Member Functions | Data Fields

Town Struct Reference

Town data structure. More...

#include <town.h>

Inheritance diagram for Town:
Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >

Public Member Functions

 Town (TileIndex tile=INVALID_TILE)
 Creates a new town.
 ~Town ()
 Destroy the town.
void InitializeLayout (TownLayout layout)
 Assigns town layout.
void UpdateLabel ()
 Updates the town label of the town after changes in rating.
FORCEINLINE StringID Label () const
 Returns the correct town label, based on rating.
FORCEINLINE StringID SmallLabel () const
 Returns the correct town small label, based on rating.
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).
uint16 GrowthRatePercent () const

Static Public Member Functions

static FORCEINLINE TownGetByTile (TileIndex tile)
static TownGetRandom ()
 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
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
uint16 exclusive_counter
 months till the exclusivity expires
int16 ratings [MAX_COMPANIES]
 Ratings of each company for this town.
StringID town_label
 Label dependent on _local_company rating.
uint32 gen_act_pass
uint32 gen_act_mail
uint32 gen_max_pass
uint32 gen_max_mail
uint32 new_gen_max_pass
uint32 new_gen_max_mail
uint16 new_gen_act_pass
uint16 new_gen_act_mail
uint32 max_pass
uint32 max_mail
uint32 max_food
uint32 max_water
uint32 max_goods
uint32 new_max_pass
uint32 new_max_mail
uint32 new_max_food
uint32 new_max_water
uint32 new_max_goods
byte pct_pass_transported
byte pct_mail_transported
byte pct_food_transported
byte pct_water_transported
byte pct_goods_transported
uint16 act_pass
uint16 act_mail
uint16 act_food
uint16 act_water
uint16 act_goods
uint16 new_act_pass
uint16 new_act_mail
uint16 new_act_food
uint16 new_act_water
uint16 new_act_goods
uint16 time_until_rebuild
uint16 grow_counter
int16 growth_rate
uint32 ratio
byte fund_buildings_months
byte road_build_months
bool larger_town
TownLayoutByte layout
 town specific road layout
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.
byte transported_goods_percent
 Percentage of transported goods last month.
byte needed_for_growth
 What is most needed for town growth?

Detailed Description

Town data structure.

Definition at line 72 of file town.h.


Member Function Documentation

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().

FORCEINLINE StringID Town::Label (  )  const [inline]

Returns the correct town label, based on rating.

<)- Option to display population string always in white.

Little bit of a hack here: we abuse the fact that the very good string is white

Note:
By doing this here we do not mess with actual company rating.

Definition at line 192 of file town.h.

References _local_company, _settings_client, ClientSettings::gui, MAX_COMPANIES, GUISettings::population_in_label, GUISettings::population_in_label_coloured, and town_label.

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.

Returns:
the maximum noise level the town will tolerate.

Definition at line 242 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.

Parameters:
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().

FORCEINLINE StringID Town::SmallLabel (  )  const [inline]

Returns the correct town small label, based on rating.

<)- Option to display population string always in white.

Little bit of a hack here: we abuse the fact that the very good string is white

Note:
By doing this here we do not mess with actual company rating.

Definition at line 217 of file town.h.

References _local_company, _settings_client, ClientSettings::gui, MAX_COMPANIES, GUISettings::population_in_label, GUISettings::population_in_label_coloured, and town_label.

void Town::UpdateLabel (  ) 

Updates the town label of the town after changes in rating.

The colour scheme is: Red: Appalling and Very poor ratings. Orange: Poor and mediocre ratings. Yellow: Good rating. White: Very good rating (standard). Green: Excellent and outstanding ratings.

Definition at line 167 of file town_cmd.cpp.

References _local_company, MAX_COMPANIES, ratings, and town_label.

Referenced by UpdateVirtCoord().


The documentation for this struct was generated from the following files: