OpenTTD Source 20260711-master-g3fb3006dff
town_type.h File Reference

Types related to towns. More...

#include "core/enum_type.hpp"
#include "core/pool_type.hpp"

Go to the source code of this file.

Data Structures

struct  TransportedCargoStat< Tstorage >
 Store the maximum and actually transported cargo amount for the current and the last month. More...

Typedefs

using TownID = PoolID<uint16_t, struct TownIDTag, 64000, 0xFFFF>
using TownExpandModes = EnumBitSet<TownExpandMode, uint8_t>
 Bitset of TownExpandMode elements.

Enumerations

enum class  TownSize : uint8_t {
  Small , Medium , Large , Random ,
  End
}
 Supported initial town sizes. More...
enum class  TownLayout : uint8_t {
  Original , BetterRoads , Grid2x2 , Grid3x3 ,
  Random , End
}
 Town Layouts. More...
enum class  TownExpandMode : uint8_t { Buildings , Roads }
 Options for growing towns. More...
enum class  TownFounding : uint8_t { Forbidden , Allowed , CustomLayout }
 Town founding setting values. More...
enum class  TownCargoGenMode : uint8_t { Original , Bitcount }
 Town cargo generation modes. More...

Variables

static constexpr int RATING_MINIMUM = -1000
static constexpr int RATING_APPALLING = -400
static constexpr int RATING_VERYPOOR = -200
static constexpr int RATING_POOR = 0
static constexpr int RATING_MEDIOCRE = 200
static constexpr int RATING_GOOD = 400
static constexpr int RATING_VERYGOOD = 600
static constexpr int RATING_EXCELLENT = 800
static constexpr int RATING_OUTSTANDING = 1000
 OUTSTANDING.
static constexpr int RATING_MAXIMUM = RATING_OUTSTANDING
static constexpr int RATING_INITIAL = 500
 initial rating
static constexpr int RATING_TREE_DOWN_STEP = -35
static constexpr int RATING_TREE_MINIMUM = RATING_MINIMUM
static constexpr int RATING_TREE_UP_STEP = 7
static constexpr int RATING_TREE_MAXIMUM = 220
static constexpr int RATING_GROWTH_UP_STEP = 5
 when a town grows, all companies have rating increased a bit ...
static constexpr int RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE
 ... up to RATING_MEDIOCRE
static constexpr int RATING_STATION_UP_STEP = 12
 when a town grows, company gains reputation for all well serviced stations ...
static constexpr int RATING_STATION_DOWN_STEP = -15
 ... but loses for badly serviced stations
static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP = 50
 rating increase for improving a town-owned bridge
static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP = -250
 penalty for removing town owned tunnel or bridge
static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM = 0
 minimum rating after removing tunnel or bridge
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144
 rating needed, "Lenient" difficulty settings
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208
 "Neutral"
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400
 "Hostile"
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = RATING_MINIMUM
 "Permissive" (local authority disabled)
static constexpr int RATING_ROAD_DOWN_STEP_INNER = -50
 removing a roadpiece in the middle
static constexpr int RATING_ROAD_DOWN_STEP_EDGE = -18
 removing a roadpiece at the edge
static constexpr int RATING_ROAD_MINIMUM = -100
 minimum rating after removing town owned road
static constexpr int RATING_ROAD_NEEDED_LENIENT = 16
 rating needed, "Lenient" difficulty settings
static constexpr int RATING_ROAD_NEEDED_NEUTRAL = 64
 "Neutral"
static constexpr int RATING_ROAD_NEEDED_HOSTILE = 112
 "Hostile"
static constexpr int RATING_ROAD_NEEDED_PERMISSIVE = RATING_MINIMUM
 "Permissive" (local authority disabled)
static constexpr int RATING_HOUSE_MINIMUM = RATING_MINIMUM
static constexpr int RATING_BRIBE_UP_STEP = 200
static constexpr int RATING_BRIBE_MAXIMUM = 800
static constexpr int RATING_BRIBE_DOWN_TO = -50
static constexpr int RATING_WATER_RIVER_DOWN_STEP = -200
 removing a river tile
static constexpr int RATING_WATER_MINIMUM = RATING_MINIMUM
 minimum rating after removing water features near town
static const uint MAX_LENGTH_TOWN_NAME_CHARS = 32
 The maximum length of a town name in characters including '\0'.

Detailed Description

Types related to towns.

Definition in file town_type.h.

Typedef Documentation

◆ TownExpandModes

Bitset of TownExpandMode elements.

Definition at line 101 of file town_type.h.

◆ TownID

using TownID = PoolID<uint16_t, struct TownIDTag, 64000, 0xFFFF>

Definition at line 16 of file town_type.h.

Enumeration Type Documentation

◆ TownCargoGenMode

enum class TownCargoGenMode : uint8_t
strong

Town cargo generation modes.

Enumerator
Original 

Original algorithm (quadratic cargo by population).

Bitcount 

Bit-counted algorithm (normal distribution from individual house population).

Definition at line 111 of file town_type.h.

◆ TownExpandMode

enum class TownExpandMode : uint8_t
strong

Options for growing towns.

Enumerator
Buildings 

Allow town to place buildings.

Roads 

Allow town to place roads.

Definition at line 95 of file town_type.h.

◆ TownFounding

enum class TownFounding : uint8_t
strong

Town founding setting values.

It needs to be 8bits, because we save and load it as such

Enumerator
Forbidden 

Forbidden.

Allowed 

Allowed.

CustomLayout 

Allowed, with custom town layout.

Definition at line 104 of file town_type.h.

◆ TownLayout

enum class TownLayout : uint8_t
strong

Town Layouts.

It needs to be 8bits, because we save and load it as such

Enumerator
Original 

Original algorithm (min. 1 distance between roads).

BetterRoads 

Extended original algorithm (min. 2 distance between roads).

Grid2x2 

Geometric 2x2 grid algorithm.

Grid3x3 

Geometric 3x3 grid algorithm.

Random 

Random town layout.

End 

Number of town layouts.

Definition at line 83 of file town_type.h.

◆ TownSize

enum class TownSize : uint8_t
strong

Supported initial town sizes.

Enumerator
Small 

Small town.

Medium 

Medium town.

Large 

Large town.

Random 

Random size, bigger than small, smaller than large.

End 

Number of available town sizes.

Definition at line 21 of file town_type.h.

Variable Documentation

◆ MAX_LENGTH_TOWN_NAME_CHARS

const uint MAX_LENGTH_TOWN_NAME_CHARS = 32
static

The maximum length of a town name in characters including '\0'.

Definition at line 116 of file town_type.h.

Referenced by CmdFoundTown(), CmdRenameTown(), TownViewWindow::OnClick(), and VerifyTownName().

◆ RATING_APPALLING

int RATING_APPALLING = -400
staticconstexpr

Definition at line 33 of file town_type.h.

◆ RATING_BRIBE_DOWN_TO

int RATING_BRIBE_DOWN_TO = -50
staticconstexpr

Definition at line 77 of file town_type.h.

◆ RATING_BRIBE_MAXIMUM

int RATING_BRIBE_MAXIMUM = 800
staticconstexpr

Definition at line 76 of file town_type.h.

◆ RATING_BRIBE_UP_STEP

int RATING_BRIBE_UP_STEP = 200
staticconstexpr

Definition at line 75 of file town_type.h.

◆ RATING_EXCELLENT

int RATING_EXCELLENT = 800
staticconstexpr

Definition at line 39 of file town_type.h.

◆ RATING_GOOD

int RATING_GOOD = 400
staticconstexpr

Definition at line 37 of file town_type.h.

◆ RATING_GROWTH_MAXIMUM

int RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE
staticconstexpr

... up to RATING_MEDIOCRE

Definition at line 53 of file town_type.h.

Referenced by UpdateTownRating().

◆ RATING_GROWTH_UP_STEP

int RATING_GROWTH_UP_STEP = 5
staticconstexpr

when a town grows, all companies have rating increased a bit ...

Definition at line 52 of file town_type.h.

Referenced by UpdateTownRating().

◆ RATING_HOUSE_MINIMUM

int RATING_HOUSE_MINIMUM = RATING_MINIMUM
staticconstexpr

Definition at line 73 of file town_type.h.

◆ RATING_INITIAL

int RATING_INITIAL = 500
staticconstexpr

initial rating

Definition at line 44 of file town_type.h.

Referenced by AfterLoadGame(), ChangeOwnershipOfCompanyItems(), and DoCreateTown().

◆ RATING_MAXIMUM

int RATING_MAXIMUM = RATING_OUTSTANDING
staticconstexpr

Definition at line 42 of file town_type.h.

◆ RATING_MEDIOCRE

int RATING_MEDIOCRE = 200
staticconstexpr

Definition at line 36 of file town_type.h.

◆ RATING_MINIMUM

int RATING_MINIMUM = -1000
staticconstexpr

Definition at line 32 of file town_type.h.

◆ RATING_OUTSTANDING

int RATING_OUTSTANDING = 1000
staticconstexpr

OUTSTANDING.

Definition at line 40 of file town_type.h.

◆ RATING_POOR

int RATING_POOR = 0
staticconstexpr

Definition at line 35 of file town_type.h.

◆ RATING_ROAD_DOWN_STEP_EDGE

int RATING_ROAD_DOWN_STEP_EDGE = -18
staticconstexpr

removing a roadpiece at the edge

Definition at line 66 of file town_type.h.

Referenced by CheckAllowRemoveRoad().

◆ RATING_ROAD_DOWN_STEP_INNER

int RATING_ROAD_DOWN_STEP_INNER = -50
staticconstexpr

removing a roadpiece in the middle

Definition at line 65 of file town_type.h.

Referenced by CheckAllowRemoveRoad().

◆ RATING_ROAD_MINIMUM

int RATING_ROAD_MINIMUM = -100
staticconstexpr

minimum rating after removing town owned road

Definition at line 67 of file town_type.h.

Referenced by CheckAllowRemoveRoad().

◆ RATING_ROAD_NEEDED_HOSTILE

int RATING_ROAD_NEEDED_HOSTILE = 112
staticconstexpr

"Hostile"

Definition at line 70 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_ROAD_NEEDED_LENIENT

int RATING_ROAD_NEEDED_LENIENT = 16
staticconstexpr

rating needed, "Lenient" difficulty settings

Definition at line 68 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_ROAD_NEEDED_NEUTRAL

int RATING_ROAD_NEEDED_NEUTRAL = 64
staticconstexpr

"Neutral"

Definition at line 69 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_ROAD_NEEDED_PERMISSIVE

int RATING_ROAD_NEEDED_PERMISSIVE = RATING_MINIMUM
staticconstexpr

"Permissive" (local authority disabled)

Definition at line 71 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_STATION_DOWN_STEP

int RATING_STATION_DOWN_STEP = -15
staticconstexpr

... but loses for badly serviced stations

Definition at line 55 of file town_type.h.

Referenced by UpdateTownRating().

◆ RATING_STATION_UP_STEP

int RATING_STATION_UP_STEP = 12
staticconstexpr

when a town grows, company gains reputation for all well serviced stations ...

Definition at line 54 of file town_type.h.

Referenced by UpdateTownRating().

◆ RATING_TREE_DOWN_STEP

int RATING_TREE_DOWN_STEP = -35
staticconstexpr

Definition at line 47 of file town_type.h.

◆ RATING_TREE_MAXIMUM

int RATING_TREE_MAXIMUM = 220
staticconstexpr

Definition at line 50 of file town_type.h.

◆ RATING_TREE_MINIMUM

int RATING_TREE_MINIMUM = RATING_MINIMUM
staticconstexpr

Definition at line 48 of file town_type.h.

◆ RATING_TREE_UP_STEP

int RATING_TREE_UP_STEP = 7
staticconstexpr

Definition at line 49 of file town_type.h.

◆ RATING_TUNNEL_BRIDGE_DOWN_STEP

int RATING_TUNNEL_BRIDGE_DOWN_STEP = -250
staticconstexpr

penalty for removing town owned tunnel or bridge

Definition at line 58 of file town_type.h.

Referenced by DoClearBridge(), and DoClearTunnel().

◆ RATING_TUNNEL_BRIDGE_MINIMUM

int RATING_TUNNEL_BRIDGE_MINIMUM = 0
staticconstexpr

minimum rating after removing tunnel or bridge

Definition at line 59 of file town_type.h.

Referenced by DoClearBridge(), and DoClearTunnel().

◆ RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE

int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400
staticconstexpr

"Hostile"

Definition at line 62 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_TUNNEL_BRIDGE_NEEDED_LENIENT

int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144
staticconstexpr

rating needed, "Lenient" difficulty settings

Definition at line 60 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL

int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208
staticconstexpr

"Neutral"

Definition at line 61 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE

int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = RATING_MINIMUM
staticconstexpr

"Permissive" (local authority disabled)

Definition at line 63 of file town_type.h.

Referenced by CheckforTownRating().

◆ RATING_TUNNEL_BRIDGE_UP_STEP

int RATING_TUNNEL_BRIDGE_UP_STEP = 50
staticconstexpr

rating increase for improving a town-owned bridge

Definition at line 57 of file town_type.h.

Referenced by CmdBuildBridge().

◆ RATING_VERYGOOD

int RATING_VERYGOOD = 600
staticconstexpr

Definition at line 38 of file town_type.h.

◆ RATING_VERYPOOR

int RATING_VERYPOOR = -200
staticconstexpr

Definition at line 34 of file town_type.h.

◆ RATING_WATER_MINIMUM

int RATING_WATER_MINIMUM = RATING_MINIMUM
staticconstexpr

minimum rating after removing water features near town

Definition at line 80 of file town_type.h.

Referenced by ClearTile_Water().

◆ RATING_WATER_RIVER_DOWN_STEP

int RATING_WATER_RIVER_DOWN_STEP = -200
staticconstexpr

removing a river tile

Definition at line 79 of file town_type.h.

Referenced by ClearTile_Water().