OpenTTD Source 20260711-master-g3fb3006dff
town_type.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
9
10#ifndef TOWN_TYPE_H
11#define TOWN_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "core/pool_type.hpp"
15
17
18struct Town;
19
21enum class TownSize : uint8_t {
25 Random,
26
28};
29
30/* These refer to the maximums, so Appalling is -1000 to -400
31 * MAXIMUM RATINGS BOUNDARIES */
32static constexpr int RATING_MINIMUM = -1000;
33static constexpr int RATING_APPALLING = -400;
34static constexpr int RATING_VERYPOOR = -200;
35static constexpr int RATING_POOR = 0;
36static constexpr int RATING_MEDIOCRE = 200;
37static constexpr int RATING_GOOD = 400;
38static constexpr int RATING_VERYGOOD = 600;
39static constexpr int RATING_EXCELLENT = 800;
40static constexpr int RATING_OUTSTANDING = 1000;
41
42static constexpr int RATING_MAXIMUM = RATING_OUTSTANDING;
43
44static constexpr int RATING_INITIAL = 500;
45
46/* RATINGS AFFECTING NUMBERS */
47static constexpr int RATING_TREE_DOWN_STEP = -35;
48static constexpr int RATING_TREE_MINIMUM = RATING_MINIMUM;
49static constexpr int RATING_TREE_UP_STEP = 7;
50static constexpr int RATING_TREE_MAXIMUM = 220;
51
52static constexpr int RATING_GROWTH_UP_STEP = 5;
53static constexpr int RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE;
54static constexpr int RATING_STATION_UP_STEP = 12;
55static constexpr int RATING_STATION_DOWN_STEP = -15;
56
57static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP = 50;
58static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP = -250;
59static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM = 0;
60static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144;
61static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208;
62static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400;
63static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = RATING_MINIMUM;
64
65static constexpr int RATING_ROAD_DOWN_STEP_INNER = -50;
66static constexpr int RATING_ROAD_DOWN_STEP_EDGE = -18;
67static constexpr int RATING_ROAD_MINIMUM = -100;
68static constexpr int RATING_ROAD_NEEDED_LENIENT = 16;
69static constexpr int RATING_ROAD_NEEDED_NEUTRAL = 64;
70static constexpr int RATING_ROAD_NEEDED_HOSTILE = 112;
71static constexpr int RATING_ROAD_NEEDED_PERMISSIVE = RATING_MINIMUM;
72
73static constexpr int RATING_HOUSE_MINIMUM = RATING_MINIMUM;
74
75static constexpr int RATING_BRIBE_UP_STEP = 200;
76static constexpr int RATING_BRIBE_MAXIMUM = 800;
77static constexpr int RATING_BRIBE_DOWN_TO = -50; // XXX SHOULD BE SOMETHING LOWER?
78
79static constexpr int RATING_WATER_RIVER_DOWN_STEP = -200;
80static constexpr int RATING_WATER_MINIMUM = RATING_MINIMUM;
81
83enum class TownLayout : uint8_t {
88
89 Random,
90
92};
93
95enum class TownExpandMode : uint8_t {
98};
99
102
109
111enum class TownCargoGenMode : uint8_t {
114};
115
116static const uint MAX_LENGTH_TOWN_NAME_CHARS = 32;
117
119template <typename Tstorage>
121 Tstorage old_max = 0;
122 Tstorage new_max = 0;
123 Tstorage old_act = 0;
124 Tstorage new_act = 0;
125
127 void NewMonth()
128 {
129 this->old_max = this->new_max; this->new_max = 0;
130 this->old_act = this->new_act; this->new_act = 0;
131 }
132};
133
134#endif /* TOWN_TYPE_H */
Enum-as-bit-set wrapper.
Type (helpers) for enums.
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Templated helper to make a PoolID a single POD value.
Definition pool_type.hpp:50
Town data structure.
Definition town.h:64
Store the maximum and actually transported cargo amount for the current and the last month.
Definition town_type.h:120
Tstorage new_max
Maximum amount this month.
Definition town_type.h:122
void NewMonth()
Update stats for a new month.
Definition town_type.h:127
Tstorage old_max
Maximum amount last month.
Definition town_type.h:121
Tstorage old_act
Actually transported last month.
Definition town_type.h:123
Tstorage new_act
Actually transported this month.
Definition town_type.h:124
static constexpr int RATING_GROWTH_UP_STEP
when a town grows, all companies have rating increased a bit ...
Definition town_type.h:52
static constexpr int RATING_INITIAL
initial rating
Definition town_type.h:44
static constexpr int RATING_ROAD_NEEDED_HOSTILE
"Hostile"
Definition town_type.h:70
static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP
rating increase for improving a town-owned bridge
Definition town_type.h:57
static constexpr int RATING_ROAD_DOWN_STEP_EDGE
removing a roadpiece at the edge
Definition town_type.h:66
static constexpr int RATING_ROAD_DOWN_STEP_INNER
removing a roadpiece in the middle
Definition town_type.h:65
TownCargoGenMode
Town cargo generation modes.
Definition town_type.h:111
@ Bitcount
Bit-counted algorithm (normal distribution from individual house population).
Definition town_type.h:113
static constexpr int RATING_ROAD_NEEDED_NEUTRAL
"Neutral"
Definition town_type.h:69
static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM
minimum rating after removing tunnel or bridge
Definition town_type.h:59
static constexpr int RATING_WATER_MINIMUM
minimum rating after removing water features near town
Definition town_type.h:80
TownLayout
Town Layouts.
Definition town_type.h:83
@ Original
Original algorithm (min. 1 distance between roads).
Definition town_type.h:84
@ BetterRoads
Extended original algorithm (min. 2 distance between roads).
Definition town_type.h:85
@ Grid2x2
Geometric 2x2 grid algorithm.
Definition town_type.h:86
@ Grid3x3
Geometric 3x3 grid algorithm.
Definition town_type.h:87
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT
rating needed, "Lenient" difficulty settings
Definition town_type.h:60
TownFounding
Town founding setting values.
Definition town_type.h:104
@ CustomLayout
Allowed, with custom town layout.
Definition town_type.h:107
@ Forbidden
Forbidden.
Definition town_type.h:105
@ Allowed
Allowed.
Definition town_type.h:106
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE
"Hostile"
Definition town_type.h:62
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE
"Permissive" (local authority disabled)
Definition town_type.h:63
static constexpr int RATING_STATION_DOWN_STEP
... but loses for badly serviced stations
Definition town_type.h:55
static constexpr int RATING_ROAD_MINIMUM
minimum rating after removing town owned road
Definition town_type.h:67
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL
"Neutral"
Definition town_type.h:61
static constexpr int RATING_ROAD_NEEDED_LENIENT
rating needed, "Lenient" difficulty settings
Definition town_type.h:68
static constexpr int RATING_STATION_UP_STEP
when a town grows, company gains reputation for all well serviced stations ...
Definition town_type.h:54
static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP
penalty for removing town owned tunnel or bridge
Definition town_type.h:58
TownSize
Supported initial town sizes.
Definition town_type.h:21
@ Small
Small town.
Definition town_type.h:22
@ Large
Large town.
Definition town_type.h:24
@ End
Number of available town sizes.
Definition town_type.h:27
@ Medium
Medium town.
Definition town_type.h:23
static const uint MAX_LENGTH_TOWN_NAME_CHARS
The maximum length of a town name in characters including '\0'.
Definition town_type.h:116
TownExpandMode
Options for growing towns.
Definition town_type.h:95
@ Roads
Allow town to place roads.
Definition town_type.h:97
@ Buildings
Allow town to place buildings.
Definition town_type.h:96
EnumBitSet< TownExpandMode, uint8_t > TownExpandModes
Bitset of TownExpandMode elements.
Definition town_type.h:101
static constexpr int RATING_ROAD_NEEDED_PERMISSIVE
"Permissive" (local authority disabled)
Definition town_type.h:71
static constexpr int RATING_OUTSTANDING
OUTSTANDING.
Definition town_type.h:40
static constexpr int RATING_WATER_RIVER_DOWN_STEP
removing a river tile
Definition town_type.h:79
static constexpr int RATING_GROWTH_MAXIMUM
... up to RATING_MEDIOCRE
Definition town_type.h:53