diff options
author | frosch <frosch@openttd.org> | 2009-11-07 22:47:54 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-11-07 22:47:54 +0000 |
commit | ba1fc280e3b0c13baedc2ef54dabb2deec41c818 (patch) | |
tree | f8f51f5d18355d9205052bad2e90e068e9bfacb6 /src/economy.cpp | |
parent | 7984d90c40f4d55cad9f34d0acac27beb701a63a (diff) | |
download | openttd-ba1fc280e3b0c13baedc2ef54dabb2deec41c818.tar.xz |
(svn r18005) -Codechange: Convert the Prices struct into an array and an enum.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r-- | src/economy.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 78521011b..2e70af61f 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -123,7 +123,7 @@ Money CalculateCompanyValue(const Company *c) if (st->owner == owner) num += CountBits((byte)st->facilities); } - value += num * _price.station_value * 25; + value += num * _price[PR_STATION_VALUE] * 25; Vehicle *v; FOR_ALL_VEHICLES(v) { @@ -558,7 +558,7 @@ static void CompaniesGenStatistics() FOR_ALL_STATIONS(st) { _current_company = st->owner; - CommandCost cost(EXPENSES_PROPERTY, _price.station_value >> 1); + CommandCost cost(EXPENSES_PROPERTY, _price[PR_STATION_VALUE] >> 1); SubtractMoneyFromCompany(cost); } @@ -698,7 +698,7 @@ static void CompaniesPayInterest() SubtractMoneyFromCompany(CommandCost(EXPENSES_LOAN_INT, up_to_this_month - up_to_previous_month)); - SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price.station_value >> 2)); + SubtractMoneyFromCompany(CommandCost(EXPENSES_OTHER, _price[PR_STATION_VALUE] >> 2)); } } @@ -793,11 +793,16 @@ void InitializeEconomy() _economy.inflation_prices = _economy.inflation_payment = 1 << 16; } -Money GetPriceByIndex(uint8 index) +/** + * Determine a certain base price with range checking + * @param index Price of interest + * @return Base price, or zero if out of range + */ +Money GetPriceByIndex(Price index) { - if (index > NUM_PRICES) return 0; + if (index >= NUM_PRICES) return 0; - return ((Money*)&_price)[index]; + return _price[index]; } Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, CargoID cargo_type) |