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