|
OpenTTD Source 20251104-master-g3befbdd52f
|
Functions related to the economy. More...
#include "economy_type.h"#include "station_type.h"#include "cargo_type.h"#include "vehicle_type.h"#include "company_type.h"#include "settings_type.h"#include "source_type.h"#include "core/random_func.hpp"Go to the source code of this file.
Functions | |
| void | ResetPriceBaseMultipliers () |
| Reset changes to the price base multipliers. | |
| void | SetPriceBaseMultiplier (Price price, int factor) |
| Change a price base by the given factor. | |
| int | UpdateCompanyRatingAndValue (Company *c, bool update) |
| if update is set to true, the economy is updated with this score (also the house is updated, should only be true in the on-tick event) | |
| void | StartupIndustryDailyChanges (bool init_counter) |
| Initialize the variables that will maintain the daily industry change system. | |
| Money | GetTransportedGoodsIncome (uint num_pieces, uint dist, uint16_t transit_periods, CargoType cargo_type) |
| uint | MoveGoodsToStation (CargoType cargo, uint amount, Source source, const StationList &all_stations, Owner exclusivity=INVALID_OWNER) |
| void | PrepareUnload (Vehicle *front_v) |
| Prepare the vehicle to be unloaded. | |
| void | LoadUnloadStation (Station *st) |
| Load/unload the vehicles in this station according to the order they entered. | |
| Money | GetPrice (Price index, uint cost_factor, const struct GRFFile *grf_file, int shift=0) |
| void | InitializeEconomy () |
| Resets economy to initial values. | |
| void | RecomputePrices () |
| Computes all prices, payments and maximum loan. | |
| bool | AddInflation (bool check_year=true) |
| Add monthly inflation. | |
| bool | EconomyIsInRecession () |
| Is the economy in recession? | |
| static uint | ScaleByInverseCargoScale (uint num, bool town) |
| Scale a number by the inverse of the cargo scale setting, e.g. | |
| uint | ScaleByCargoScale (uint num, bool town) |
| Scale a number by the cargo scale setting. | |
Variables | |
| const ScoreInfo | _score_info [] |
| Score info, values used for computing the detailed performance rating. | |
| TypedIndexContainer< std::array< std::array< int64_t, SCORE_END >, MAX_COMPANIES >, CompanyID > | _score_part |
| Economy | _economy |
| Prices | _price |
Functions related to the economy.
Definition in file economy_func.h.
| bool AddInflation | ( | bool | check_year | ) |
Add monthly inflation.
| check_year | Shall the inflation get stopped after 170 years? |
Definition at line 704 of file economy.cpp.
References Economy::infl_amount, Economy::infl_amount_pr, Economy::inflation_payment, Economy::inflation_prices, MAX_INFLATION, and TimerGameConst< struct Calendar >::ORIGINAL_MAX_YEAR.
Referenced by AfterLoadGame().
|
inline |
Is the economy in recession?
True if economy is in recession, false otherwise. Definition at line 50 of file economy_func.h.
References Economy::fluct.
Referenced by TownGenerateCargo(), TransportIndustryGoods(), and IndustryBuildData::TryBuildNewIndustry().
| Money GetTransportedGoodsIncome | ( | uint | num_pieces, |
| uint | dist, | ||
| uint16_t | transit_periods, | ||
| CargoType | cargo_type | ||
| ) |
Definition at line 965 of file economy.cpp.
| void InitializeEconomy | ( | ) |
Resets economy to initial values.
Definition at line 934 of file economy.cpp.
References ClearCargoDeliveryMonitoring(), ClearCargoPickupMonitoring(), Economy::inflation_payment, and Economy::inflation_prices.
| void LoadUnloadStation | ( | Station * | st | ) |
Load/unload the vehicles in this station according to the order they entered.
| st | the station to do the loading/unloading for |
Definition at line 1929 of file economy.cpp.
References _cargo_delivery_destinations, LoadUnloadVehicle(), and TriggerIndustryProduction().
| uint MoveGoodsToStation | ( | CargoType | cargo, |
| uint | amount, | ||
| Source | source, | ||
| const StationList & | all_stations, | ||
| Owner | exclusivity = INVALID_OWNER |
||
| ) |
Definition at line 4529 of file station_cmd.cpp.
| void PrepareUnload | ( | Vehicle * | front_v | ) |
Prepare the vehicle to be unloaded.
| front_v | the vehicle to be unloaded |
Definition at line 1255 of file economy.cpp.
References GoodsEntry::Acceptance, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_cargo_payment_pool >::CanAllocateItem(), Vehicle::cargo_payment, CargoUnloading, Vehicle::current_order, SpecializedStation< Station, false >::Get(), Vehicle::GetNextStoppingStation(), Order::GetUnloadType(), Station::goods, Vehicle::last_station_visited, Vehicle::load_unload_ticks, LoadingFinished, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::MAX_SIZE, Vehicle::Next(), Vehicle::orders, OUFB_NO_UNLOAD, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Reset(), GoodsEntry::status, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and BaseConsist::vehicle_flags.
Referenced by Vehicle::BeginLoading().
| void RecomputePrices | ( | ) |
Computes all prices, payments and maximum loan.
Definition at line 742 of file economy.cpp.
References _settings_game, Clamp(), DifficultySettings::construction_cost, GameSettings::difficulty, Economy::inflation_payment, Economy::inflation_prices, InvalidateWindowData(), CargoSpec::Iterate(), LOAN_INTERVAL, Economy::max_loan, DifficultySettings::max_loan, PCAT_CONSTRUCTION, PCAT_RUNNING, SetWindowClassesDirty(), PriceBaseSpec::start_price, DifficultySettings::vehicle_costs, WC_BUILD_VEHICLE, WC_COMPANY_INFRASTRUCTURE, WC_PAYMENT_RATES, WC_REPLACE_VEHICLE, and WC_VEHICLE_DETAILS.
Referenced by InitializeWindowsAndCaches(), and ReloadNewGRFData().
| void ResetPriceBaseMultipliers | ( | ) |
Reset changes to the price base multipliers.
Definition at line 870 of file economy.cpp.
Referenced by ResetNewGRFData().
|
inline |
Scale a number by the cargo scale setting.
| num | The number to scale. |
| town | Are we scaling town production, or industry production? |
Definition at line 78 of file economy_func.h.
References _settings_game, Chance16(), GameSettings::economy, EconomySettings::industry_cargo_scale, ScaleByInverseCargoScale(), and EconomySettings::town_cargo_scale.
Referenced by ChopLumberMillTrees(), DoCreateNewIndustry(), ProduceIndustryGoodsHelper(), TownGenerateCargo(), and UpdateTownMaxPass().
|
static |
Scale a number by the inverse of the cargo scale setting, e.g.
a scale of 25% multiplies the number by 4.
| num | The number to scale. |
| town | Are we scaling town production, or industry production? |
Definition at line 61 of file economy_func.h.
References _settings_game, GameSettings::economy, EconomySettings::industry_cargo_scale, and EconomySettings::town_cargo_scale.
Referenced by ScaleByCargoScale().
| void SetPriceBaseMultiplier | ( | Price | price, |
| int | factor | ||
| ) |
Change a price base by the given factor.
The price base is altered by factors of two. NewBaseCost = OldBaseCost * 2^n
| price | Index of price base to change. |
| factor | Amount to change by. |
Definition at line 882 of file economy.cpp.
References Clamp(), and MIN_PRICE_MODIFIER.
Referenced by FinalisePriceBaseMultipliers().
| void StartupIndustryDailyChanges | ( | bool | init_counter | ) |
Initialize the variables that will maintain the daily industry change system.
| init_counter | specifies if the counter is required to be initialized |
Definition at line 892 of file economy.cpp.
References Economy::industry_daily_change_counter, Economy::industry_daily_increment, Map::LogX(), and Map::LogY().
Referenced by ECMYChunkHandler::Load().
| int UpdateCompanyRatingAndValue | ( | Company * | c, |
| bool | update | ||
| ) |
if update is set to true, the economy is updated with this score (also the house is updated, should only be true in the on-tick event)
| update | the economy with calculated score |
| c | company been evaluated |
Definition at line 202 of file economy.cpp.
References _score_info, CalculateCompanyValue(), CompanyProperties::current_loan, Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem< Tpool >::index, IsCompanyBuildableVehicleType(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::Iterate(), CompanyProperties::location_of_HQ, CompanyProperties::money, ScoreInfo::needed, CompanyProperties::num_valid_stat_ent, CompanyProperties::old_economy, ScoreInfo::score, SCORE_END, SCORE_MAX, SCORE_TOTAL, SetWindowDirty(), UpdateCompanyHQ(), VEHICLE_PROFIT_MIN_AGE, and WC_PERFORMANCE_DETAIL.
Referenced by CmdBuildObject(), and CompaniesGenStatistics().
|
extern |
Definition at line 105 of file economy.cpp.
|
extern |
Definition at line 106 of file economy.cpp.
|
extern |
Score info, values used for computing the detailed performance rating.
Definition at line 91 of file economy.cpp.
Referenced by PerformanceRatingDetailWindow::DrawWidget(), and UpdateCompanyRatingAndValue().
|
extern |
Definition at line 104 of file economy.cpp.