summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-04-11 14:54:03 +0000
committerfrosch <frosch@openttd.org>2009-04-11 14:54:03 +0000
commit1b85c10a5b2b4f427ec097c45ea7b701340e81df (patch)
tree9e57c9c5bff609c6fd38488c02d47b5bc4426d20 /src
parentbe7215497c6da65e0754bdfd2f03b67f80df7956 (diff)
downloadopenttd-1b85c10a5b2b4f427ec097c45ea7b701340e81df.tar.xz
(svn r16027) -Fix (r9555): Usage of uninitialised memory when trying to build a random new industry, but there are no industrytypes to choose from (i.e. all appearance probabilities are zero).
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 88cdf7a09..768584d33 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1872,6 +1872,9 @@ static void MaybeNewIndustry(void)
}
}
+ /* Abort if there is no industry buildable */
+ if (probability_max == 0) return;
+
/* Find a random type, with maximum being what has been evaluate above*/
rndtype = RandomRange(probability_max);
for (j = 0; j < NUM_INDUSTRYTYPES; j++) {