OpenTTD Source 20250312-master-gcdcc6b491d
|
Types related to the economy. More...
Go to the source code of this file.
Data Structures | |
struct | Economy |
Data of the economy. More... | |
struct | ScoreInfo |
Data structure for storing how the score is computed for a single score id. More... | |
struct | PriceBaseSpec |
Describes properties of price bases. More... | |
Typedefs | |
typedef OverflowSafeInt64 | Money |
typedef Money | Prices[PR_END] |
Prices of everything. | |
using | PriceMultipliers = std::array< int8_t, PR_END > |
using | Expenses = std::array< Money, EXPENSES_END > |
Data type for storage of Money for each ExpensesType category. | |
using | CargoPaymentID = PoolID< uint32_t, struct CargoPaymentIDTag, 0xFF000, 0xFFFFF > |
Enumerations | |
enum | EconomyType : uint8_t { ET_BEGIN = 0 , ET_ORIGINAL = 0 , ET_SMOOTH = 1 , ET_FROZEN = 2 , ET_END = 3 } |
Type of the game economy. More... | |
enum | ScoreID : uint8_t { 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 , SCORE_END = 10 } |
Score categories in the detailed performance rating. More... | |
enum | Price : uint8_t { PR_BEGIN = 0 , 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 , PR_CLEAR_FIELDS , 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 , PR_CLEAR_INDUSTRY , PR_BUILD_OBJECT , PR_CLEAR_OBJECT , 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 , PR_BUILD_CANAL , PR_CLEAR_CANAL , PR_BUILD_AQUEDUCT , PR_CLEAR_AQUEDUCT , PR_BUILD_LOCK , PR_CLEAR_LOCK , PR_INFRASTRUCTURE_RAIL , PR_INFRASTRUCTURE_ROAD , PR_INFRASTRUCTURE_WATER , PR_INFRASTRUCTURE_STATION , PR_INFRASTRUCTURE_AIRPORT , PR_END , INVALID_PRICE = 0xFF } |
Enumeration of all base prices for use with Prices. More... | |
enum | ExpensesType : uint8_t { EXPENSES_CONSTRUCTION = 0 , EXPENSES_NEW_VEHICLES , EXPENSES_TRAIN_RUN , EXPENSES_ROADVEH_RUN , EXPENSES_AIRCRAFT_RUN , EXPENSES_SHIP_RUN , EXPENSES_PROPERTY , EXPENSES_TRAIN_REVENUE , EXPENSES_ROADVEH_REVENUE , EXPENSES_AIRCRAFT_REVENUE , EXPENSES_SHIP_REVENUE , EXPENSES_LOAN_INTEREST , EXPENSES_OTHER , EXPENSES_END , INVALID_EXPENSES = 0xFF } |
Types of expenses. More... | |
enum | PriceCategory : uint8_t { PCAT_NONE , PCAT_RUNNING , PCAT_CONSTRUCTION } |
Categories of a price bases. More... | |
Variables | |
static const int | MIN_CARGO_SCALE = 15 |
Minimum allowed value of town_cargo_scale/industry_cargo_scale. | |
static const int | MAX_CARGO_SCALE = 300 |
Maximum allowed value of town_cargo_scale/industry_cargo_scale. | |
static const int | DEF_CARGO_SCALE = 100 |
Default value of town_cargo_scale/industry_cargo_scale. | |
static constexpr int | SCORE_MAX = 1000 |
The max score that can be in the performance history. | |
static const int | LOAN_INTERVAL = 10000 |
The "steps" in loan size, in British Pounds! | |
static const int64_t | INITIAL_LOAN = 100000 |
The size of loan for a new company, in British Pounds! | |
static const int64_t | MAX_LOAN_LIMIT = 2000000000 |
The max amount possible to configure for a max loan of a company. | |
static const uint64_t | MAX_INFLATION = (1ull << (63 - 32)) - 1 |
Maximum inflation (including fractional part) without causing overflows in int64_t price computations. | |
static const int | MIN_PRICE_MODIFIER = -8 |
Maximum NewGRF price modifiers. | |
static const int | MAX_PRICE_MODIFIER = 16 |
static const int | INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1 |
static const uint | TUNNELBRIDGE_TRACKBIT_FACTOR = 4 |
Multiplier for how many regular track bits a tunnel/bridge counts. | |
static const uint | LEVELCROSSING_TRACKBIT_FACTOR = 2 |
Multiplier for how many regular track bits a level crossing counts. | |
static const uint | ROAD_DEPOT_TRACKBIT_FACTOR = 2 |
Multiplier for how many regular track bits a road depot counts. | |
static const uint | ROAD_STOP_TRACKBIT_FACTOR = 2 |
Multiplier for how many regular track bits a bay stop counts. | |
static const uint | LOCK_DEPOT_TILE_FACTOR = 2 |
Multiplier for how many regular tiles a lock counts. | |
Types related to the economy.
Definition in file economy_type.h.
using CargoPaymentID = PoolID<uint32_t, struct CargoPaymentIDTag, 0xFF000, 0xFFFFF> |
Definition at line 258 of file economy_type.h.
using Expenses = std::array<Money, EXPENSES_END> |
Data type for storage of Money for each ExpensesType category.
Definition at line 199 of file economy_type.h.
typedef OverflowSafeInt64 Money |
Definition at line 17 of file economy_type.h.
using PriceMultipliers = std::array<int8_t, PR_END> |
Definition at line 175 of file economy_type.h.
typedef Money Prices[PR_END] |
enum EconomyType : uint8_t |
Type of the game economy.
Definition at line 20 of file economy_type.h.
enum ExpensesType : uint8_t |
Types of expenses.
Definition at line 178 of file economy_type.h.
enum Price : uint8_t |
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.
Definition at line 95 of file economy_type.h.
enum PriceCategory : uint8_t |
Categories of a price bases.
Definition at line 204 of file economy_type.h.
enum ScoreID : uint8_t |
Score categories in the detailed performance rating.
Enumerator | |
---|---|
SCORE_TOTAL | This must always be the last entry. |
SCORE_END | How many scores are there.. |
Definition at line 61 of file economy_type.h.
|
static |
Default value of town_cargo_scale/industry_cargo_scale.
Definition at line 41 of file economy_type.h.
|
static |
The size of loan for a new company, in British Pounds!
Definition at line 223 of file economy_type.h.
Referenced by DoStartupNewCompany().
|
static |
Definition at line 244 of file economy_type.h.
|
static |
Multiplier for how many regular track bits a level crossing counts.
Definition at line 249 of file economy_type.h.
Referenced by CmdBuildRoad(), CmdBuildSingleRail(), CmdConvertRail(), CmdRemoveSingleRail(), and RemoveRoad().
|
static |
The "steps" in loan size, in British Pounds!
Definition at line 221 of file economy_type.h.
Referenced by CmdDecreaseLoan(), CmdIncreaseLoan(), CmdSetCompanyMaxLoan(), DoStartupNewCompany(), CompanyFinancesWindow::GetWidgetString(), and RecomputePrices().
|
static |
Multiplier for how many regular tiles a lock counts.
Definition at line 255 of file economy_type.h.
Referenced by CmdBuildShipDepot(), DoBuildLock(), and RemoveLock().
|
static |
Maximum allowed value of town_cargo_scale/industry_cargo_scale.
Above 340, callback-based industries would produce more than once per day, which GRFs do not expect. Towns use the same maximum to match.
Definition at line 39 of file economy_type.h.
|
static |
Maximum inflation (including fractional part) without causing overflows in int64_t 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. Note that NewGRF multipliers share the 16 fractional bits.
Definition at line 235 of file economy_type.h.
Referenced by AddInflation(), and AfterLoadGame().
|
static |
The max amount possible to configure for a max loan of a company.
Definition at line 225 of file economy_type.h.
Referenced by CmdSetCompanyMaxLoan().
|
static |
Definition at line 243 of file economy_type.h.
|
static |
Minimum allowed value of town_cargo_scale/industry_cargo_scale.
Below 13, callback-based industries would produce less than once per month. We round up to 15% because it's a nicer number. Towns use the same minimum to match, and because below this small towns often produce no cargo.
Definition at line 33 of file economy_type.h.
|
static |
Maximum NewGRF price modifiers.
Increasing base prices by factor 65536 should be enough.
Definition at line 242 of file economy_type.h.
Referenced by SetPriceBaseMultiplier().
|
static |
Multiplier for how many regular track bits a road depot counts.
Definition at line 251 of file economy_type.h.
Referenced by CmdBuildRoadDepot(), and CmdConvertRoad().
|
static |
Multiplier for how many regular track bits a bay stop counts.
Definition at line 253 of file economy_type.h.
Referenced by CmdBuildRoadStop(), CmdBuildRoadWaypoint(), CmdConvertRoad(), RemoveRoadStop(), and RemoveRoadWaypointStop().
|
staticconstexpr |
The max score that can be in the performance history.
The scores together of score_info is allowed to be more!
Definition at line 83 of file economy_type.h.
Referenced by PerformanceRatingDetailWindow::DrawWidget(), and UpdateCompanyRatingAndValue().
|
static |
Multiplier for how many regular track bits a tunnel/bridge counts.
Definition at line 247 of file economy_type.h.
Referenced by CmdBuildBridge(), CmdBuildRoad(), CmdBuildTunnel(), CmdConvertRail(), CmdConvertRoad(), DoClearBridge(), DoClearTunnel(), and RemoveRoad().