OpenTTD Source 20241224-master-gf74b0cf984
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 <http://www.gnu.org/licenses/>.
6 */
7
10#ifndef TOWN_TYPE_H
11#define TOWN_TYPE_H
12
13#include "core/enum_type.hpp"
14
15typedef uint16_t TownID;
16struct Town;
17
28
29/* These refer to the maximums, so Appalling is -1000 to -400
30 * MAXIMUM RATINGS BOUNDARIES */
31static constexpr int RATING_MINIMUM = -1000;
32static constexpr int RATING_APPALLING = -400;
33static constexpr int RATING_VERYPOOR = -200;
34static constexpr int RATING_POOR = 0;
35static constexpr int RATING_MEDIOCRE = 200;
36static constexpr int RATING_GOOD = 400;
37static constexpr int RATING_VERYGOOD = 600;
38static constexpr int RATING_EXCELLENT = 800;
39static constexpr int RATING_OUTSTANDING = 1000;
40
41static constexpr int RATING_MAXIMUM = RATING_OUTSTANDING;
42
43static constexpr int RATING_INITIAL = 500;
44
45/* RATINGS AFFECTING NUMBERS */
46static constexpr int RATING_TREE_DOWN_STEP = -35;
47static constexpr int RATING_TREE_MINIMUM = RATING_MINIMUM;
48static constexpr int RATING_TREE_UP_STEP = 7;
49static constexpr int RATING_TREE_MAXIMUM = 220;
50
51static constexpr int RATING_GROWTH_UP_STEP = 5;
52static constexpr int RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE;
53static constexpr int RATING_STATION_UP_STEP = 12;
54static constexpr int RATING_STATION_DOWN_STEP = -15;
55
56static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP = 50;
57static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP = -250;
58static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM = 0;
59static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144;
60static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL = 208;
61static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE = 400;
62static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE = RATING_MINIMUM;
63
64static constexpr int RATING_ROAD_DOWN_STEP_INNER = -50;
65static constexpr int RATING_ROAD_DOWN_STEP_EDGE = -18;
66static constexpr int RATING_ROAD_MINIMUM = -100;
67static constexpr int RATING_ROAD_NEEDED_LENIENT = 16;
68static constexpr int RATING_ROAD_NEEDED_NEUTRAL = 64;
69static constexpr int RATING_ROAD_NEEDED_HOSTILE = 112;
70static constexpr int RATING_ROAD_NEEDED_PERMISSIVE = RATING_MINIMUM;
71
72static constexpr int RATING_HOUSE_MINIMUM = RATING_MINIMUM;
73
74static constexpr int RATING_BRIBE_UP_STEP = 200;
75static constexpr int RATING_BRIBE_MAXIMUM = 800;
76static constexpr int RATING_BRIBE_DOWN_TO = -50; // XXX SHOULD BE SOMETHING LOWER?
77
91
92
100
102enum TownCargoGenMode : uint8_t {
103 TCGM_BEGIN = 0,
106 TCGM_END,
107};
108
109static const uint MAX_LENGTH_TOWN_NAME_CHARS = 32;
110
112template <typename Tstorage>
114 Tstorage old_max;
115 Tstorage new_max;
116 Tstorage old_act;
117 Tstorage new_act;
118
120
122 void NewMonth()
123 {
124 this->old_max = this->new_max; this->new_max = 0;
125 this->old_act = this->new_act; this->new_act = 0;
126 }
127};
128
129#endif /* TOWN_TYPE_H */
Type (helpers) for enums.
#define DECLARE_ENUM_AS_ADDABLE(EnumType)
Operator that allows this enumeration to be added to any other enumeration.
Definition enum_type.hpp:45
Town data structure.
Definition town.h:54
Store the maximum and actually transported cargo amount for the current and the last month.
Definition town_type.h:113
Tstorage new_max
Maximum amount this month.
Definition town_type.h:115
void NewMonth()
Update stats for a new month.
Definition town_type.h:122
Tstorage old_max
Maximum amount last month.
Definition town_type.h:114
Tstorage old_act
Actually transported last month.
Definition town_type.h:116
Tstorage new_act
Actually transported this month.
Definition town_type.h:117
static constexpr int RATING_GROWTH_UP_STEP
when a town grows, all companies have rating increased a bit ...
Definition town_type.h:51
static constexpr int RATING_INITIAL
initial rating
Definition town_type.h:43
static constexpr int RATING_ROAD_NEEDED_HOSTILE
"Hostile"
Definition town_type.h:69
static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP
rating increase for improving a town-owned bridge
Definition town_type.h:56
static constexpr int RATING_ROAD_DOWN_STEP_EDGE
removing a roadpiece at the edge
Definition town_type.h:65
static constexpr int RATING_ROAD_DOWN_STEP_INNER
removing a roadpiece in the middle
Definition town_type.h:64
TownCargoGenMode
Town cargo generation modes.
Definition town_type.h:102
@ TCGM_BITCOUNT
Bit-counted algorithm (normal distribution from individual house population)
Definition town_type.h:105
@ TCGM_ORIGINAL
Original algorithm (quadratic cargo by population)
Definition town_type.h:104
static constexpr int RATING_ROAD_NEEDED_NEUTRAL
"Neutral"
Definition town_type.h:68
static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM
minimum rating after removing tunnel or bridge
Definition town_type.h:58
TownLayout
Town Layouts.
Definition town_type.h:79
@ TL_3X3_GRID
Geometric 3x3 grid algorithm.
Definition town_type.h:84
@ TL_ORIGINAL
Original algorithm (min. 1 distance between roads)
Definition town_type.h:81
@ TL_2X2_GRID
Geometric 2x2 grid algorithm.
Definition town_type.h:83
@ TL_RANDOM
Random town layout.
Definition town_type.h:86
@ TL_BETTER_ROADS
Extended original algorithm (min. 2 distance between roads)
Definition town_type.h:82
@ NUM_TLS
Number of town layouts.
Definition town_type.h:88
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT
rating needed, "Lenient" difficulty settings
Definition town_type.h:59
TownFounding
Town founding setting values.
Definition town_type.h:93
@ TF_ALLOWED
Allowed.
Definition town_type.h:96
@ TF_CUSTOM_LAYOUT
Allowed, with custom town layout.
Definition town_type.h:97
@ TF_END
Used for iterations and limit testing.
Definition town_type.h:98
@ TF_BEGIN
Used for iterations and limit testing.
Definition town_type.h:94
@ TF_FORBIDDEN
Forbidden.
Definition town_type.h:95
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE
"Hostile"
Definition town_type.h:61
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE
"Permissive" (local authority disabled)
Definition town_type.h:62
static constexpr int RATING_STATION_DOWN_STEP
... but loses for badly serviced stations
Definition town_type.h:54
static constexpr int RATING_ROAD_MINIMUM
minimum rating after removing town owned road
Definition town_type.h:66
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL
"Neutral"
Definition town_type.h:60
static constexpr int RATING_ROAD_NEEDED_LENIENT
rating needed, "Lenient" difficulty settings
Definition town_type.h:67
static constexpr int RATING_STATION_UP_STEP
when a town grows, company gains reputation for all well serviced stations ...
Definition town_type.h:53
static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP
penalty for removing town owned tunnel or bridge
Definition town_type.h:57
TownSize
Supported initial town sizes.
Definition town_type.h:19
@ TSZ_RANDOM
Random size, bigger than small, smaller than large.
Definition town_type.h:23
@ TSZ_END
Number of available town sizes.
Definition town_type.h:25
@ TSZ_MEDIUM
Medium town.
Definition town_type.h:21
@ TSZ_SMALL
Small town.
Definition town_type.h:20
@ TSZ_LARGE
Large town.
Definition town_type.h:22
static const uint MAX_LENGTH_TOWN_NAME_CHARS
The maximum length of a town name in characters including '\0'.
Definition town_type.h:109
static constexpr int RATING_ROAD_NEEDED_PERMISSIVE
"Permissive" (local authority disabled)
Definition town_type.h:70
static constexpr int RATING_OUTSTANDING
OUTSTANDING.
Definition town_type.h:39
static constexpr int RATING_GROWTH_MAXIMUM
... up to RATING_MEDIOCRE
Definition town_type.h:52