OpenTTD
economy_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 ECONOMY_TYPE_H
11 #define ECONOMY_TYPE_H
12 
14 #include "core/enum_type.hpp"
15 
16 typedef OverflowSafeInt64 Money;
17 
19 struct Economy {
21  int16 fluct;
23  byte infl_amount;
29 
30  /* Old stuff for savegame conversion only */
33 };
34 
36 enum ScoreID {
37  SCORE_BEGIN = 0,
38  SCORE_VEHICLES = 0,
39  SCORE_STATIONS = 1,
40  SCORE_MIN_PROFIT = 2,
41  SCORE_MIN_INCOME = 3,
42  SCORE_MAX_INCOME = 4,
43  SCORE_DELIVERED = 5,
44  SCORE_CARGO = 6,
45  SCORE_MONEY = 7,
46  SCORE_LOAN = 8,
48  SCORE_END = 10,
49 
50  SCORE_MAX = 1000,
51  /* the scores together of score_info is allowed to be more! */
52 };
54 
55 
56 struct ScoreInfo {
57  int needed;
58  int score;
59 };
60 
65 enum Price {
66  PR_BEGIN = 0,
67  PR_STATION_VALUE = 0,
68  PR_BUILD_RAIL,
69  PR_BUILD_ROAD,
70  PR_BUILD_SIGNALS,
71  PR_BUILD_BRIDGE,
72  PR_BUILD_DEPOT_TRAIN,
73  PR_BUILD_DEPOT_ROAD,
74  PR_BUILD_DEPOT_SHIP,
75  PR_BUILD_TUNNEL,
76  PR_BUILD_STATION_RAIL,
77  PR_BUILD_STATION_RAIL_LENGTH,
78  PR_BUILD_STATION_AIRPORT,
79  PR_BUILD_STATION_BUS,
80  PR_BUILD_STATION_TRUCK,
81  PR_BUILD_STATION_DOCK,
82  PR_BUILD_VEHICLE_TRAIN,
83  PR_BUILD_VEHICLE_WAGON,
84  PR_BUILD_VEHICLE_AIRCRAFT,
85  PR_BUILD_VEHICLE_ROAD,
86  PR_BUILD_VEHICLE_SHIP,
87  PR_BUILD_TREES,
88  PR_TERRAFORM,
89  PR_CLEAR_GRASS,
90  PR_CLEAR_ROUGH,
91  PR_CLEAR_ROCKS,
92  PR_CLEAR_FIELDS,
93  PR_CLEAR_TREES,
94  PR_CLEAR_RAIL,
95  PR_CLEAR_SIGNALS,
96  PR_CLEAR_BRIDGE,
97  PR_CLEAR_DEPOT_TRAIN,
98  PR_CLEAR_DEPOT_ROAD,
99  PR_CLEAR_DEPOT_SHIP,
100  PR_CLEAR_TUNNEL,
101  PR_CLEAR_WATER,
102  PR_CLEAR_STATION_RAIL,
103  PR_CLEAR_STATION_AIRPORT,
104  PR_CLEAR_STATION_BUS,
105  PR_CLEAR_STATION_TRUCK,
106  PR_CLEAR_STATION_DOCK,
107  PR_CLEAR_HOUSE,
108  PR_CLEAR_ROAD,
109  PR_RUNNING_TRAIN_STEAM,
110  PR_RUNNING_TRAIN_DIESEL,
111  PR_RUNNING_TRAIN_ELECTRIC,
112  PR_RUNNING_AIRCRAFT,
113  PR_RUNNING_ROADVEH,
114  PR_RUNNING_SHIP,
115  PR_BUILD_INDUSTRY,
116  PR_CLEAR_INDUSTRY,
117  PR_BUILD_OBJECT,
118  PR_CLEAR_OBJECT,
119  PR_BUILD_WAYPOINT_RAIL,
120  PR_CLEAR_WAYPOINT_RAIL,
121  PR_BUILD_WAYPOINT_BUOY,
122  PR_CLEAR_WAYPOINT_BUOY,
123  PR_TOWN_ACTION,
124  PR_BUILD_FOUNDATION,
125  PR_BUILD_INDUSTRY_RAW,
126  PR_BUILD_TOWN,
127  PR_BUILD_CANAL,
128  PR_CLEAR_CANAL,
129  PR_BUILD_AQUEDUCT,
130  PR_CLEAR_AQUEDUCT,
131  PR_BUILD_LOCK,
132  PR_CLEAR_LOCK,
133  PR_INFRASTRUCTURE_RAIL,
134  PR_INFRASTRUCTURE_ROAD,
135  PR_INFRASTRUCTURE_WATER,
136  PR_INFRASTRUCTURE_STATION,
137  PR_INFRASTRUCTURE_AIRPORT,
138 
139  PR_END,
140  INVALID_PRICE = 0xFF
141 };
143 
144 typedef Money Prices[PR_END];
145 typedef int8 PriceMultipliers[PR_END];
146 
148 enum ExpensesType : byte {
164 };
165 
167 template <> struct EnumPropsT<ExpensesType> : MakeEnumPropsT<ExpensesType, byte, EXPENSES_CONSTRUCTION, EXPENSES_END, INVALID_EXPENSES, 8> {};
168 
176 };
177 
184  uint grf_feature;
186 };
187 
189 static const int LOAN_INTERVAL = 10000;
190 
199 static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1;
200 
206 static const int MIN_PRICE_MODIFIER = -8;
207 static const int MAX_PRICE_MODIFIER = 16;
208 static const int INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1;
209 
211 static const uint TUNNELBRIDGE_TRACKBIT_FACTOR = 4;
213 static const uint LEVELCROSSING_TRACKBIT_FACTOR = 2;
215 static const uint LOCK_DEPOT_TILE_FACTOR = 2;
216 
217 struct CargoPayment;
218 typedef uint32 CargoPaymentID;
219 
220 #endif /* ECONOMY_TYPE_H */
Helper template class that makes basic properties of given enumeration type visible from outsize...
Definition: enum_type.hpp:62
byte infl_amount_pr
inflation rate for payment rates
Definition: economy_type.h:24
Money Prices[PR_END]
Prices of everything.
Definition: economy_type.h:144
byte infl_amount
inflation amount
Definition: economy_type.h:23
Money old_max_loan_unround
Old: Unrounded max loan.
Definition: economy_type.h:31
Money start_price
Default value at game start, before adding multipliers.
Definition: economy_type.h:182
Invalid expense type.
Definition: economy_type.h:163
static const uint LEVELCROSSING_TRACKBIT_FACTOR
Multiplier for how many regular track bits a level crossing counts.
Definition: economy_type.h:213
uint16 old_max_loan_unround_fract
Old: Fraction of the unrounded max loan.
Definition: economy_type.h:32
uint64 inflation_prices
Cumulated inflation of prices since game start; 16 bit fractional part.
Definition: economy_type.h:27
byte interest_rate
Interest.
Definition: economy_type.h:22
static const int LOAN_INTERVAL
The "steps" in loan size, in British Pounds!
Definition: economy_type.h:189
PriceCategory category
Price is affected by certain difficulty settings.
Definition: economy_type.h:183
An overflow safe integer-like type.
Price
Enumeration of all base prices for use with Prices.
Definition: economy_type.h:65
This must always be the last entry.
Definition: economy_type.h:47
Other expenses.
Definition: economy_type.h:161
Construction costs.
Definition: economy_type.h:149
static const int MIN_PRICE_MODIFIER
Maximum NewGRF price modifiers.
Definition: economy_type.h:206
uint32 industry_daily_increment
The value which will increment industry_daily_change_counter. Computed value. NOSAVE.
Definition: economy_type.h:26
Type (helpers) for enums.
Income from ships.
Definition: economy_type.h:159
Running costs aircraft.
Definition: economy_type.h:153
How many scores are there..
Definition: economy_type.h:48
Price is affected by "construction cost" difficulty setting.
Definition: economy_type.h:175
Not affected by difficulty settings.
Definition: economy_type.h:173
Interest payments over the loan.
Definition: economy_type.h:160
Informative template class exposing basic enumeration properties used by several other templates belo...
Definition: enum_type.hpp:48
int score
How much score it will give.
Definition: economy_type.h:58
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR
Multiplier for how many regular track bits a tunnel/bridge counts.
Definition: economy_type.h:211
Helper class to perform the cargo payment.
Definition: economy_base.h:24
Income from aircraft.
Definition: economy_type.h:158
Money max_loan
NOSAVE: Maximum possible loan.
Definition: economy_type.h:20
The max score that can be in the performance history.
Definition: economy_type.h:50
Data of the economy.
Definition: economy_type.h:19
Price fallback_price
Fallback price multiplier for new prices but old grfs.
Definition: economy_type.h:185
Describes properties of price bases.
Definition: economy_type.h:181
uint grf_feature
GRF Feature that decides whether price multipliers apply locally or globally, #GSF_END if none...
Definition: economy_type.h:184
Running costs trains.
Definition: economy_type.h:151
static const uint64 MAX_INFLATION
Maximum inflation (including fractional part) without causing overflows in int64 price computations...
Definition: economy_type.h:199
static const uint LOCK_DEPOT_TILE_FACTOR
Multiplier for how many regular tiles a lock counts.
Definition: economy_type.h:215
Property costs.
Definition: economy_type.h:155
uint32 industry_daily_change_counter
Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily.
Definition: economy_type.h:25
int16 fluct
Economy fluctuation status.
Definition: economy_type.h:21
uint64 inflation_payment
Cumulated inflation of cargo paypent since game start; 16 bit fractional part.
Definition: economy_type.h:28
PriceCategory
Categories of a price bases.
Definition: economy_type.h:172
Running costs ships.
Definition: economy_type.h:154
ScoreID
Score categories in the detailed performance rating.
Definition: economy_type.h:36
Price is affected by "vehicle running cost" difficulty setting.
Definition: economy_type.h:174
Data structure for storing how the score is computed for a single score id.
Definition: economy_type.h:56
int needed
How much you need to get the perfect score.
Definition: economy_type.h:57
#define DECLARE_POSTFIX_INCREMENT(enum_type)
Some enums need to have allowed incrementing (i.e.
Definition: enum_type.hpp:14
Income from road vehicles.
Definition: economy_type.h:157
New vehicles.
Definition: economy_type.h:150
Running costs road vehicles.
Definition: economy_type.h:152
Income from trains.
Definition: economy_type.h:156
Number of expense types.
Definition: economy_type.h:162
ExpensesType
Types of expenses.
Definition: economy_type.h:148