summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-26 21:11:17 +0000
committerrubidium <rubidium@openttd.org>2007-06-26 21:11:17 +0000
commit89a4ee256ef6ce4ca9a54984753bb13ce5db45a8 (patch)
tree0ba1c2109b78346919482403e5e9ed5dbfe793fa /src
parent875a3760392a60e5965372cbfffc51f903e79987 (diff)
downloadopenttd-89a4ee256ef6ce4ca9a54984753bb13ce5db45a8.tar.xz
(svn r10347) -Fix [FS#948]: industries with a very low production could never recover when using smooth economy.
-Fix: in smooth economy producing industries could not close, whereas they could close in non-smooth economy. -Fix: in smooth economy the "do not increase production" flag of industries was ignored.
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index c7a6ff106..21c08ee1a 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1638,17 +1638,17 @@ static void ExtChangeIndustryProduction(Industry *i)
int mag;
new_prod = old_prod = i->production_rate[j];
- if (CHANCE16I(20, 1024, r))
- new_prod -= ((RandomRange(50) + 10) * old_prod) >> 8;
- if (CHANCE16I(20 + (i->last_month_pct_transported[j] * 20 >> 8), 1024, r >> 16))
- /* old_prod gets stuck at '4' because 60 * 4 / 256 < 1, so in that case
- * increase the odds a bit for increasing, so at least it can escape
- * the production of '4' at some time in the future (instead of being
- * stuck there for ever). */
- new_prod += ((RandomRange(old_prod == 4 ? 55 : 50) + 10) * old_prod) >> 8;
-
- new_prod = clamp(new_prod, 4, 255);
- if (new_prod == old_prod) {
+
+ if (CHANCE16I(20, 1024, r)) new_prod -= max(((RandomRange(50) + 10) * old_prod) >> 8, 1U);
+ /* Chance of increasing becomes better when more is transported */
+ if (CHANCE16I(20 + (i->last_month_pct_transported[j] * 20 >> 8), 1024, r >> 16) &&
+ (indspec->behaviour & INDUSTRYBEH_DONT_INCR_PROD) == 0) {
+ new_prod += max(((RandomRange(50) + 10) * old_prod) >> 8, 1U);
+ }
+
+ new_prod = clamp(new_prod, 1, 255);
+ /* Do not stop closing the industry when it has the lowest possible production rate */
+ if (new_prod == old_prod && && old_prod > 1)) {
closeit = false;
continue;
}
@@ -1656,8 +1656,8 @@ static void ExtChangeIndustryProduction(Industry *i)
percent = new_prod * 100 / old_prod - 100;
i->production_rate[j] = new_prod;
- if (new_prod >= indspec->production_rate[j] / 4)
- closeit = false;
+ /* Close the industry when it has the lowest possible production rate */
+ if (new_prod > 1) closeit = false;
mag = abs(percent);
if (mag >= 10) {