diff options
author | frosch <frosch@openttd.org> | 2009-11-24 13:12:34 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-11-24 13:12:34 +0000 |
commit | 912bce0b8cdeca9849dd257ca95566b009719d53 (patch) | |
tree | a2abd63725a9c6baffb22a8b3c39dc6b2f535dfb /src/economy.cpp | |
parent | b6b551533532d64f47e883d770b9633027ca7628 (diff) | |
download | openttd-912bce0b8cdeca9849dd257ca95566b009719d53.tar.xz |
(svn r18266) -Codechange: Add a function to compute prices from price base and cost factor and use it consistently for vehicle purchase, running cost, and refit cost.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 1d934bd7c..b8f4f6197 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -788,15 +788,25 @@ void InitializeEconomy() } /** - * Determine a certain base price with range checking - * @param index Price of interest - * @return Base price, or zero if out of range + * Determine a certain price + * @param index Price base + * @param cost_factor Price factor + * @param shift Extra bit shifting after the computation + * @return Price */ -Money GetPriceByIndex(Price index) +Money GetPrice(Price index, uint cost_factor, int shift) { if (index >= PR_END) return 0; - return _price[index]; + Money cost = _price[index] * cost_factor; + + if (shift >= 0) { + cost <<= shift; + } else { + cost >>= -shift; + } + + return cost; } Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type) |