summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-11-08 12:23:02 +0000
committerfrosch <frosch@openttd.org>2009-11-08 12:23:02 +0000
commit3f5e42b04a552b6c1bf06b2bbd36e8bf9c7376bb (patch)
treec5c07837a657cef27ac79e3caa35248c665a2d1d /src/economy.cpp
parente781929d7f7d472bd400cc0d00407c97f469f841 (diff)
downloadopenttd-3f5e42b04a552b6c1bf06b2bbd36e8bf9c7376bb.tar.xz
(svn r18008) -Codechange: Rename NUM_PRICES to PR_END, and use the Price enum some more.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 2e70af61f..57d052bea 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -109,7 +109,7 @@ int _score_part[MAX_COMPANIES][SCORE_END];
Economy _economy;
Prices _price;
Money _additional_cash_required;
-static byte _price_base_multiplier[NUM_PRICES];
+static byte _price_base_multiplier[PR_END];
Money CalculateCompanyValue(const Company *c)
{
@@ -625,10 +625,8 @@ void RecomputePrices()
/* Setup maximum loan */
_economy.max_loan = (_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / 50000 * 50000;
- assert_compile(sizeof(_price) == NUM_PRICES * sizeof(Money));
-
/* Setup price bases */
- for (uint i = 0; i < NUM_PRICES; i++) {
+ for (Price i = PR_BEGIN; i < PR_END; i++) {
Money price = _price_base_specs[i].start_price;
/* Apply difficulty settings */
@@ -662,7 +660,7 @@ void RecomputePrices()
}
/* Store value */
- ((Money *)&_price)[i] = price;
+ _price[i] = price;
}
/* Setup cargo payment */
@@ -730,10 +728,8 @@ static void HandleEconomyFluctuations()
*/
void ResetPriceBaseMultipliers()
{
- uint i;
-
/* 8 means no multiplier. */
- for (i = 0; i < NUM_PRICES; i++)
+ for (Price i = PR_BEGIN; i < PR_END; i++)
_price_base_multiplier[i] = 8;
}
@@ -744,9 +740,9 @@ void ResetPriceBaseMultipliers()
* @param price Index of price base to change.
* @param factor Amount to change by.
*/
-void SetPriceBaseMultiplier(uint price, byte factor)
+void SetPriceBaseMultiplier(Price price, byte factor)
{
- assert(price < NUM_PRICES);
+ assert(price < PR_END);
_price_base_multiplier[price] = min(factor, MAX_PRICE_MODIFIER);
}
@@ -800,7 +796,7 @@ void InitializeEconomy()
*/
Money GetPriceByIndex(Price index)
{
- if (index >= NUM_PRICES) return 0;
+ if (index >= PR_END) return 0;
return _price[index];
}