diff options
author | frosch <frosch@openttd.org> | 2009-09-06 18:53:57 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-09-06 18:53:57 +0000 |
commit | 438a429549486f08919748cee0f5346ccacf760b (patch) | |
tree | 3858342b95e237dcb97d35476646e0d0f9d23aeb /src/economy_type.h | |
parent | 2ce1a608a8ff5eb4cd6582adac990b2004ce1103 (diff) | |
download | openttd-438a429549486f08919748cee0f5346ccacf760b.tar.xz |
(svn r17433) -Codechange: Store cumulated inflation in savegame and compute all prices from that instead of storing all prices separately.
Note: Savegame conversion computes the inflation from max loan. Prices from modified savegames will get lost. TTO savegames will also behave slightly different.
-Change: NewGRF price modifiers now take effect everytime when loading NewGRFs instead of once on gamestart.
Diffstat (limited to 'src/economy_type.h')
-rw-r--r-- | src/economy_type.h | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/economy_type.h b/src/economy_type.h index 68e8c8b49..c66da86bc 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -19,15 +19,19 @@ typedef OverflowSafeInt64 Money; struct Economy { - Money max_loan; ///< Maximum possible loan - Money max_loan_unround; ///< Economy fluctuation status - uint16 max_loan_unround_fract; ///< Fraction of the unrounded max loan - int16 fluct; + Money max_loan; ///< NOSAVE: Maximum possible loan + int16 fluct; ///< Economy fluctuation status byte interest_rate; ///< Interest byte infl_amount; ///< inflation amount byte infl_amount_pr; ///< inflation rate for payment rates uint32 industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily uint32 industry_daily_increment; ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE + uint64 inflation_prices; ///< Cumulated inflation of prices since game start; 16 bit fractional part + uint64 inflation_payment; ///< Cumulated inflation of cargo paypent since game start; 16 bit fractional part + + /* Old stuff for savegame conversion only */ + Money old_max_loan_unround; ///< Old: Unrounded max loan + uint16 old_max_loan_unround_fract; ///< Old: Fraction of the unrounded max loan }; enum ScoreID { @@ -149,6 +153,23 @@ struct PriceBaseSpec { /** The "steps" in loan size, in British Pounds! */ static const int LOAN_INTERVAL = 10000; +/** + * Maximum inflation (including fractional part) without causing overflows in int64 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. + * @see MAX_PRICE_MODIFIER + */ +static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1; + +/** + * Maximum NewGRF price modifier including the shift offset of 8 bits. + * Increasing base prices by factor 65536 should be enough. + * @see MAX_INFLATION + */ +static const int MAX_PRICE_MODIFIER = 16 + 8; + struct CargoPayment; typedef uint32 CargoPaymentID; |