2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
8 /** @file economy_func.h Functions related to the economy. */
10 #ifndef ECONOMY_FUNC_H
11 #define ECONOMY_FUNC_H
13 #include "economy_type.h"
14 #include "station_type.h"
15 #include "cargo_type.h"
16 #include "vehicle_type.h"
17 #include "company_type.h"
19 void ResetPriceBaseMultipliers();
20 void SetPriceBaseMultiplier(Price price
, int factor
);
22 extern const ScoreInfo _score_info
[];
23 extern int64_t _score_part
[MAX_COMPANIES
][SCORE_END
];
24 extern Economy _economy
;
25 /* Prices and also the fractional part. */
28 extern CargoScaler _town_cargo_scaler
;
29 extern CargoScaler _industry_cargo_scaler
;
30 extern CargoScaler _industry_inverse_cargo_scaler
;
32 int UpdateCompanyRatingAndValue(Company
*c
, bool update
);
33 void StartupIndustryDailyChanges(bool init_counter
);
35 Money
GetTransportedGoodsIncome(uint num_pieces
, uint dist
, uint16_t transit_periods
, CargoID cargo_type
);
36 uint
MoveGoodsToStation(CargoID type
, uint amount
, SourceType source_type
, SourceID source_id
, const StationList
&all_stations
, Owner exclusivity
= INVALID_OWNER
);
38 void PrepareUnload(Vehicle
*front_v
);
39 void LoadUnloadStation(Station
*st
);
41 Money
GetPrice(Price index
, uint cost_factor
, const struct GRFFile
*grf_file
, int shift
= 0);
43 void InitializeEconomy();
44 void RecomputePrices();
45 bool AddInflation(bool check_year
= true);
48 * Is the economy in recession?
49 * @return \c True if economy is in recession, \c false otherwise.
51 inline bool EconomyIsInRecession()
53 return _economy
.fluct
<= 0;
56 uint
ScaleQuantity(uint amount
, int scale_factor
, bool allow_trunc
= false);
57 uint
ScaleQuantity(uint amount
, int cf
, int fine
, bool allow_trunc
= false);
59 int PercentageToScaleQuantityFactor(uint percentage
);
61 void UpdateCargoScalers();
63 void PostAcquireCompany(Company
*c
);
65 #endif /* ECONOMY_FUNC_H */