summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-11-24 13:12:34 +0000
committerfrosch <frosch@openttd.org>2009-11-24 13:12:34 +0000
commit912bce0b8cdeca9849dd257ca95566b009719d53 (patch)
treea2abd63725a9c6baffb22a8b3c39dc6b2f535dfb /src/economy.cpp
parentb6b551533532d64f47e883d770b9633027ca7628 (diff)
downloadopenttd-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.cpp20
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)