OpenTTD
|
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"
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, byte transit_days, CargoID cargo_type) |
uint | MoveGoodsToStation (CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations) |
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. | |
static bool | EconomyIsInRecession () |
Is the economy in recession? |
Variables | |
const ScoreInfo | _score_info [] |
Score info, values used for computing the detailed performance rating. | |
int | _score_part [MAX_COMPANIES][SCORE_END] |
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 723 of file economy.cpp.
References _cur_year, _settings_game, GameSettings::game_creation, Economy::infl_amount, Economy::infl_amount_pr, Economy::inflation_payment, Economy::inflation_prices, MAX_INFLATION, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR, and GameCreationSettings::starting_year.
Referenced by AfterLoadGame(), and CompaniesMonthlyLoop().
|
inlinestatic |
Is the economy in recession?
True
if economy is in recession, false
otherwise. Definition at line 49 of file economy_func.h.
References Economy::fluct.
Referenced by TileLoop_Town(), and IndustryBuildData::TryBuildNewIndustry().
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 1900 of file economy.cpp.
References SmallVector< T, S >::Begin(), SmallVector< T, S >::Clear(), SmallVector< T, S >::End(), Vehicle::load_unload_ticks, LoadUnloadVehicle(), TriggerIndustryProduction(), Vehicle::vehstatus, VS_CRASHED, and VS_STOPPED.
void PrepareUnload | ( | Vehicle * | front_v | ) |
Prepare the vehicle to be unloaded.
curr_station | the station where the consist is at the moment |
front_v | the vehicle to be unloaded |
Definition at line 1248 of file economy.cpp.
References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargo_payment_pool >::CanAllocateItem(), GoodsEntry::cargo, Vehicle::cargo_payment, ClrBit(), Vehicle::current_order, GoodsEntry::GES_ACCEPTANCE, SpecializedStation< Station, false >::Get(), Vehicle::GetNextStoppingStation(), Order::GetUnloadType(), Station::goods, HasBit(), Vehicle::last_station_visited, Vehicle::list, Vehicle::load_unload_ticks, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, Vehicle::Next(), Vehicle::orders, OUFB_NO_UNLOAD, SetBit(), GoodsEntry::status, BaseConsist::vehicle_flags, VF_CARGO_UNLOADING, and VF_LOADING_FINISHED.
Referenced by Vehicle::BeginLoading().
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 900 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 910 of file economy.cpp.
References Economy::industry_daily_change_counter, Economy::industry_daily_increment, MapLogX(), and MapLogY().
Referenced by Load_ECMY().
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 153 of file economy.cpp.
References Vehicle::age, CalculateCompanyValue(), Clamp(), ClampToI32(), CompanyEconomyEntry::company_value, CountBits(), CompanyProperties::current_loan, CompanyEconomyEntry::delivered_cargo, CompanyEconomyEntry::expenses, BaseStation::facilities, FOR_ALL_VEHICLES, CargoArray::GetCount(), CargoArray::GetSum(), CompanyEconomyEntry::income, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsCompanyBuildableVehicleType(), Vehicle::IsPrimaryVehicle(), CompanyProperties::location_of_HQ, max(), min(), CompanyProperties::money, ScoreInfo::needed, CompanyProperties::num_valid_stat_ent, CompanyProperties::old_economy, BaseStation::owner, Vehicle::owner, CompanyEconomyEntry::performance_history, Vehicle::profit_last_year, ScoreInfo::score, SCORE_END, SCORE_MAX, SCORE_TOTAL, SetWindowDirty(), BaseVehicle::type, UpdateCompanyHQ(), and WC_PERFORMANCE_DETAIL.
Referenced by CmdBuildObject(), and CompaniesGenStatistics().