summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2007-12-28 16:21:29 +0000
committerglx <glx@openttd.org>2007-12-28 16:21:29 +0000
commitc87f20ff37e710575246ee31902c9a7b2235e111 (patch)
tree533d55bb1e063ffba7044e67f3d641115e698e05
parent8e1f21e29b9f0fec72e24f34f7baa3ad14945d5f (diff)
downloadopenttd-c87f20ff37e710575246ee31902c9a7b2235e111.tar.xz
(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)
-rw-r--r--src/industry_cmd.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index 9fb1112a8..d38beb3fd 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -1612,7 +1612,11 @@ CommandCost CmdBuildIndustry(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* 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) {