OpenTTD Source  12.0-beta2
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 
15 typedef uint16 TownID;
16 struct Town;
17 
19 enum TownSize {
24 
26 };
27 template <> struct EnumPropsT<TownSize> : MakeEnumPropsT<TownSize, byte, TSZ_SMALL, TSZ_END, TSZ_END, 2> {};
28 
29 enum Ratings {
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,
35  RATING_POOR = 0,
36  RATING_MEDIOCRE = 200,
37  RATING_GOOD = 400,
38  RATING_VERYGOOD = 600,
39  RATING_EXCELLENT = 800,
41 
42  RATING_MAXIMUM = RATING_OUTSTANDING,
43 
45 
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,
51 
53  RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE,
56 
62 
69 
70  RATING_HOUSE_MINIMUM = RATING_MINIMUM,
71 
72  RATING_BRIBE_UP_STEP = 200,
73  RATING_BRIBE_MAXIMUM = 800,
74  RATING_BRIBE_DOWN_TO = -50 // XXX SHOULD BE SOMETHING LOWER?
75 };
76 
78 enum TownLayout : byte {
79  TL_BEGIN = 0,
84 
86 
88 };
89 template <> struct EnumPropsT<TownLayout> : MakeEnumPropsT<TownLayout, byte, TL_BEGIN, NUM_TLS, NUM_TLS, 3> {};
90 
92 enum TownFounding : byte {
93  TF_BEGIN = 0,
98 };
99 
101 enum TownCargoGenMode : byte {
102  TCGM_BEGIN = 0,
105  TCGM_END,
106 };
107 
108 static const uint MAX_LENGTH_TOWN_NAME_CHARS = 32;
109 
111 template <typename Tstorage>
113  Tstorage old_max;
114  Tstorage new_max;
115  Tstorage old_act;
116  Tstorage new_act;
117 
118  TransportedCargoStat() : old_max(0), new_max(0), old_act(0), new_act(0) {}
119 
121  void NewMonth()
122  {
123  this->old_max = this->new_max; this->new_max = 0;
124  this->old_act = this->new_act; this->new_act = 0;
125  }
126 };
127 
128 #endif /* TOWN_TYPE_H */
RATING_STATION_UP_STEP
@ RATING_STATION_UP_STEP
when a town grows, company gains reputation for all well serviced stations ...
Definition: town_type.h:54
RATING_STATION_DOWN_STEP
@ RATING_STATION_DOWN_STEP
... but loses for badly serviced stations
Definition: town_type.h:55
RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE
@ RATING_TUNNEL_BRIDGE_NEEDED_HOSTILE
"Hostile"
Definition: town_type.h:61
TownCargoGenMode
TownCargoGenMode
Town cargo generation modes.
Definition: town_type.h:101
RATING_TUNNEL_BRIDGE_MINIMUM
@ RATING_TUNNEL_BRIDGE_MINIMUM
minimum rating after removing tunnel or bridge
Definition: town_type.h:58
TF_FORBIDDEN
@ TF_FORBIDDEN
Forbidden.
Definition: town_type.h:94
TL_RANDOM
@ TL_RANDOM
Random town layout.
Definition: town_type.h:85
TownSize
TownSize
Supported initial town sizes.
Definition: town_type.h:19
TF_ALLOWED
@ TF_ALLOWED
Allowed.
Definition: town_type.h:95
TCGM_ORIGINAL
@ TCGM_ORIGINAL
Original algorithm (quadratic cargo by population)
Definition: town_type.h:103
TownLayout
TownLayout
Town Layouts.
Definition: town_type.h:78
RATING_GROWTH_UP_STEP
@ RATING_GROWTH_UP_STEP
when a town grows, all companies have rating increased a bit ...
Definition: town_type.h:52
TransportedCargoStat::NewMonth
void NewMonth()
Update stats for a new month.
Definition: town_type.h:121
RATING_INITIAL
@ RATING_INITIAL
initial rating
Definition: town_type.h:44
TF_CUSTOM_LAYOUT
@ TF_CUSTOM_LAYOUT
Allowed, with custom town layout.
Definition: town_type.h:96
TSZ_MEDIUM
@ TSZ_MEDIUM
Medium town.
Definition: town_type.h:21
TownFounding
TownFounding
Town founding setting values.
Definition: town_type.h:92
EnumPropsT
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:48
TL_BETTER_ROADS
@ TL_BETTER_ROADS
Extended original algorithm (min. 2 distance between roads)
Definition: town_type.h:81
TF_BEGIN
@ TF_BEGIN
Used for iterations and limit testing.
Definition: town_type.h:93
RATING_ROAD_NEEDED_HOSTILE
@ RATING_ROAD_NEEDED_HOSTILE
"Hostile"
Definition: town_type.h:68
TF_END
@ TF_END
Used for iterations and limit testing.
Definition: town_type.h:97
TSZ_END
@ TSZ_END
Number of available town sizes.
Definition: town_type.h:25
TL_3X3_GRID
@ TL_3X3_GRID
Geometric 3x3 grid algorithm.
Definition: town_type.h:83
TSZ_SMALL
@ TSZ_SMALL
Small town.
Definition: town_type.h:20
RATING_ROAD_MINIMUM
@ RATING_ROAD_MINIMUM
minimum rating after removing town owned road
Definition: town_type.h:65
TSZ_RANDOM
@ TSZ_RANDOM
Random size, bigger than small, smaller than large.
Definition: town_type.h:23
RATING_ROAD_NEEDED_NEUTRAL
@ RATING_ROAD_NEEDED_NEUTRAL
"Neutral"
Definition: town_type.h:67
RATING_ROAD_NEEDED_PERMISSIVE
@ RATING_ROAD_NEEDED_PERMISSIVE
rating needed, "Permissive" difficulty settings
Definition: town_type.h:66
TransportedCargoStat::new_max
Tstorage new_max
Maximum amount this month.
Definition: town_type.h:114
TransportedCargoStat::old_max
Tstorage old_max
Maximum amount last month.
Definition: town_type.h:113
Ratings
Ratings
Definition: town_type.h:29
TCGM_BITCOUNT
@ TCGM_BITCOUNT
Bit-counted algorithm (normal distribution from individual house population)
Definition: town_type.h:104
TransportedCargoStat::new_act
Tstorage new_act
Actually transported this month.
Definition: town_type.h:116
RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE
@ RATING_TUNNEL_BRIDGE_NEEDED_PERMISSIVE
rating needed, "Permissive" difficulty settings
Definition: town_type.h:59
RATING_GROWTH_MAXIMUM
@ RATING_GROWTH_MAXIMUM
... up to RATING_MEDIOCRE
Definition: town_type.h:53
TransportedCargoStat::old_act
Tstorage old_act
Actually transported last month.
Definition: town_type.h:115
RATING_ROAD_DOWN_STEP_EDGE
@ RATING_ROAD_DOWN_STEP_EDGE
removing a roadpiece at the edge
Definition: town_type.h:64
enum_type.hpp
MakeEnumPropsT
Helper template class that makes basic properties of given enumeration type visible from outsize.
Definition: enum_type.hpp:62
RATING_OUTSTANDING
@ RATING_OUTSTANDING
OUTSTANDING.
Definition: town_type.h:40
Town
Town data structure.
Definition: town.h:50
RATING_ROAD_DOWN_STEP_INNER
@ RATING_ROAD_DOWN_STEP_INNER
removing a roadpiece in the middle
Definition: town_type.h:63
TL_ORIGINAL
@ TL_ORIGINAL
Original algorithm (min. 1 distance between roads)
Definition: town_type.h:80
NUM_TLS
@ NUM_TLS
Number of town layouts.
Definition: town_type.h:87
TSZ_LARGE
@ TSZ_LARGE
Large town.
Definition: town_type.h:22
MAX_LENGTH_TOWN_NAME_CHARS
static const uint MAX_LENGTH_TOWN_NAME_CHARS
The maximum length of a town name in characters including '\0'.
Definition: town_type.h:108
TL_2X2_GRID
@ TL_2X2_GRID
Geometric 2x2 grid algorithm.
Definition: town_type.h:82
RATING_TUNNEL_BRIDGE_DOWN_STEP
@ RATING_TUNNEL_BRIDGE_DOWN_STEP
penalty for removing town owned tunnel or bridge
Definition: town_type.h:57
TransportedCargoStat
Store the maximum and actually transported cargo amount for the current and the last month.
Definition: town_type.h:112
RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL
@ RATING_TUNNEL_BRIDGE_NEEDED_NEUTRAL
"Neutral"
Definition: town_type.h:60