OpenTTD Source: src/economy_func.h File Reference

OpenTTD Source 14.1

Functions | Variables
economy_func.h File Reference
`#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 "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. More...
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) More...
void | StartupIndustryDailyChanges (bool init_counter)
| Initialize the variables that will maintain the daily industry change system. More...
Money | GetTransportedGoodsIncome (uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type)
uint | MoveGoodsToStation (CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity=INVALID_OWNER)
void | PrepareUnload (Vehicle *front_v)
| Prepare the vehicle to be unloaded. More...
void | LoadUnloadStation (Station *st)
| Load/unload the vehicles in this station according to the order they entered. More...
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. More...
bool | EconomyIsInRecession ()
| Is the economy in recession? More...
static uint | ScaleByInverseCargoScale (uint num, bool town)
| Scale a number by the inverse of the cargo scale setting, e.g. More...
uint | ScaleByCargoScale (uint num, bool town)
| Scale a number by the cargo scale setting. More...

## Variables
const ScoreInfo | _score_info []
| Score info, values used for computing the detailed performance rating.
int64_t | _score_part [MAX_COMPANIES][SCORE_END]
Economy | _economy
Prices | _price

## Detailed Description

Functions related to the economy.

Definition in file economy_func.h.

## Function Documentation

## ◆ AddInflation()

bool AddInflation | ( | bool | check_year | ) |

Add monthly inflation.

Parameters

  check_year | Shall the inflation get stopped after 170 years?

Returns
  true if inflation is maxed and nothing was changed

Definition at line 720 of file economy.cpp.

References TimerGameConst< struct Calendar >::ORIGINAL_MAX_YEAR.

## ◆ EconomyIsInRecession()

bool EconomyIsInRecession | ( |  | ) |
| inline

Is the economy in recession?

Returns
  `True` if economy is in recession, `false` otherwise.

Definition at line 49 of file economy_func.h.

Referenced by TownGenerateCargo(), TransportIndustryGoods(), and IndustryBuildData::TryBuildNewIndustry().

## ◆ LoadUnloadStation()

void LoadUnloadStation | ( | Station * | st | ) |

Load/unload the vehicles in this station according to the order they entered.

Parameters

  st | the station to do the loading/unloading for

Definition at line 1949 of file economy.cpp.

References _cargo_delivery_destinations, Vehicle::load_unload_ticks, LoadUnloadVehicle(), TriggerIndustryProduction(), Vehicle::vehstatus, VS_CRASHED, and VS_STOPPED.

## ◆ PrepareUnload()

void PrepareUnload | ( | Vehicle * | front_v | ) |

Prepare the vehicle to be unloaded.

Parameters

  front_v | the vehicle to be unloaded

Definition at line 1275 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::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.

## ◆ ScaleByCargoScale()

uint ScaleByCargoScale | ( | uint | num,
|  | bool | town
| ) |  |
| inline

Scale a number by the cargo scale setting.

Parameters

  num | The number to scale.
  town | Are we scaling town production, or industry production?

Returns
  The number scaled by the current cargo scale setting. May be 0.

Definition at line 77 of file economy_func.h.

Referenced by ChopLumberMillTrees(), TownGenerateCargo(), and UpdateTownMaxPass().

## ◆ ScaleByInverseCargoScale()

static uint ScaleByInverseCargoScale | ( | uint | num,
|  | bool | town
| ) |  |
| static

Scale a number by the inverse of the cargo scale setting, e.g.

a scale of 25% multiplies the number by 4.

Parameters

  num | The number to scale.
  town | Are we scaling town production, or industry production?

Returns
  The number scaled by the inverse of the cargo scale setting, minimum of 1.

Definition at line 60 of file economy_func.h.

## ◆ SetPriceBaseMultiplier()

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

Parameters

  price | Index of price base to change.
  factor | Amount to change by.

Definition at line 898 of file economy.cpp.

## ◆ StartupIndustryDailyChanges()

void StartupIndustryDailyChanges | ( | bool | init_counter | ) |

Initialize the variables that will maintain the daily industry change system.

Parameters

  init_counter | specifies if the counter is required to be initialized

Definition at line 908 of file economy.cpp.

References Map::LogX(), and Map::LogY().

## ◆ UpdateCompanyRatingAndValue()

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)

Parameters

  update | the economy with calculated score
  c | company been evaluated

Returns
  actual score of this company

Definition at line 201 of file economy.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index.