From 6c088543c1407e4ef0531babe6b870c676528946 Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 13 Nov 2010 10:11:47 +0000 Subject: (svn r21158) -Codechange: Assert boundary inside the loop rather than afterwards. --- src/industry_cmd.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/industry_cmd.cpp') 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); } } -- cgit v1.2.3-54-g00ecf