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 TownID
;
18 /** Supported initial town sizes */
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 template <> struct EnumPropsT
<TownSize
> : MakeEnumPropsT
<TownSize
, byte
, TSZ_SMALL
, TSZ_END
, TSZ_END
, 2> {};
30 /* These refer to the maximums, so Appalling is -1000 to -400
31 * MAXIMUM RATINGS BOUNDARIES */
32 RATING_MINIMUM
= -1000,
33 RATING_APPALLING
= -400,
34 RATING_VERYPOOR
= -200,
36 RATING_MEDIOCRE
= 200,
38 RATING_VERYGOOD
= 600,
39 RATING_EXCELLENT
= 800,
40 RATING_OUTSTANDING
= 1000, ///< OUTSTANDING
42 RATING_MAXIMUM
= RATING_OUTSTANDING
,
44 RATING_INITIAL
= 500, ///< initial rating
46 /* RATINGS AFFECTING NUMBERS */
47 RATING_TREE_DOWN_STEP
= -35,
48 RATING_TREE_MINIMUM
= RATING_MINIMUM
,
49 RATING_TREE_UP_STEP
= 7,
50 RATING_TREE_MAXIMUM
= 220,
52 RATING_GROWTH_UP_STEP
= 5, ///< when a town grows, all companies have rating increased a bit ...
53 RATING_GROWTH_MAXIMUM
= RATING_MEDIOCRE
, ///< ... up to RATING_MEDIOCRE
54 RATING_STATION_UP_STEP
= 12, ///< when a town grows, company gains reputation for all well serviced stations ...
55 RATING_STATION_DOWN_STEP
= -15, ///< ... but loses for badly serviced stations
57 RATING_TUNNEL_BRIDGE_DOWN_STEP
= -250, ///< penalty for removing town owned tunnel or bridge
58 RATING_TUNNEL_BRIDGE_MINIMUM
= 0, ///< minimum rating after removing tunnel or bridge
59 RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE
= 144, ///< rating needed, "Permissive" difficulty settings
60 RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL
= 208, ///< "Neutral"
61 RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE
= 400, ///< "Hostile"
63 RATING_ROAD_DOWN_STEP_INNER
= -50, ///< removing a roadpiece in the middle
64 RATING_ROAD_DOWN_STEP_EDGE
= -18, ///< removing a roadpiece at the edge
65 RATING_ROAD_MINIMUM
= -100, ///< minimum rating after removing town owned road
66 RATING_ROAD_NEEDED_PERMISSIVE
= 16, ///< rating needed, "Permissive" difficulty settings
67 RATING_ROAD_NEEDED_NEUTRAL
= 64, ///< "Neutral"
68 RATING_ROAD_NEEDED_HOSTILE
= 112, ///< "Hostile"
70 RATING_HOUSE_MINIMUM
= RATING_MINIMUM
,
72 RATING_BRIBE_UP_STEP
= 200,
73 RATING_BRIBE_MAXIMUM
= 800,
74 RATING_BRIBE_DOWN_TO
= -50 // XXX SHOULD BE SOMETHING LOWER?
77 /** Town Layouts. It needs to be 8bits, because we save and load it as such */
78 enum TownLayout
: byte
{
80 TL_ORIGINAL
= 0, ///< Original algorithm (min. 1 distance between roads)
81 TL_BETTER_ROADS
, ///< Extended original algorithm (min. 2 distance between roads)
82 TL_2X2_GRID
, ///< Geometric 2x2 grid algorithm
83 TL_3X3_GRID
, ///< Geometric 3x3 grid algorithm
85 TL_RANDOM
, ///< Random town layout
87 NUM_TLS
, ///< Number of town layouts
89 template <> struct EnumPropsT
<TownLayout
> : MakeEnumPropsT
<TownLayout
, byte
, TL_BEGIN
, NUM_TLS
, NUM_TLS
, 3> {};
91 /** Town founding setting values. It needs to be 8bits, because we save and load it as such */
92 enum TownFounding
: byte
{
93 TF_BEGIN
= 0, ///< Used for iterations and limit testing
94 TF_FORBIDDEN
= 0, ///< Forbidden
95 TF_ALLOWED
, ///< Allowed
96 TF_CUSTOM_LAYOUT
, ///< Allowed, with custom town layout
97 TF_END
, ///< Used for iterations and limit testing
100 /** Town cargo generation modes */
101 enum TownCargoGenMode
: byte
{
103 TCGM_ORIGINAL
= 0, ///< Original algorithm (quadratic cargo by population)
104 TCGM_BITCOUNT
, ///< Bit-counted algorithm (normal distribution from individual house population)
108 static const uint MAX_LENGTH_TOWN_NAME_CHARS
= 32; ///< The maximum length of a town name in characters including '\0'
110 /** Store the maximum and actually transported cargo amount for the current and the last month. */
111 template <typename Tstorage
>
112 struct TransportedCargoStat
{
113 Tstorage old_max
; ///< Maximum amount last month
114 Tstorage new_max
; ///< Maximum amount this month
115 Tstorage old_act
; ///< Actually transported last month
116 Tstorage new_act
; ///< Actually transported this month
118 TransportedCargoStat() : old_max(0), new_max(0), old_act(0), new_act(0) {}
120 /** Update stats for a new month. */
123 this->old_max
= this->new_max
; this->new_max
= 0;
124 this->old_act
= this->new_act
; this->new_act
= 0;
128 #endif /* TOWN_TYPE_H */