1
0
Fork 0

(svn r21158) -Codechange: Assert boundary inside the loop rather than afterwards.

release/1.1
alberth 2010-11-13 10:11:47 +00:00
parent 30637a8340
commit 6c088543c1
1 changed files with 3 additions and 2 deletions

View File

@ -1994,11 +1994,12 @@ void GenerateIndustries()
for (uint i = 0; i < total_amount; i++) { for (uint i = 0; i < total_amount; i++) {
uint32 r = RandomRange(total_prob); uint32 r = RandomRange(total_prob);
IndustryType it = 0; IndustryType it = 0;
while (it < NUM_INDUSTRYTYPES && r >= industry_probs[it]) { while (r >= industry_probs[it]) {
r -= industry_probs[it]; r -= industry_probs[it];
it++; it++;
assert(it < NUM_INDUSTRYTYPES);
} }
assert(it < NUM_INDUSTRYTYPES && industry_probs[it] > 0); assert(industry_probs[it] > 0);
PlaceInitialIndustry(it, false); PlaceInitialIndustry(it, false);
} }
} }