Changeset - r8154:7eaecf565a0f
[Not reviewed]
master
0 1 0
glx - 16 years ago 2007-12-28 16:21:29
glx@openttd.org
(svn r11716) -Fix [FS#1561]: don't put more than one Random() in function calls because parameter evaluation order is not guaranteed in the c++ standard (can lead to desyncs)
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/industry_cmd.cpp
Show inline comments
 
@@ -1612,7 +1612,11 @@ CommandCost CmdBuildIndustry(TileIndex t
 
			 * is nothing we can really do about that. */
 
			if (Random() <= indspec->prospecting_chance) {
 
				for (int i = 0; i < 5000; i++) {
 
					const Industry *ind = CreateNewIndustryHelper(RandomTile(), p1, flags, indspec, RandomRange(indspec->num_table));
 
					/* We should not have more than one Random() in a function call
 
					 * because parameter evaluation order is not guaranteed in the c++ standard
 
					 */
 
					tile = RandomTile();
 
					const Industry *ind = CreateNewIndustryHelper(tile, p1, flags, indspec, RandomRange(indspec->num_table));
 
					if (ind != NULL) {
 
						SetDParam(0, indspec->name);
 
						if (indspec->new_industry_text > STR_LAST_STRINGID) {
0 comments (0 inline, 0 general)