Go to the documentation of this file.
29 static const TownID INVALID_TOWN = 0xFFFF;
81 inline byte GetPercentTransported(
CargoID cid)
const {
return this->supplied[cid].
old_act * 256 / (this->supplied[cid].
old_max + 1); }
98 std::list<PersistentStorage *> psa_list;
127 inline const char *GetCachedName()
const
129 if (!this->name.empty())
return this->name.c_str();
130 if (this->cached_name.empty()) this->FillCachedName();
131 return this->cached_name.c_str();
143 void FillCachedName()
const;
149 void ClearAllTownCachedNames();
150 void ShowTownViewWindow(TownID town);
151 void ExpandTown(
Town *t);
153 void RebuildTownKdtree();
169 TDIWD_POPULATION_CHANGE,
197 void UpdateTownMaxPass(
Town *t);
198 void UpdateTownRadius(
Town *t);
231 extern TownID _new_town_id;
242 assert(obj->name.empty() || obj->town_cn == UINT16_MAX);
263 T *lobj = T::GetIfValid(cid);
266 if (lobj !=
nullptr && obj != lobj) {
268 if (lobj->town == obj->town && lobj->IsOfType(obj)) {
270 uint i = (uint)lobj->town_cn - next;
280 }
while (
HasBit(used, 0));
291 if (cid == T::GetPoolSize()) cid = 0;
292 }
while (cid != idx);
294 obj->town_cn = (uint16)next;
301 static inline uint16 TownTicksToGameTicks(uint16 ticks) {
@ TACT_BRIBE
Try to bribe the council.
CompanyMask have_ratings
which companies have a rating
uint32 TileIndex
The index/ID of a Tile.
@ TACT_BUILD_STATUE
Build a statue.
static const uint16 MAX_TOWN_GROWTH_TICKS
Max amount of original town ticks that still fit into uint16, about equal to UINT16_MAX / TOWN_GROWTH...
static Titem * Get(size_t index)
Returns Titem with given index.
void InitializeLayout(TownLayout layout)
Assigns town layout.
byte road_build_months
fund road reconstruction in action?
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.
uint8 unwanted[MAX_COMPANIES]
how many months companies aren't wanted by towns (bribe)
CompanyMask statues
which companies have a statue?
byte town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
uint16 noise_reached
level of noise that all the airports are generating
uint32 squared_town_zone_radius[HZB_END]
UpdateTownRadius updates this given the house count.
static const int TOWN_GROWTH_TICKS
cycle duration for towns trying to grow. (this originates from the size of the town array in TTD
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
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
uint32 goal[NUM_TE]
Amount of cargo required for the town to grow.
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 uint HOUSE_CLASS_MAX
There can only be as many classes as there are new houses, plus one for NO_CLASS, as the original hou...
const CargoSpec * FindFirstCargoWithTownEffect(TownEffect effect)
Determines the first cargo with a certain town effect.
Owner
Enum for all companies/owners.
@ TACT_FUNDS
All possible funding actions.
byte fund_buildings_months
fund buildings program in action?
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
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.
static TownID GetTownIndex(TileIndex t)
Get the index of which town this house/street is attached to.
void UpdateVirtCoord()
Resize the sign(label) of the town after changes in population (creation or growth or else)
static Town * GetRandom()
Return a random valid town.
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
@ TACT_ADVERTISE_MEDIUM
Medium advertising campaign.
BuildingCounts< uint16 > building_counts
The number of each type of building in the town.
Town(TileIndex tile=INVALID_TILE)
Creates a new town.
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
uint32 population
Current population of people.
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.
uint16 time_until_rebuild
time until we rebuild a house
Common return value for all commands.
static const HouseID NUM_HOUSES
Total number of houses.
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.
int32 TileIndexDiff
An offset value between to tiles.
@ NUM_TE
Amount of town effects.
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.
uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t)
Get a list of available actions to do at a town.
TownFlags
This enum is used in conjunction with town->flags.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
uint16 MaxTownNoise() const
Calculate the max town noise.
EconomySettings economy
settings to change the economy
@ MAX_COMPANIES
Maximum number of companies.
uint32 GetWorldPopulation()
Determines the world population Basically, count population of all towns, one by one.
uint16 growth_rate
town growth rate
const byte _town_action_costs[TACT_COUNT]
Factor in the cost of each town action.
RoadType
The different roadtypes we support.
std::set< Station *, StationCompare > StationList
List of stations.
int16 ratings[MAX_COMPANIES]
ratings of each company for this town
@ TACT_ADVERTISE_LARGE
Large advertising campaign.
TownEffect
Town growth effect when delivering cargo.
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
@ TACT_CONSTRUCTION
All possible construction actions.
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.
uint16 HouseID
OpenTTD ID of house types.
uint16 town_noise_population[3]
population to base decision on noise evaluation (
Base class for all pools.
bool GenerateTowns(TownLayout layout)
This function will generate a certain amount of towns, with a certain layout It can be called from th...
@ TACT_COUNT
Number of available town actions.
@ TACT_ADVERTISE_SMALL
Small advertising campaign.
Tstorage old_act
Actually transported last month.
@ NUM_CARGO
Maximal number of cargo types in a game.
TownCache cache
Container for all cacheable data.
@ TOWN_IS_GROWING
Conditions for town growth are met. Grow according to Town::growth_rate.
PartOfSubsidy
What part of a subsidy is something?
@ TACT_NONE
Empty action set.
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
byte CargoID
Cargo slots to indicate a cargo type within a game.
uint32 num_houses
Amount of houses.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
TownLayout layout
town specific road layout
bool larger_town
if this is a larger town and should grow more quickly
@ TUNNELBRIDGE_REMOVE
Removal of a tunnel or bridge owned by the towb.
@ 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.
TransportedCargoStat< uint32 > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
CompanyID exclusivity
which company has exclusivity
uint16 grow_counter
counter to count when to grow, value is smaller than or equal to growth_rate
@ TACT_ALL
All possible actions.
Base class for all PoolItems.
@ TOWN_CUSTOM_GROWTH
Growth rate is controlled by GS.
uint8 exclusive_counter
months till the exclusivity expires
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.
static const uint16 TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
std::string cached_name
NOSAVE: Cache of the resolved name of the town, if not using a custom town name.
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.
TransportedCargoStat< uint16 > received[NUM_TE]
Cargo statistics about received cargotypes.
@ TACT_BUY_RIGHTS
Buy exclusive transport rights.