OpenTTD Source: src/town.h Source File

OpenTTD Source 15.3

town.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef TOWN_H
11#define TOWN_H
12
13#include "misc/history_type.hpp"
14#include "viewport_type.h"
15#include "timer/timer_game_tick.h"
16#include "town_map.h"
17#include "subsidy_type.h"
18#include "newgrf_storage.h"
19#include "cargotype.h"
20
21template <typename T>
22 struct BuildingCounts {
23 std::vector<T> id_count{};
24 std::vector<T> class_count{};
25
26 auto operator<=>(const BuildingCounts &) const = default;
27};
28
29 static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4;
30 static const uint CUSTOM_TOWN_MAX_NUMBER = 5000;
31
32 static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE;
33 static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF;
34 static const uint16_t TOWN_GROWTH_RATE_NONE = 0xFFFF;
35 static const uint16_t MAX_TOWN_GROWTH_TICKS = 930;
36
37typedef Pool<Town, TownID, 64> TownPool;
38extern TownPool _town_pool;
39
41 enum class TownFlag : uint8_t {
42 IsGrowing = 0,
43 HasChurch = 1,
44 HasStadium = 2,
45 CustomGrowth = 3,
46};
47
48using TownFlags = EnumBitSet<TownFlag, uint8_t>;
49
51 struct TownCache {
52 uint32_t num_houses = 0;
53 uint32_t population = 0;
54 TrackedViewportSign sign{};
55 PartsOfSubsidy part_of_subsidy{};
56 std::array<uint32_t, NUM_HOUSE_ZONES> squared_town_zone_radius{};
57 BuildingCounts<uint16_t> building_counts{};
58
59 auto operator<=>(const TownCache &) const = default;
60};
61
63 struct Town : TownPool::PoolItem<&_town_pool> {
64 TileIndex xy = INVALID_TILE;
65
66 TownCache cache{};
67
68 /* Town name */
69 uint32_t townnamegrfid = 0;
70 uint16_t townnametype = 0;
71 uint32_t townnameparts = 0;
72 std::string name{};
73 mutable std::string cached_name{};
74
75 TownFlags flags{};
76
77 uint16_t noise_reached = 0;
78
79 CompanyMask statues{};
80
81 /* Company ratings. */
82 CompanyMask have_ratings{};
83 TypedIndexContainer<std::array<uint8_t, MAX_COMPANIES>, CompanyID> unwanted{};
84 CompanyID exclusivity = CompanyID::Invalid();
85 uint8_t exclusive_counter = 0;
86 TypedIndexContainer<std::array<int16_t, MAX_COMPANIES>, CompanyID> ratings{};
87
88 struct SuppliedHistory {
89 uint32_t production = 0;
90 uint32_t transported = 0;
91
92 uint8_t PctTransported() const
93 {
94 if (this->production == 0) return 0;
95 return ClampTo<uint8_t>(this->transported * 256 / this->production);
96 }
97 };
98
99 struct SuppliedCargo {
100 CargoType cargo = INVALID_CARGO;
101 HistoryData<SuppliedHistory> history{};
102
103 SuppliedCargo() = default;
104 SuppliedCargo(CargoType cargo) : cargo(cargo) {}
105 };
106
107 using SuppliedCargoes = std::vector<SuppliedCargo>;
108
109 SuppliedCargoes supplied{};
110 std::array<TransportedCargoStat<uint16_t>, NUM_TAE> received{};
111 std::array<uint32_t, NUM_TAE> goal{};
112 ValidHistoryMask valid_history = 0;
113
114 EncodedString text{};
115
116 inline SuppliedCargo &GetOrCreateCargoSupplied(CargoType cargo)
117 {
118 assert(IsValidCargoType(cargo));
119 auto it = std::ranges::lower_bound(this->supplied, cargo, std::less{}, &SuppliedCargo::cargo);
120 if (it == std::end(this->supplied) || it->cargo != cargo) it = this->supplied.emplace(it, cargo);
121 return *it;
122 }
123
124 inline SuppliedCargoes::const_iterator GetCargoSupplied(CargoType cargo) const
125 {
126 if (!IsValidCargoType(cargo)) return std::end(this->supplied);
127 auto it = std::ranges::lower_bound(this->supplied, cargo, std::less{}, &SuppliedCargo::cargo);
128 if (it == std::end(this->supplied) || it->cargo != cargo) return std::end(supplied);
129 return it;
130 }
131
132 inline uint8_t GetPercentTransported(CargoType cargo_type) const
133 {
134 auto it = this->GetCargoSupplied(cargo_type);
135 if (it == std::end(this->supplied)) return 0;
136
137 return it->history[LAST_MONTH].PctTransported();
138 }
139
140 StationList stations_near{};
141
142 uint16_t time_until_rebuild = 0;
143
144 uint16_t grow_counter = 0;
145 uint16_t growth_rate = 0;
146
147 uint8_t fund_buildings_months = 0;
148 uint8_t road_build_months = 0;
149
150 bool larger_town = false;
151 TownLayout layout{};
152
153 bool show_zone = false;
154
155 std::vector<PersistentStorage *> psa_list{};
156
161 Town(TileIndex tile = INVALID_TILE) : xy(tile) { }
162
164 ~Town();
165
166 void InitializeLayout(TownLayout layout);
167
174 inline uint16_t MaxTownNoise() const
175 {
176 if (this->cache.population == 0) return 0; // no population? no noise
177
178 /* 3 is added (the noise of the lowest airport), so the user can at least build a small airfield. */
179 return ClampTo<uint16_t>((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
180 }
181
182 void UpdateVirtCoord();
183
184 inline const std::string &GetCachedName() const
185 {
186 if (!this->name.empty()) return this->name;
187 if (this->cached_name.empty()) this->FillCachedName();
188 return this->cached_name;
189 }
190
191 static inline Town *GetByTile(TileIndex tile)
192 {
193 return Town::Get(GetTownIndex(tile));
194 }
195
196 static Town *GetRandom();
197 static void PostDestructor(size_t index);
198
199private:
200 void FillCachedName() const;
201};
202
203uint32_t GetWorldPopulation();
204
205void UpdateAllTownVirtCoords();
206void ClearAllTownCachedNames();
207void ShowTownViewWindow(TownID town);
208void ExpandTown(Town *t);
209
210void RebuildTownKdtree();
211
213 enum TownCouncilAttitudes {
214 TOWN_COUNCIL_LENIENT = 0,
215 TOWN_COUNCIL_TOLERANT = 1,
216 TOWN_COUNCIL_HOSTILE = 2,
217 TOWN_COUNCIL_PERMISSIVE = 3,
218};
219
224 enum class TownRatingCheckType : uint8_t {
225 RoadRemove,
226 TunnelBridgeRemove,
227 End,
228};
229
231 enum TownDirectoryInvalidateWindowData {
232 TDIWD_FORCE_REBUILD,
233 TDIWD_POPULATION_CHANGE,
234 TDIWD_FORCE_RESORT,
235};
236
237 CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckType type);
238
239
240 TileIndexDiff GetHouseNorthPart(HouseID &house);
241
242 Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
243
244void ResetHouses();
245
247 enum class TownAction : uint8_t {
248 AdvertiseSmall,
249 AdvertiseMedium,
250 AdvertiseLarge,
251 RoadRebuild,
252 BuildStatue,
253 FundBuildings,
254 BuyRights,
255 Bribe,
256 End,
257};
258using TownActions = EnumBitSet<TownAction, uint8_t>;
259
260 DECLARE_INCREMENT_DECREMENT_OPERATORS(TownAction);
261
262void ClearTownHouse(Town *t, TileIndex tile);
263void UpdateTownMaxPass(Town *t);
264void UpdateTownRadius(Town *t);
265 CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flags);
266 Town *ClosestTownFromTile(TileIndex tile, uint threshold);
267void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags);
268 HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile);
269void SetTownRatingTestMode(bool mode);
270 TownActions GetMaskOfTownActions(CompanyID cid, const Town *t);
271uint GetDefaultTownsForMapSize();
272bool GenerateTowns(TownLayout layout, std::optional<uint> number = std::nullopt);
273const CargoSpec *FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect);
274 CargoArray GetAcceptedCargoOfHouse(const HouseSpec *hs);
275
276uint8_t GetTownActionCost(TownAction action);
277
283template <class T>
284 void MakeDefaultName(T *obj)
285{
286 /* We only want to set names if it hasn't been set before, or when we're calling from afterload. */
287 assert(obj->name.empty() || obj->town_cn == UINT16_MAX);
288
289 obj->town = ClosestTownFromTile(obj->xy, UINT_MAX);
290
291 /* Find first unused number belonging to this town. This can never fail,
292 * as long as there can be at most 65535 waypoints/depots in total.
293 *
294 * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at
295 * most 'n * (1 + ceil(m / 32))' steps (n - number of waypoints in pool,
296 * m - number of waypoints near this town).
297 * Usually, it needs only 'n' steps.
298 *
299 * If it wasn't using 'used' and 'idx', it would just search for increasing 'next',
300 * but this way it is faster */
301
302 uint32_t used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base
303 uint32_t next = 0; // first number in the bitmap
304 uint32_t idx = 0; // index where we will stop
305 uint32_t cid = 0; // current index, goes to T::GetPoolSize()-1, then wraps to 0
306
307 do {
308 T *lobj = T::GetIfValid(cid);
309
310 /* check only valid waypoints... */
311 if (lobj != nullptr && obj != lobj) {
312 /* only objects within the same city and with the same type */
313 if (lobj->town == obj->town && lobj->IsOfType(obj)) {
314 /* if lobj->town_cn < next, uint will overflow to '+inf' */
315 uint i = (uint)lobj->town_cn - next;
316
317 if (i < 32) {
318 SetBit(used, i); // update bitmap
319 if (i == 0) {
320 /* shift bitmap while the lowest bit is '1';
321 * increase the base of the bitmap too */
322 do {
323 used >>= 1;
324 next++;
325 } while (HasBit(used, 0));
326 /* when we are at 'idx' again at end of the loop and
327 * 'next' hasn't changed, then no object had town_cn == next,
328 * so we can safely use it */
329 idx = cid;
330 }
331 }
332 }
333 }
334
335 cid++;
336 if (cid == T::GetPoolSize()) cid = 0; // wrap to zero...
337 } while (cid != idx);
338
339 obj->town_cn = (uint16_t)next; // set index...
340}
341
342/*
343 * Converts original town ticks counters to plain game ticks. Note that
344 * tick 0 is a valid tick so actual amount is one more than the counter value.
345 */
346inline uint16_t TownTicksToGameTicks(uint16_t ticks)
347{
348 return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1;
349}
350
351
352 RoadType GetTownRoadType();
353bool CheckTownRoadTypes();
354std::span<const DrawBuildingsTileStruct> GetTownDrawTileData();
355
356#endif /* TOWN_H */
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
CargoType
uint8_t CargoType
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:21
IsValidCargoType
bool IsValidCargoType(CargoType cargo)
Test whether cargo type is not INVALID_CARGO.
Definition cargo_type.h:104
cargotype.h
Types/functions related to cargoes.
TownAcceptanceEffect
TownAcceptanceEffect
Town growth effect when delivering cargo.
Definition cargotype.h:22
NUM_TAE
@ NUM_TAE
Amount of town effects.
Definition cargotype.h:31
CommandCost
Common return value for all commands.
Definition command_type.h:24
CompanyMask
Definition company_type.h:43
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
EnumBitSet< TownFlag, uint8_t >
Ticks::TOWN_GROWTH_TICKS
static constexpr TimerGameTick::Ticks TOWN_GROWTH_TICKS
Cycle duration for towns trying to grow (this originates from the size of the town array in TTD).
Definition timer_game_tick.h:83
TypedIndexContainer
A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific type.
Definition convertible_through_base.hpp:38
CommandType::End
@ End
End marker.
DECLARE_INCREMENT_DECREMENT_OPERATORS
#define DECLARE_INCREMENT_DECREMENT_OPERATORS(enum_type)
For some enums it is useful to have pre/post increment/decrement operators.
Definition enum_type.hpp:63
history_type.hpp
Types for storing historical data.
HistoryData
std::array< T, HISTORY_RECORDS > HistoryData
Container type for storing history data.
Definition history_type.hpp:53
ValidHistoryMask
uint64_t ValidHistoryMask
Mask of valid history records.
Definition history_type.hpp:56
HouseZone
HouseZone
Definition house.h:55
HouseID
uint16_t HouseID
OpenTTD ID of house types.
Definition house_type.h:15
TileIndexDiff
int32_t TileIndexDiff
An offset value between two tiles.
Definition map_type.h:23
newgrf_storage.h
Functionality related to the temporary and persistent storage arrays for NewGRFs.
RoadType
RoadType
The different roadtypes we support.
Definition road_type.h:23
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
StationList
std::set< Station *, StationCompare > StationList
List of stations.
Definition station_type.h:131
BuildingCounts
Definition town.h:22
CargoArray
Class for storing amounts of cargo.
Definition cargo_type.h:111
CargoSpec
Specification of a cargo type.
Definition cargotype.h:74
DifficultySettings::town_council_tolerance
uint8_t town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
Definition settings_type.h:142
EconomySettings::town_noise_population
uint16_t town_noise_population[4]
population to base decision on noise evaluation (
Definition settings_type.h:561
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition settings_type.h:642
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition settings_type.h:633
HouseSpec
Definition house.h:98
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:285
Pool::PoolItem<&_town_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem<&_town_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
Pool
Base class for all pools.
Definition pool_type.hpp:133
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TownCache
Data structure with cached data of towns.
Definition town.h:51
TownCache::population
uint32_t population
Current population of people.
Definition town.h:53
TownCache::num_houses
uint32_t num_houses
Amount of houses.
Definition town.h:52
TownCache::sign
TrackedViewportSign sign
Location of name sign, UpdateVirtCoord updates this.
Definition town.h:54
TownCache::building_counts
BuildingCounts< uint16_t > building_counts
The number of each type of building in the town.
Definition town.h:57
TownCache::squared_town_zone_radius
std::array< uint32_t, NUM_HOUSE_ZONES > squared_town_zone_radius
UpdateTownRadius updates this given the house count.
Definition town.h:56
TownCache::part_of_subsidy
PartsOfSubsidy part_of_subsidy
Is this town a source/destination of a subsidy?
Definition town.h:55
Town::SuppliedCargo
Definition town.h:99
Town::SuppliedHistory
Definition town.h:88
Town::SuppliedHistory::transported
uint32_t transported
Total transported.
Definition town.h:90
Town::SuppliedHistory::production
uint32_t production
Total produced.
Definition town.h:89
Town
Town data structure.
Definition town.h:63
Town::text
EncodedString text
General text with additional information.
Definition town.h:114
Town::larger_town
bool larger_town
if this is a larger town and should grow more quickly
Definition town.h:150
Town::Town
Town(TileIndex tile=INVALID_TILE)
Creates a new town.
Definition town.h:161
Town::statues
CompanyMask statues
which companies have a statue?
Definition town.h:79
Town::time_until_rebuild
uint16_t time_until_rebuild
time until we rebuild a house
Definition town.h:142
Town::cached_name
std::string cached_name
NOSAVE: Cache of the resolved name of the town, if not using a custom town name.
Definition town.h:73
Town::xy
TileIndex xy
town center tile
Definition town.h:64
Town::fund_buildings_months
uint8_t fund_buildings_months
fund buildings program in action?
Definition town.h:147
Town::noise_reached
uint16_t noise_reached
level of noise that all the airports are generating
Definition town.h:77
Town::supplied
SuppliedCargoes supplied
Cargo statistics about supplied cargo.
Definition town.h:109
Town::layout
TownLayout layout
town specific road layout
Definition town.h:151
Town::MaxTownNoise
uint16_t MaxTownNoise() const
Calculate the max town noise.
Definition town.h:174
Town::GetRandom
static Town * GetRandom()
Return a random valid town.
Definition town_cmd.cpp:203
Town::name
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
Definition town.h:72
Town::grow_counter
uint16_t grow_counter
counter to count when to grow, value is smaller than or equal to growth_rate
Definition town.h:144
Town::flags
TownFlags flags
See TownFlags.
Definition town.h:75
Town::cache
TownCache cache
Container for all cacheable data.
Definition town.h:66
Town::unwanted
TypedIndexContainer< std::array< uint8_t, MAX_COMPANIES >, CompanyID > unwanted
how many months companies aren't wanted by towns (bribe)
Definition town.h:83
Town::exclusivity
CompanyID exclusivity
which company has exclusivity
Definition town.h:84
Town::valid_history
ValidHistoryMask valid_history
Mask of valid history records.
Definition town.h:112
Town::InitializeLayout
void InitializeLayout(TownLayout layout)
Assign the town layout.
Definition town_cmd.cpp:189
Town::show_zone
bool show_zone
NOSAVE: mark town to show the local authority zone in the viewports.
Definition town.h:153
Town::exclusive_counter
uint8_t exclusive_counter
months till the exclusivity expires
Definition town.h:85
Town::UpdateVirtCoord
void UpdateVirtCoord()
Resize the sign (label) of the town after it changes population.
Definition town_cmd.cpp:398
Town::have_ratings
CompanyMask have_ratings
which companies have a rating
Definition town.h:82
Town::~Town
~Town()
Destroy the town.
Definition town_cmd.cpp:115
Town::ratings
TypedIndexContainer< std::array< int16_t, MAX_COMPANIES >, CompanyID > ratings
ratings of each company for this town
Definition town.h:86
Town::growth_rate
uint16_t growth_rate
town growth rate
Definition town.h:145
Town::stations_near
StationList stations_near
NOSAVE: List of nearby stations.
Definition town.h:140
Town::PostDestructor
static void PostDestructor(size_t index)
Invalidating of the "nearest town cache" has to be done after removing item from the pool.
Definition town_cmd.cpp:174
Town::road_build_months
uint8_t road_build_months
fund road reconstruction in action?
Definition town.h:148
Town::received
std::array< TransportedCargoStat< uint16_t >, NUM_TAE > received
Cargo statistics about received cargotypes.
Definition town.h:110
Town::goal
std::array< uint32_t, NUM_TAE > goal
Amount of cargo required for the town to grow.
Definition town.h:111
TrackedViewportSign
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
Definition viewport_type.h:60
subsidy_type.h
basic types related to subsidies
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
timer_game_tick.h
Definition of the tick-based game-timer.
TOWN_GROWTH_WINTER
static const uint TOWN_GROWTH_WINTER
The town only needs this cargo in the winter (any amount)
Definition town.h:32
ChangeTownRating
void ChangeTownRating(Town *t, int add, int max, DoCommandFlags flags)
Changes town rating of the current company.
Definition town_cmd.cpp:4040
TownRatingCheckType
TownRatingCheckType
Action types that a company must ask permission for to a town authority.
Definition town.h:224
TownRatingCheckType::TunnelBridgeRemove
@ TunnelBridgeRemove
Removal of a tunnel or bridge owned by the town.
TownRatingCheckType::RoadRemove
@ RoadRemove
Removal of a road owned by the town.
GetHouseNorthPart
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
Definition town_cmd.cpp:3025
GetDefaultTownsForMapSize
uint GetDefaultTownsForMapSize()
Calculate the number of towns which should be on the map according to the current "town density" newg...
Definition town_cmd.cpp:2432
ClearTownHouse
void ClearTownHouse(Town *t, TileIndex tile)
Clear a town house.
Definition town_cmd.cpp:3050
GetMaskOfTownActions
TownActions GetMaskOfTownActions(CompanyID cid, const Town *t)
Get a list of available town authority actions.
Definition town_cmd.cpp:3672
FindFirstCargoWithTownAcceptanceEffect
const CargoSpec * FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
Determines the first cargo with a certain town effect.
Definition town_cmd.cpp:3127
ClosestTownFromTile
Town * ClosestTownFromTile(TileIndex tile, uint threshold)
Return the town closest (in distance or ownership) to a given tile, within a given threshold.
Definition town_cmd.cpp:3961
TOWN_GROWTH_DESERT
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
Definition town.h:33
TownDirectoryInvalidateWindowData
TownDirectoryInvalidateWindowData
Special values for town list window for the data parameter of InvalidateWindowData.
Definition town.h:231
GenerateTowns
bool GenerateTowns(TownLayout layout, std::optional< uint > number=std::nullopt)
Generate a number of towns with a given layout.
Definition town_cmd.cpp:2448
GetWorldPopulation
uint32_t GetWorldPopulation()
Get the total population, the sum of all towns in the world.
Definition town_cmd.cpp:457
CUSTOM_TOWN_MAX_NUMBER
static const uint CUSTOM_TOWN_MAX_NUMBER
this is the maximum number of towns a user can specify in customisation
Definition town.h:30
UpdateTownMaxPass
void UpdateTownMaxPass(Town *t)
Update the maximum amount of monthly passengers and mail for a town, based on its population.
Definition town_cmd.cpp:2003
GetAcceptedCargoOfHouse
CargoArray GetAcceptedCargoOfHouse(const HouseSpec *hs)
Get accepted cargo of a house prototype.
Definition town_cmd.cpp:858
GetTownActionCost
uint8_t GetTownActionCost(TownAction action)
Get cost factors for a TownAction.
Definition town_cmd.cpp:3391
CUSTOM_TOWN_NUMBER_DIFFICULTY
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition town.h:29
ClearAllTownCachedNames
void ClearAllTownCachedNames()
Clear the cached_name of all towns.
Definition town_cmd.cpp:430
GetTownRoadType
RoadType GetTownRoadType()
Get the road type that towns should build at this current moment.
Definition town_cmd.cpp:965
CalcClosestTownFromTile
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Definition town_cmd.cpp:3943
TownAction
TownAction
Town actions of a company.
Definition town.h:247
TownAction::RoadRebuild
@ RoadRebuild
Rebuild the roads.
TownAction::Bribe
@ Bribe
Try to bribe the council.
TownAction::AdvertiseLarge
@ AdvertiseLarge
Large advertising campaign.
TownAction::BuildStatue
@ BuildStatue
Build a statue.
TownAction::BuyRights
@ BuyRights
Buy exclusive transport rights.
TownAction::FundBuildings
@ FundBuildings
Fund new buildings.
TownAction::AdvertiseMedium
@ AdvertiseMedium
Medium advertising campaign.
TownAction::AdvertiseSmall
@ AdvertiseSmall
Small advertising campaign.
CheckforTownRating
CommandCost CheckforTownRating(DoCommandFlags flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
Definition town_cmd.cpp:4077
GetTownRadiusGroup
HouseZone GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Definition town_cmd.cpp:2516
CheckTownRoadTypes
bool CheckTownRoadTypes()
Check if towns are able to build road.
Definition town_cmd.cpp:1015
MAX_TOWN_GROWTH_TICKS
static const uint16_t MAX_TOWN_GROWTH_TICKS
Max amount of original town ticks that still fit into uint16_t, about equal to UINT16_MAX / TOWN_GROW...
Definition town.h:35
TownCouncilAttitudes
TownCouncilAttitudes
Settings for town council attitudes.
Definition town.h:213
SetTownRatingTestMode
void SetTownRatingTestMode(bool mode)
Switch the town rating to test-mode, to allow commands to be tested without affecting current ratings...
Definition town_cmd.cpp:4002
UpdateTownRadius
void UpdateTownRadius(Town *t)
Update the cached town zone radii of a town, based on the number of houses.
Definition town_cmd.cpp:1956
TownFlag
TownFlag
Flags controlling various town behaviours.
Definition town.h:41
TownFlag::HasChurch
@ HasChurch
There can be only one church by town.
TownFlag::CustomGrowth
@ CustomGrowth
Growth rate is controlled by GS.
TownFlag::HasStadium
@ HasStadium
There can be only one stadium by town.
TownFlag::IsGrowing
@ IsGrowing
Conditions for town growth are met. Grow according to Town::growth_rate.
TOWN_GROWTH_RATE_NONE
static const uint16_t TOWN_GROWTH_RATE_NONE
Special value for Town::growth_rate to disable town growth.
Definition town.h:34
CheckIfAuthorityAllowsNewStation
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlags flags)
Checks whether the local authority allows construction of a new station (rail, road,...
Definition town_cmd.cpp:3920
MakeDefaultName
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
Definition town.h:284
UpdateAllTownVirtCoords
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
Definition town_cmd.cpp:422
town_map.h
Accessors for towns.
GetTownIndex
TownID GetTownIndex(Tile t)
Get the index of which town this house/street is attached to.
Definition town_map.h:23
TownLayout
TownLayout
Town Layouts.
Definition town_type.h:81
viewport_type.h
Types related to viewports.