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