summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2012-10-01 19:31:55 +0000
committerfrosch <frosch@openttd.org>2012-10-01 19:31:55 +0000
commit0ba2ed7676b954511fd2c17f450ae1618b1a677c (patch)
treeb4388f02c5ff87b9f2e14963abb51e488bf5cf30
parent712260202660ffaf19342b43c0b34cd2e2093434 (diff)
downloadopenttd-0ba2ed7676b954511fd2c17f450ae1618b1a677c.tar.xz
(svn r24565) -Fix: Stop both price and payment inflation if either of them has reached MAX_INFLATION.
-rw-r--r--src/economy.cpp9
-rw-r--r--src/economy_func.h2
-rw-r--r--src/saveload/afterload.cpp2
3 files changed, 9 insertions, 4 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index 5026e0127..6ef7636aa 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -651,8 +651,9 @@ static void CompaniesGenStatistics()
/**
* Add monthly inflation
* @param check_year Shall the inflation get stopped after 170 years?
+ * @return true if inflation is maxed and nothing was changed
*/
-void AddInflation(bool check_year)
+bool AddInflation(bool check_year)
{
/* The cargo payment inflation differs from the normal inflation, so the
* relative amount of money you make with a transport decreases slowly over
@@ -669,7 +670,9 @@ void AddInflation(bool check_year)
* inflation doesn't add anything after that either; it even makes playing
* it impossible due to the diverging cost and income rates.
*/
- if (check_year && (_cur_year - _settings_game.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return;
+ if (check_year && (_cur_year - _settings_game.game_creation.starting_year) >= (ORIGINAL_MAX_YEAR - ORIGINAL_BASE_YEAR)) return true;
+
+ if (_economy.inflation_prices == MAX_INFLATION || _economy.inflation_payment == MAX_INFLATION) return true;
/* Approximation for (100 + infl_amount)% ** (1 / 12) - 100%
* scaled by 65536
@@ -681,6 +684,8 @@ void AddInflation(bool check_year)
if (_economy.inflation_prices > MAX_INFLATION) _economy.inflation_prices = MAX_INFLATION;
if (_economy.inflation_payment > MAX_INFLATION) _economy.inflation_payment = MAX_INFLATION;
+
+ return false;
}
/**
diff --git a/src/economy_func.h b/src/economy_func.h
index e9c9c170d..111ce85a2 100644
--- a/src/economy_func.h
+++ b/src/economy_func.h
@@ -40,7 +40,7 @@ Money GetPrice(Price index, uint cost_factor, const struct GRFFile *grf_file, in
void InitializeEconomy();
void RecomputePrices();
-void AddInflation(bool check_year = true);
+bool AddInflation(bool check_year = true);
/**
* Is the economy in recession?
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index d97aa2aaf..bc27288e2 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -2171,7 +2171,7 @@ bool AfterLoadGame()
/* Simulate the inflation, so we also get the payment inflation */
while (_economy.inflation_prices < aimed_inflation) {
- AddInflation(false);
+ if (AddInflation(false)) break;
}
}