Fix undefined evaluation order when constructing random vectors
authorkwolekr <kwolekr@minetest.net>
Wed, 11 May 2016 07:47:45 +0000 (03:47 -0400)
committerkwolekr <kwolekr@minetest.net>
Sat, 28 May 2016 03:23:58 +0000 (23:23 -0400)
commitb1eb757e60c155707b8fc1b2497b632246819c7b
tree96e9b35b1e0f2b300f379a2703f659130cdab534
parent5b05f75a272ede582d7f86d8dbbbf7bc81e81970
Fix undefined evaluation order when constructing random vectors

MSVC and GCC evaluate parameters in right-to-left order, whereas Clang
evaluates in left-to-right order, and of course, an optimization could
leave the order of evaluation completely indeterminate.

This commit fixes all instances of the error by explicitly assigning the
results of expressions that use PseudoRandom::next() or range() to their
respective vector components.

The right-to-left evaluation behavior is preserved since Clang is much less
commonly used to compile Minetest than GCC and MSVC combined, and would
therefore cause the least harm.
src/cavegen.cpp
src/dungeongen.cpp