2007-12-21 21:50:46 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2007-12-21 21:50:46 +00:00
|
|
|
/** @file economy_type.h Types related to the economy. */
|
|
|
|
|
|
|
|
#ifndef ECONOMY_TYPE_H
|
|
|
|
#define ECONOMY_TYPE_H
|
|
|
|
|
|
|
|
#include "core/overflowsafe_type.hpp"
|
|
|
|
#include "core/enum_type.hpp"
|
|
|
|
|
|
|
|
typedef OverflowSafeInt64 Money;
|
|
|
|
|
2010-02-14 15:58:10 +00:00
|
|
|
/** Data of the economy. */
|
2007-12-21 21:50:46 +00:00
|
|
|
struct Economy {
|
2009-09-06 18:53:57 +00:00
|
|
|
Money max_loan; ///< NOSAVE: Maximum possible loan
|
|
|
|
int16 fluct; ///< Economy fluctuation status
|
2008-09-15 17:18:22 +00:00
|
|
|
byte interest_rate; ///< Interest
|
|
|
|
byte infl_amount; ///< inflation amount
|
|
|
|
byte infl_amount_pr; ///< inflation rate for payment rates
|
|
|
|
uint32 industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily
|
|
|
|
uint32 industry_daily_increment; ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE
|
2009-09-06 18:53:57 +00:00
|
|
|
uint64 inflation_prices; ///< Cumulated inflation of prices since game start; 16 bit fractional part
|
|
|
|
uint64 inflation_payment; ///< Cumulated inflation of cargo paypent since game start; 16 bit fractional part
|
|
|
|
|
|
|
|
/* Old stuff for savegame conversion only */
|
|
|
|
Money old_max_loan_unround; ///< Old: Unrounded max loan
|
|
|
|
uint16 old_max_loan_unround_fract; ///< Old: Fraction of the unrounded max loan
|
2007-12-21 21:50:46 +00:00
|
|
|
};
|
|
|
|
|
2010-07-31 19:45:48 +00:00
|
|
|
/** Score categories in the detailed performance rating. */
|
2007-12-21 21:50:46 +00:00
|
|
|
enum ScoreID {
|
|
|
|
SCORE_BEGIN = 0,
|
|
|
|
SCORE_VEHICLES = 0,
|
|
|
|
SCORE_STATIONS = 1,
|
|
|
|
SCORE_MIN_PROFIT = 2,
|
|
|
|
SCORE_MIN_INCOME = 3,
|
|
|
|
SCORE_MAX_INCOME = 4,
|
|
|
|
SCORE_DELIVERED = 5,
|
|
|
|
SCORE_CARGO = 6,
|
|
|
|
SCORE_MONEY = 7,
|
|
|
|
SCORE_LOAN = 8,
|
|
|
|
SCORE_TOTAL = 9, ///< This must always be the last entry
|
|
|
|
SCORE_END = 10, ///< How many scores are there..
|
|
|
|
|
2011-12-19 17:48:04 +00:00
|
|
|
SCORE_MAX = 1000, ///< The max score that can be in the performance history
|
2007-12-21 21:50:46 +00:00
|
|
|
/* the scores together of score_info is allowed to be more! */
|
|
|
|
};
|
2010-03-23 22:25:43 +00:00
|
|
|
DECLARE_POSTFIX_INCREMENT(ScoreID)
|
2007-12-21 21:50:46 +00:00
|
|
|
|
2010-07-31 19:45:48 +00:00
|
|
|
/** Data structure for storing how the score is computed for a single score id. */
|
2007-12-21 21:50:46 +00:00
|
|
|
struct ScoreInfo {
|
|
|
|
int needed; ///< How much you need to get the perfect score
|
|
|
|
int score; ///< How much score it will give
|
|
|
|
};
|
|
|
|
|
2009-11-08 12:23:02 +00:00
|
|
|
/**
|
|
|
|
* Enumeration of all base prices for use with #Prices.
|
|
|
|
* The prices are ordered as they are expected by NewGRF cost multipliers, so don't shuffle them.
|
|
|
|
*/
|
2009-11-07 22:47:54 +00:00
|
|
|
enum Price {
|
2009-11-08 12:23:02 +00:00
|
|
|
PR_BEGIN = 0,
|
2009-11-07 22:47:54 +00:00
|
|
|
PR_STATION_VALUE = 0,
|
|
|
|
PR_BUILD_RAIL,
|
|
|
|
PR_BUILD_ROAD,
|
|
|
|
PR_BUILD_SIGNALS,
|
|
|
|
PR_BUILD_BRIDGE,
|
|
|
|
PR_BUILD_DEPOT_TRAIN,
|
|
|
|
PR_BUILD_DEPOT_ROAD,
|
|
|
|
PR_BUILD_DEPOT_SHIP,
|
|
|
|
PR_BUILD_TUNNEL,
|
|
|
|
PR_BUILD_STATION_RAIL,
|
|
|
|
PR_BUILD_STATION_RAIL_LENGTH,
|
|
|
|
PR_BUILD_STATION_AIRPORT,
|
|
|
|
PR_BUILD_STATION_BUS,
|
|
|
|
PR_BUILD_STATION_TRUCK,
|
|
|
|
PR_BUILD_STATION_DOCK,
|
|
|
|
PR_BUILD_VEHICLE_TRAIN,
|
|
|
|
PR_BUILD_VEHICLE_WAGON,
|
|
|
|
PR_BUILD_VEHICLE_AIRCRAFT,
|
|
|
|
PR_BUILD_VEHICLE_ROAD,
|
|
|
|
PR_BUILD_VEHICLE_SHIP,
|
|
|
|
PR_BUILD_TREES,
|
|
|
|
PR_TERRAFORM,
|
|
|
|
PR_CLEAR_GRASS,
|
|
|
|
PR_CLEAR_ROUGH,
|
|
|
|
PR_CLEAR_ROCKS,
|
2010-01-29 00:11:30 +00:00
|
|
|
PR_CLEAR_FIELDS,
|
2009-11-07 22:47:54 +00:00
|
|
|
PR_CLEAR_TREES,
|
|
|
|
PR_CLEAR_RAIL,
|
|
|
|
PR_CLEAR_SIGNALS,
|
|
|
|
PR_CLEAR_BRIDGE,
|
|
|
|
PR_CLEAR_DEPOT_TRAIN,
|
|
|
|
PR_CLEAR_DEPOT_ROAD,
|
|
|
|
PR_CLEAR_DEPOT_SHIP,
|
|
|
|
PR_CLEAR_TUNNEL,
|
|
|
|
PR_CLEAR_WATER,
|
|
|
|
PR_CLEAR_STATION_RAIL,
|
|
|
|
PR_CLEAR_STATION_AIRPORT,
|
|
|
|
PR_CLEAR_STATION_BUS,
|
|
|
|
PR_CLEAR_STATION_TRUCK,
|
|
|
|
PR_CLEAR_STATION_DOCK,
|
|
|
|
PR_CLEAR_HOUSE,
|
|
|
|
PR_CLEAR_ROAD,
|
|
|
|
PR_RUNNING_TRAIN_STEAM,
|
|
|
|
PR_RUNNING_TRAIN_DIESEL,
|
|
|
|
PR_RUNNING_TRAIN_ELECTRIC,
|
|
|
|
PR_RUNNING_AIRCRAFT,
|
|
|
|
PR_RUNNING_ROADVEH,
|
|
|
|
PR_RUNNING_SHIP,
|
|
|
|
PR_BUILD_INDUSTRY,
|
2009-11-24 22:15:42 +00:00
|
|
|
PR_CLEAR_INDUSTRY,
|
2010-08-08 10:59:30 +00:00
|
|
|
PR_BUILD_OBJECT,
|
|
|
|
PR_CLEAR_OBJECT,
|
2009-11-24 22:15:42 +00:00
|
|
|
PR_BUILD_WAYPOINT_RAIL,
|
|
|
|
PR_CLEAR_WAYPOINT_RAIL,
|
|
|
|
PR_BUILD_WAYPOINT_BUOY,
|
|
|
|
PR_CLEAR_WAYPOINT_BUOY,
|
|
|
|
PR_TOWN_ACTION,
|
|
|
|
PR_BUILD_FOUNDATION,
|
|
|
|
PR_BUILD_INDUSTRY_RAW,
|
|
|
|
PR_BUILD_TOWN,
|
2010-04-25 13:56:51 +00:00
|
|
|
PR_BUILD_CANAL,
|
|
|
|
PR_CLEAR_CANAL,
|
|
|
|
PR_BUILD_AQUEDUCT,
|
|
|
|
PR_CLEAR_AQUEDUCT,
|
|
|
|
PR_BUILD_LOCK,
|
|
|
|
PR_CLEAR_LOCK,
|
2011-12-03 23:40:46 +00:00
|
|
|
PR_INFRASTRUCTURE_RAIL,
|
|
|
|
PR_INFRASTRUCTURE_ROAD,
|
|
|
|
PR_INFRASTRUCTURE_WATER,
|
|
|
|
PR_INFRASTRUCTURE_STATION,
|
|
|
|
PR_INFRASTRUCTURE_AIRPORT,
|
2009-11-07 22:47:54 +00:00
|
|
|
|
2009-11-08 12:23:02 +00:00
|
|
|
PR_END,
|
2009-11-07 22:47:54 +00:00
|
|
|
INVALID_PRICE = 0xFF
|
2007-12-21 21:50:46 +00:00
|
|
|
};
|
2009-11-08 12:23:02 +00:00
|
|
|
DECLARE_POSTFIX_INCREMENT(Price)
|
2007-12-21 21:50:46 +00:00
|
|
|
|
2010-02-14 15:58:10 +00:00
|
|
|
typedef Money Prices[PR_END]; ///< Prices of everything. @see Price
|
2009-11-24 13:15:58 +00:00
|
|
|
typedef int8 PriceMultipliers[PR_END];
|
2007-12-21 21:50:46 +00:00
|
|
|
|
2010-02-14 15:58:10 +00:00
|
|
|
/** Types of expenses. */
|
2007-12-21 21:50:46 +00:00
|
|
|
enum ExpensesType {
|
2010-02-14 15:58:10 +00:00
|
|
|
EXPENSES_CONSTRUCTION = 0, ///< Construction costs.
|
|
|
|
EXPENSES_NEW_VEHICLES, ///< New vehicles.
|
|
|
|
EXPENSES_TRAIN_RUN, ///< Running costs trains.
|
|
|
|
EXPENSES_ROADVEH_RUN, ///< Running costs road vehicles.
|
2018-04-30 16:52:32 +00:00
|
|
|
EXPENSES_AIRCRAFT_RUN, ///< Running costs aircraft.
|
2010-02-14 15:58:10 +00:00
|
|
|
EXPENSES_SHIP_RUN, ///< Running costs ships.
|
|
|
|
EXPENSES_PROPERTY, ///< Property costs.
|
|
|
|
EXPENSES_TRAIN_INC, ///< Income from trains.
|
|
|
|
EXPENSES_ROADVEH_INC, ///< Income from road vehicles.
|
2018-04-30 16:52:32 +00:00
|
|
|
EXPENSES_AIRCRAFT_INC, ///< Income from aircraft.
|
2010-02-14 15:58:10 +00:00
|
|
|
EXPENSES_SHIP_INC, ///< Income from ships.
|
|
|
|
EXPENSES_LOAN_INT, ///< Interest payments over the loan.
|
|
|
|
EXPENSES_OTHER, ///< Other expenses.
|
|
|
|
EXPENSES_END, ///< Number of expense types.
|
|
|
|
INVALID_EXPENSES = 0xFF, ///< Invalid expense type.
|
2007-12-21 21:50:46 +00:00
|
|
|
};
|
|
|
|
|
2013-09-21 13:07:42 +00:00
|
|
|
/** Define basic enum properties for ExpensesType */
|
|
|
|
template <> struct EnumPropsT<ExpensesType> : MakeEnumPropsT<ExpensesType, byte, EXPENSES_CONSTRUCTION, EXPENSES_END, INVALID_EXPENSES, 8> {};
|
|
|
|
typedef TinyEnumT<ExpensesType> ExpensesTypeByte; ///< typedefing-enumification of ExpensesType
|
|
|
|
|
2009-08-02 12:34:26 +00:00
|
|
|
/**
|
|
|
|
* Categories of a price bases.
|
|
|
|
*/
|
|
|
|
enum PriceCategory {
|
2009-08-02 13:56:14 +00:00
|
|
|
PCAT_NONE, ///< Not affected by difficulty settings
|
|
|
|
PCAT_RUNNING, ///< Price is affected by "vehicle running cost" difficulty setting
|
|
|
|
PCAT_CONSTRUCTION, ///< Price is affected by "construction cost" difficulty setting
|
2009-08-02 12:34:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Describes properties of price bases.
|
|
|
|
*/
|
|
|
|
struct PriceBaseSpec {
|
|
|
|
Money start_price; ///< Default value at game start, before adding multipliers.
|
|
|
|
PriceCategory category; ///< Price is affected by certain difficulty settings.
|
2010-10-30 17:51:07 +00:00
|
|
|
uint grf_feature; ///< GRF Feature that decides whether price multipliers apply locally or globally, #GSF_END if none.
|
2009-11-24 22:15:42 +00:00
|
|
|
Price fallback_price; ///< Fallback price multiplier for new prices but old grfs.
|
2009-08-02 12:34:26 +00:00
|
|
|
};
|
|
|
|
|
2009-05-11 11:13:37 +00:00
|
|
|
/** The "steps" in loan size, in British Pounds! */
|
|
|
|
static const int LOAN_INTERVAL = 10000;
|
2008-01-12 14:10:35 +00:00
|
|
|
|
2009-09-06 18:53:57 +00:00
|
|
|
/**
|
|
|
|
* Maximum inflation (including fractional part) without causing overflows in int64 price computations.
|
|
|
|
* This allows for 32 bit base prices (21 are currently needed).
|
|
|
|
* Considering the sign bit and 16 fractional bits, there are 15 bits left.
|
|
|
|
* 170 years of 4% inflation result in a inflation of about 822, so 10 bits are actually enough.
|
2010-10-30 17:51:07 +00:00
|
|
|
* Note that NewGRF multipliers share the 16 fractional bits.
|
2009-09-06 18:53:57 +00:00
|
|
|
* @see MAX_PRICE_MODIFIER
|
|
|
|
*/
|
|
|
|
static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1;
|
|
|
|
|
|
|
|
/**
|
2009-11-08 18:04:53 +00:00
|
|
|
* Maximum NewGRF price modifiers.
|
2009-09-06 18:53:57 +00:00
|
|
|
* Increasing base prices by factor 65536 should be enough.
|
|
|
|
* @see MAX_INFLATION
|
|
|
|
*/
|
2010-05-13 09:44:44 +00:00
|
|
|
static const int MIN_PRICE_MODIFIER = -8;
|
|
|
|
static const int MAX_PRICE_MODIFIER = 16;
|
|
|
|
static const int INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1;
|
2009-09-06 18:53:57 +00:00
|
|
|
|
2011-12-03 23:40:13 +00:00
|
|
|
/** Multiplier for how many regular track bits a tunnel/bridge counts. */
|
|
|
|
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR = 4;
|
|
|
|
/** Multiplier for how many regular track bits a level crossing counts. */
|
|
|
|
static const uint LEVELCROSSING_TRACKBIT_FACTOR = 2;
|
2011-12-03 23:40:23 +00:00
|
|
|
/** Multiplier for how many regular tiles a lock counts. */
|
|
|
|
static const uint LOCK_DEPOT_TILE_FACTOR = 2;
|
2011-12-03 23:40:13 +00:00
|
|
|
|
2009-06-29 19:55:36 +00:00
|
|
|
struct CargoPayment;
|
|
|
|
typedef uint32 CargoPaymentID;
|
|
|
|
|
2007-12-21 21:50:46 +00:00
|
|
|
#endif /* ECONOMY_TYPE_H */
|