summaryrefslogtreecommitdiff
path: root/economy.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2005-10-12 07:27:56 +0000
committerpeter1138 <peter1138@openttd.org>2005-10-12 07:27:56 +0000
commitc78e87d4da98b74784d08da6c348da06d8740c83 (patch)
treef0e985934fd7c2e532353937b6127d5499a8b8f6 /economy.c
parentd678a124459aacd4cf99ac0d171f8c3ecd4aa7af (diff)
downloadopenttd-c78e87d4da98b74784d08da6c348da06d8740c83.tar.xz
(svn r3032) -NewGRF, Feature: Add support for changing base prices.
Diffstat (limited to 'economy.c')
-rw-r--r--economy.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/economy.c b/economy.c
index 8ec569d00..fd19a592c 100644
--- a/economy.c
+++ b/economy.c
@@ -768,6 +768,33 @@ static const int32 _price_base[NUM_PRICES] = {
1000000, // build_industry
};
+static byte price_base_multiplier[NUM_PRICES];
+
+/**
+ * Reset changes to the price base multipliers.
+ */
+void ResetPriceBaseMultipliers(void)
+{
+ int i;
+
+ // 8 means no multiplier.
+ for (i = 0; i < NUM_PRICES; i++)
+ price_base_multiplier[i] = 8;
+}
+
+/**
+ * Change a price base by the given factor.
+ * The price base is altered by factors of two, with an offset of 8.
+ * NewBaseCost = OldBaseCost * 2^(n-8)
+ * @param price Index of price base to change.
+ * @param factor Amount to change by.
+ */
+void SetPriceBaseMultiplier(int price, byte factor)
+{
+ if (price < NUM_PRICES)
+ price_base_multiplier[price] = factor;
+}
+
void StartupEconomy(void)
{
int i;
@@ -784,6 +811,11 @@ void StartupEconomy(void)
price = price * 9 >> 3;
}
}
+ if (price_base_multiplier[i] > 8) {
+ price <<= price_base_multiplier[i] - 8;
+ } else {
+ price >>= 8 - price_base_multiplier[i];
+ }
((int32*)&_price)[i] = price;
_price_frac[i] = 0;
}