From 2141ca23687b538ad5c537fc468b61bfc3b01bc2 Mon Sep 17 00:00:00 2001 From: frosch Date: Fri, 16 Apr 2010 21:21:54 +0000 Subject: (svn r19643) -Fix (r19120): Industry generation failed for large maps and lots of industry types. --- src/industry_cmd.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/industry_cmd.cpp') diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index f25ada8c3..2b1170aba 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1923,7 +1923,8 @@ void GenerateIndustries() /* Add the remaining industries according to their probabilities */ for (uint i = 0; i < total_amount; i++) { - uint32 r = RandomRange(total_prob); + /* RandomRange() can only deal with 16 bit, which is not enough here. */ + uint32 r = ((uint64)Random() * (uint64)total_prob) >> 32; IndustryType it = 0; while (it < NUM_INDUSTRYTYPES && r >= industry_probs[it]) { r -= industry_probs[it]; -- cgit v1.2.3-54-g00ecf