summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-11-13 10:11:47 +0000
committeralberth <alberth@openttd.org>2010-11-13 10:11:47 +0000
commit6c088543c1407e4ef0531babe6b870c676528946 (patch)
tree0a6e53cf292c3f848645db1db3b0e1fc58969b90 /src
parent30637a8340844abce2aab469295b4160d1f2d532 (diff)
downloadopenttd-6c088543c1407e4ef0531babe6b870c676528946.tar.xz
(svn r21158) -Codechange: Assert boundary inside the loop rather than afterwards.
Diffstat (limited to 'src')
-rw-r--r--src/industry_cmd.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index a56ed02b5..aff016ae6 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1994,11 +1994,12 @@ void GenerateIndustries()
for (uint i = 0; i < total_amount; i++) {
uint32 r = RandomRange(total_prob);
IndustryType it = 0;
- while (it < NUM_INDUSTRYTYPES && r >= industry_probs[it]) {
+ while (r >= industry_probs[it]) {
r -= industry_probs[it];
it++;
+ assert(it < NUM_INDUSTRYTYPES);
}
- assert(it < NUM_INDUSTRYTYPES && industry_probs[it] > 0);
+ assert(industry_probs[it] > 0);
PlaceInitialIndustry(it, false);
}
}