Mercurial > hg > openttd
changeset 8154:5143b10911a1 draft
(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)
author | glx <glx@openttd.org> |
---|---|
date | Fri, 28 Dec 2007 16:21:29 +0000 |
parents | a18e5c54295e |
children | 2ca155c0aef1 |
files | src/industry_cmd.cpp |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -1612,7 +1612,11 @@ * 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) {