Changeset - r11642:a6a29052163f
[Not reviewed]
master
0 1 0
frosch - 15 years ago 2009-04-11 14:54:03
frosch@openttd.org
(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).
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1869,12 +1869,15 @@ static void MaybeNewIndustry(void)
 
			/* adds the result for this industry */
 
			cumulative_probs[num].ind = j;
 
			cumulative_probs[num++].prob = probability_max;
 
		}
 
	}
 

	
 
	/* 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++) {
 
		/* and choose the index of the industry that matches as close as possible this random type */
 
		if (cumulative_probs[j].prob >= rndtype) break;
 
	}
0 comments (0 inline, 0 general)