OpenTTD Source: src/town.h Source File

OpenTTD Source 15.0-beta1

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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef TOWN_H
11#define TOWN_H
12
13#include "viewport_type.h"
14#include "timer/timer_game_tick.h"
15#include "town_map.h"
16#include "subsidy_type.h"
17#include "newgrf_storage.h"
18#include "cargotype.h"
19
20template <typename T>
21 struct BuildingCounts {
22 std::vector<T> id_count;
23 std::vector<T> class_count;
24
25 auto operator<=>(const BuildingCounts &) const = default;
26};
27
28 static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4;
29 static const uint CUSTOM_TOWN_MAX_NUMBER = 5000;
30
31static const TownID INVALID_TOWN = 0xFFFF;
32
33 static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE;
34 static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF;
35 static const uint16_t TOWN_GROWTH_RATE_NONE = 0xFFFF;
36 static const uint16_t MAX_TOWN_GROWTH_TICKS = 930;
37
38typedef Pool<Town, TownID, 64, 64000> TownPool;
39extern TownPool _town_pool;
40
42 struct TownCache {
43 uint32_t num_houses;
44 uint32_t population;
45 TrackedViewportSign sign;
46 PartOfSubsidy part_of_subsidy;
47 std::array<uint32_t, HZB_END> squared_town_zone_radius;
48 BuildingCounts<uint16_t> building_counts;
49
50 auto operator<=>(const TownCache &) const = default;
51};
52
54 struct Town : TownPool::PoolItem<&_town_pool> {
55 TileIndex xy;
56
57 TownCache cache;
58
59 /* Town name */
60 uint32_t townnamegrfid;
61 uint16_t townnametype;
62 uint32_t townnameparts;
63 std::string name;
64 mutable std::string cached_name;
65
66 uint8_t flags;
67
68 uint16_t noise_reached;
69
70 CompanyMask statues;
71
72 /* Company ratings. */
73 CompanyMask have_ratings;
74 uint8_t unwanted[MAX_COMPANIES];
75 CompanyID exclusivity;
76 uint8_t exclusive_counter;
77 int16_t ratings[MAX_COMPANIES];
78
79 TransportedCargoStat<uint32_t> supplied[NUM_CARGO];
80 TransportedCargoStat<uint16_t> received[NUM_TAE];
81 uint32_t goal[NUM_TAE];
82
83 std::string text;
84
85 inline uint8_t GetPercentTransported(CargoID cid) const
86 {
87 if (!IsValidCargoID(cid)) return 0;
88 return this->supplied[cid].old_act * 256 / (this->supplied[cid].old_max + 1);
89 }
90
91 StationList stations_near;
92
93 uint16_t time_until_rebuild;
94
95 uint16_t grow_counter;
96 uint16_t growth_rate;
97
98 uint8_t fund_buildings_months;
99 uint8_t road_build_months;
100
101 bool larger_town;
102 TownLayout layout;
103
104 bool show_zone;
105
106 std::vector<PersistentStorage *> psa_list;
107
112 Town(TileIndex tile = INVALID_TILE) : xy(tile) { }
113
115 ~Town();
116
117 void InitializeLayout(TownLayout layout);
118
125 inline uint16_t MaxTownNoise() const
126 {
127 if (this->cache.population == 0) return 0; // no population? no noise
128
129 /* 3 is added (the noise of the lowest airport), so the user can at least build a small airfield. */
130 return ClampTo<uint16_t>((this->cache.population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
131 }
132
133 void UpdateVirtCoord();
134
135 inline const std::string &GetCachedName() const
136 {
137 if (!this->name.empty()) return this->name;
138 if (this->cached_name.empty()) this->FillCachedName();
139 return this->cached_name;
140 }
141
142 static inline Town *GetByTile(TileIndex tile)
143 {
144 return Town::Get(GetTownIndex(tile));
145 }
146
147 static Town *GetRandom();
148 static void PostDestructor(size_t index);
149
150private:
151 void FillCachedName() const;
152};
153
154uint32_t GetWorldPopulation();
155
156void UpdateAllTownVirtCoords();
157void ClearAllTownCachedNames();
158void ShowTownViewWindow(TownID town);
159void ExpandTown(Town *t);
160
161void RebuildTownKdtree();
162
164 enum TownCouncilAttitudes {
165 TOWN_COUNCIL_LENIENT = 0,
166 TOWN_COUNCIL_TOLERANT = 1,
167 TOWN_COUNCIL_HOSTILE = 2,
168 TOWN_COUNCIL_PERMISSIVE = 3,
169};
170
175 enum TownRatingCheckType {
176 ROAD_REMOVE = 0,
177 TUNNELBRIDGE_REMOVE = 1,
178 TOWN_RATING_CHECK_TYPE_COUNT,
179};
180
182 enum TownDirectoryInvalidateWindowData {
183 TDIWD_FORCE_REBUILD,
184 TDIWD_POPULATION_CHANGE,
185 TDIWD_FORCE_RESORT,
186};
187
195 enum TownFlags {
196 TOWN_IS_GROWING = 0,
197 TOWN_HAS_CHURCH = 1,
198 TOWN_HAS_STADIUM = 2,
199 TOWN_CUSTOM_GROWTH = 3,
200};
201
202 CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type);
203
204
205 TileIndexDiff GetHouseNorthPart(HouseID &house);
206
207 Town *CalcClosestTownFromTile(TileIndex tile, uint threshold = UINT_MAX);
208
209void ResetHouses();
210
212 enum TownActions {
213 TACT_NONE = 0x00,
214
215 TACT_ADVERTISE_SMALL = 0x01,
216 TACT_ADVERTISE_MEDIUM = 0x02,
217 TACT_ADVERTISE_LARGE = 0x04,
218 TACT_ROAD_REBUILD = 0x08,
219 TACT_BUILD_STATUE = 0x10,
220 TACT_FUND_BUILDINGS = 0x20,
221 TACT_BUY_RIGHTS = 0x40,
222 TACT_BRIBE = 0x80,
223
224 TACT_COUNT = 8,
225
226 TACT_ADVERTISE = TACT_ADVERTISE_SMALL | TACT_ADVERTISE_MEDIUM | TACT_ADVERTISE_LARGE,
227 TACT_CONSTRUCTION = TACT_ROAD_REBUILD | TACT_BUILD_STATUE | TACT_FUND_BUILDINGS,
228 TACT_FUNDS = TACT_BUY_RIGHTS | TACT_BRIBE,
229 TACT_ALL = TACT_ADVERTISE | TACT_CONSTRUCTION | TACT_FUNDS,
230};
231 DECLARE_ENUM_AS_BIT_SET(TownActions)
232
233void ClearTownHouse(Town *t, TileIndex tile);
234void UpdateTownMaxPass(Town *t);
235void UpdateTownRadius(Town *t);
236 CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags);
237 Town *ClosestTownFromTile(TileIndex tile, uint threshold);
238void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags);
239HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile);
240void SetTownRatingTestMode(bool mode);
241 TownActions GetMaskOfTownActions(CompanyID cid, const Town *t);
242bool GenerateTowns(TownLayout layout);
243const CargoSpec *FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect);
244 CargoArray GetAcceptedCargoOfHouse(const HouseSpec *hs);
245
246extern const uint8_t _town_action_costs[TACT_COUNT];
247
253template <class T>
254 void MakeDefaultName(T *obj)
255{
256 /* We only want to set names if it hasn't been set before, or when we're calling from afterload. */
257 assert(obj->name.empty() || obj->town_cn == UINT16_MAX);
258
259 obj->town = ClosestTownFromTile(obj->xy, UINT_MAX);
260
261 /* Find first unused number belonging to this town. This can never fail,
262 * as long as there can be at most 65535 waypoints/depots in total.
263 *
264 * This does 'n * m' search, but with 32bit 'used' bitmap, it needs at
265 * most 'n * (1 + ceil(m / 32))' steps (n - number of waypoints in pool,
266 * m - number of waypoints near this town).
267 * Usually, it needs only 'n' steps.
268 *
269 * If it wasn't using 'used' and 'idx', it would just search for increasing 'next',
270 * but this way it is faster */
271
272 uint32_t used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base
273 uint32_t next = 0; // first number in the bitmap
274 uint32_t idx = 0; // index where we will stop
275 uint32_t cid = 0; // current index, goes to T::GetPoolSize()-1, then wraps to 0
276
277 do {
278 T *lobj = T::GetIfValid(cid);
279
280 /* check only valid waypoints... */
281 if (lobj != nullptr && obj != lobj) {
282 /* only objects within the same city and with the same type */
283 if (lobj->town == obj->town && lobj->IsOfType(obj)) {
284 /* if lobj->town_cn < next, uint will overflow to '+inf' */
285 uint i = (uint)lobj->town_cn - next;
286
287 if (i < 32) {
288 SetBit(used, i); // update bitmap
289 if (i == 0) {
290 /* shift bitmap while the lowest bit is '1';
291 * increase the base of the bitmap too */
292 do {
293 used >>= 1;
294 next++;
295 } while (HasBit(used, 0));
296 /* when we are at 'idx' again at end of the loop and
297 * 'next' hasn't changed, then no object had town_cn == next,
298 * so we can safely use it */
299 idx = cid;
300 }
301 }
302 }
303 }
304
305 cid++;
306 if (cid == T::GetPoolSize()) cid = 0; // wrap to zero...
307 } while (cid != idx);
308
309 obj->town_cn = (uint16_t)next; // set index...
310}
311
312/*
313 * Converts original town ticks counters to plain game ticks. Note that
314 * tick 0 is a valid tick so actual amount is one more than the counter value.
315 */
316inline uint16_t TownTicksToGameTicks(uint16_t ticks)
317{
318 return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1;
319}
320
321
322 RoadType GetTownRoadType();
323bool CheckTownRoadTypes();
324std::span<const DrawBuildingsTileStruct> GetTownDrawTileData();
325
326#endif /* TOWN_H */
HasBit
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
SetBit
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
Definition bitmath_func.hpp:121
CargoID
uint8_t CargoID
Cargo slots to indicate a cargo type within a game.
Definition cargo_type.h:22
IsValidCargoID
bool IsValidCargoID(CargoID t)
Test whether cargo type is not INVALID_CARGO.
Definition cargo_type.h:107
NUM_CARGO
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Definition cargo_type.h:74
cargotype.h
Types/functions related to cargoes.
TownAcceptanceEffect
TownAcceptanceEffect
Town growth effect when delivering cargo.
Definition cargotype.h:21
NUM_TAE
@ NUM_TAE
Amount of town effects.
Definition cargotype.h:30
CommandCost
Common return value for all commands.
Definition command_type.h:23
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
DoCommandFlag
DoCommandFlag
List of flags for a command.
Definition command_type.h:374
Owner
Owner
Enum for all companies/owners.
Definition company_type.h:18
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition company_type.h:23
DECLARE_ENUM_AS_BIT_SET
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:35
HouseID
uint16_t HouseID
OpenTTD ID of house types.
Definition house_type.h:13
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:25
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:57
StationList
std::set< Station *, StationCompare > StationList
List of stations.
Definition station_type.h:94
BuildingCounts
Definition town.h:21
CargoArray
Class for storing amounts of cargo.
Definition cargo_type.h:114
CargoSpec
Specification of a cargo type.
Definition cargotype.h:76
DifficultySettings::town_council_tolerance
uint8_t town_council_tolerance
minimum required town ratings to be allowed to demolish stuff
Definition settings_type.h:116
EconomySettings::town_noise_population
uint16_t town_noise_population[4]
population to base decision on noise evaluation (
Definition settings_type.h:533
GameSettings::economy
EconomySettings economy
settings to change the economy
Definition settings_type.h:602
GameSettings::difficulty
DifficultySettings difficulty
settings related to the difficulty
Definition settings_type.h:592
HouseSpec
Definition house.h:93
Pool::PoolItem
Base class for all PoolItems.
Definition pool_type.hpp:237
Pool::PoolItem<&_town_pool >::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:238
Pool::PoolItem<&_town_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition pool_type.hpp:339
Pool
Base class for all pools.
Definition pool_type.hpp:80
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:42
TownCache::population
uint32_t population
Current population of people.
Definition town.h:44
TownCache::num_houses
uint32_t num_houses
Amount of houses.
Definition town.h:43
TownCache::squared_town_zone_radius
std::array< uint32_t, HZB_END > squared_town_zone_radius
UpdateTownRadius updates this given the house count.
Definition town.h:47
TownCache::part_of_subsidy
PartOfSubsidy part_of_subsidy
Is this town a source/destination of a subsidy?
Definition town.h:46
TownCache::sign
TrackedViewportSign sign
Location of name sign, UpdateVirtCoord updates this.
Definition town.h:45
TownCache::building_counts
BuildingCounts< uint16_t > building_counts
The number of each type of building in the town.
Definition town.h:48
Town
Town data structure.
Definition town.h:54
Town::larger_town
bool larger_town
if this is a larger town and should grow more quickly
Definition town.h:101
Town::Town
Town(TileIndex tile=INVALID_TILE)
Creates a new town.
Definition town.h:112
Town::supplied
TransportedCargoStat< uint32_t > supplied[NUM_CARGO]
Cargo statistics about supplied cargo.
Definition town.h:79
Town::statues
CompanyMask statues
which companies have a statue?
Definition town.h:70
Town::time_until_rebuild
uint16_t time_until_rebuild
time until we rebuild a house
Definition town.h:93
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:64
Town::xy
TileIndex xy
town center tile
Definition town.h:55
Town::fund_buildings_months
uint8_t fund_buildings_months
fund buildings program in action?
Definition town.h:98
Town::noise_reached
uint16_t noise_reached
level of noise that all the airports are generating
Definition town.h:68
Town::ratings
int16_t ratings[MAX_COMPANIES]
ratings of each company for this town
Definition town.h:77
Town::layout
TownLayout layout
town specific road layout
Definition town.h:102
Town::received
TransportedCargoStat< uint16_t > received[NUM_TAE]
Cargo statistics about received cargotypes.
Definition town.h:80
Town::MaxTownNoise
uint16_t MaxTownNoise() const
Calculate the max town noise.
Definition town.h:125
Town::GetRandom
static Town * GetRandom()
Return a random valid town.
Definition town_cmd.cpp:196
Town::name
std::string name
Custom town name. If empty, the town was not renamed and uses the generated name.
Definition town.h:63
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:95
Town::flags
uint8_t flags
See TownFlags.
Definition town.h:66
Town::cache
TownCache cache
Container for all cacheable data.
Definition town.h:57
Town::exclusivity
CompanyID exclusivity
which company has exclusivity
Definition town.h:75
Town::InitializeLayout
void InitializeLayout(TownLayout layout)
Assign the town layout.
Definition town_cmd.cpp:182
Town::show_zone
bool show_zone
NOSAVE: mark town to show the local authority zone in the viewports.
Definition town.h:104
Town::goal
uint32_t goal[NUM_TAE]
Amount of cargo required for the town to grow.
Definition town.h:81
Town::exclusive_counter
uint8_t exclusive_counter
months till the exclusivity expires
Definition town.h:76
Town::UpdateVirtCoord
void UpdateVirtCoord()
Resize the sign (label) of the town after it changes population.
Definition town_cmd.cpp:409
Town::text
std::string text
General text with additional information.
Definition town.h:83
Town::have_ratings
CompanyMask have_ratings
which companies have a rating
Definition town.h:73
Town::~Town
~Town()
Destroy the town.
Definition town_cmd.cpp:110
Town::unwanted
uint8_t unwanted[MAX_COMPANIES]
how many months companies aren't wanted by towns (bribe)
Definition town.h:74
Town::growth_rate
uint16_t growth_rate
town growth rate
Definition town.h:96
Town::stations_near
StationList stations_near
NOSAVE: List of nearby stations.
Definition town.h:91
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:167
Town::road_build_months
uint8_t road_build_months
fund road reconstruction in action?
Definition town.h:99
TrackedViewportSign
Specialised ViewportSign that tracks whether it is valid for entering into a Kdtree.
Definition viewport_type.h:51
TransportedCargoStat
Store the maximum and actually transported cargo amount for the current and the last month.
Definition town_type.h:113
TransportedCargoStat::old_max
Tstorage old_max
Maximum amount last month.
Definition town_type.h:114
TransportedCargoStat::old_act
Tstorage old_act
Actually transported last month.
Definition town_type.h:116
subsidy_type.h
basic types related to subsidies
PartOfSubsidy
PartOfSubsidy
What part of a subsidy is something?
Definition subsidy_type.h:16
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:33
GetTownRadiusGroup
HouseZonesBits GetTownRadiusGroup(const Town *t, TileIndex tile)
Returns the bit corresponding to the town zone of the specified tile.
Definition town_cmd.cpp:2474
GetHouseNorthPart
TileIndexDiff GetHouseNorthPart(HouseID &house)
Determines if a given HouseID is part of a multitile house.
Definition town_cmd.cpp:2950
ClearTownHouse
void ClearTownHouse(Town *t, TileIndex tile)
Clear a town house.
Definition town_cmd.cpp:2975
GetMaskOfTownActions
TownActions GetMaskOfTownActions(CompanyID cid, const Town *t)
Get a list of available town authority actions.
Definition town_cmd.cpp:3605
FindFirstCargoWithTownAcceptanceEffect
const CargoSpec * FindFirstCargoWithTownAcceptanceEffect(TownAcceptanceEffect effect)
Determines the first cargo with a certain town effect.
Definition town_cmd.cpp:3052
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:3896
TOWN_GROWTH_DESERT
static const uint TOWN_GROWTH_DESERT
The town needs the cargo for growth when on desert (any amount)
Definition town.h:34
TownDirectoryInvalidateWindowData
TownDirectoryInvalidateWindowData
Special values for town list window for the data parameter of InvalidateWindowData.
Definition town.h:182
TownFlags
TownFlags
This enum is used in conjunction with town->flags.
Definition town.h:195
TOWN_HAS_CHURCH
@ TOWN_HAS_CHURCH
There can be only one church by town.
Definition town.h:197
TOWN_HAS_STADIUM
@ TOWN_HAS_STADIUM
There can be only one stadium by town.
Definition town.h:198
TOWN_IS_GROWING
@ TOWN_IS_GROWING
Conditions for town growth are met. Grow according to Town::growth_rate.
Definition town.h:196
TOWN_CUSTOM_GROWTH
@ TOWN_CUSTOM_GROWTH
Growth rate is controlled by GS.
Definition town.h:199
TownRatingCheckType
TownRatingCheckType
Action types that a company must ask permission for to a town authority.
Definition town.h:175
ROAD_REMOVE
@ ROAD_REMOVE
Removal of a road owned by the town.
Definition town.h:176
TUNNELBRIDGE_REMOVE
@ TUNNELBRIDGE_REMOVE
Removal of a tunnel or bridge owned by the towb.
Definition town.h:177
TOWN_RATING_CHECK_TYPE_COUNT
@ TOWN_RATING_CHECK_TYPE_COUNT
Number of town checking action types.
Definition town.h:178
GetWorldPopulation
uint32_t GetWorldPopulation()
Get the total population, the sum of all towns in the world.
Definition town_cmd.cpp:462
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:29
TownActions
TownActions
Town actions of a company.
Definition town.h:212
TACT_BUILD_STATUE
@ TACT_BUILD_STATUE
Build a statue.
Definition town.h:219
TACT_CONSTRUCTION
@ TACT_CONSTRUCTION
All possible construction actions.
Definition town.h:227
TACT_ROAD_REBUILD
@ TACT_ROAD_REBUILD
Rebuild the roads.
Definition town.h:218
TACT_ADVERTISE_MEDIUM
@ TACT_ADVERTISE_MEDIUM
Medium advertising campaign.
Definition town.h:216
TACT_BUY_RIGHTS
@ TACT_BUY_RIGHTS
Buy exclusive transport rights.
Definition town.h:221
TACT_BRIBE
@ TACT_BRIBE
Try to bribe the council.
Definition town.h:222
TACT_ADVERTISE
@ TACT_ADVERTISE
All possible advertising actions.
Definition town.h:226
TACT_COUNT
@ TACT_COUNT
Number of available town actions.
Definition town.h:224
TACT_ALL
@ TACT_ALL
All possible actions.
Definition town.h:229
TACT_FUND_BUILDINGS
@ TACT_FUND_BUILDINGS
Fund new buildings.
Definition town.h:220
TACT_FUNDS
@ TACT_FUNDS
All possible funding actions.
Definition town.h:228
TACT_NONE
@ TACT_NONE
Empty action set.
Definition town.h:213
TACT_ADVERTISE_LARGE
@ TACT_ADVERTISE_LARGE
Large advertising campaign.
Definition town.h:217
TACT_ADVERTISE_SMALL
@ TACT_ADVERTISE_SMALL
Small advertising campaign.
Definition town.h:215
_town_action_costs
const uint8_t _town_action_costs[TACT_COUNT]
Factor in the cost of each town action.
Definition town_cmd.cpp:3314
UpdateTownMaxPass
void UpdateTownMaxPass(Town *t)
Update the maximum amount of montly passengers and mail for a town, based on its population.
Definition town_cmd.cpp:1993
GetAcceptedCargoOfHouse
CargoArray GetAcceptedCargoOfHouse(const HouseSpec *hs)
Get accepted cargo of a house prototype.
Definition town_cmd.cpp:853
CUSTOM_TOWN_NUMBER_DIFFICULTY
static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY
value for custom town number in difficulty settings
Definition town.h:28
ClearAllTownCachedNames
void ClearAllTownCachedNames()
Clear the cached_name of all towns.
Definition town_cmd.cpp:435
ChangeTownRating
void ChangeTownRating(Town *t, int add, int max, DoCommandFlag flags)
Changes town rating of the current company.
Definition town_cmd.cpp:3975
GetTownRoadType
RoadType GetTownRoadType()
Get the road type that towns should build at this current moment.
Definition town_cmd.cpp:953
CalcClosestTownFromTile
Town * CalcClosestTownFromTile(TileIndex tile, uint threshold=UINT_MAX)
Return the town closest to the given tile within threshold.
Definition town_cmd.cpp:3878
CheckTownRoadTypes
bool CheckTownRoadTypes()
Check if towns are able to build road.
Definition town_cmd.cpp:1009
GenerateTowns
bool GenerateTowns(TownLayout layout)
Generate a number of towns with a given layout.
Definition town_cmd.cpp:2413
CheckIfAuthorityAllowsNewStation
CommandCost CheckIfAuthorityAllowsNewStation(TileIndex tile, DoCommandFlag flags)
Checks whether the local authority allows construction of a new station (rail, road,...
Definition town_cmd.cpp:3854
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:36
CheckforTownRating
CommandCost CheckforTownRating(DoCommandFlag flags, Town *t, TownRatingCheckType type)
Does the town authority allow the (destructive) action of the current company?
Definition town_cmd.cpp:4012
TownCouncilAttitudes
TownCouncilAttitudes
Settings for town council attitudes.
Definition town.h:164
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:3937
UpdateTownRadius
void UpdateTownRadius(Town *t)
Update the cached town zone radii of a town, based on the number of houses.
Definition town_cmd.cpp:1946
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:35
MakeDefaultName
void MakeDefaultName(T *obj)
Set the default name for a depot/waypoint.
Definition town.h:254
UpdateAllTownVirtCoords
void UpdateAllTownVirtCoords()
Update the virtual coords needed to draw the town sign for all towns.
Definition town_cmd.cpp:427
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:79
viewport_type.h
Types related to viewports.