aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_settings.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-08-11 19:07:56 +0200
committerest31 <MTest31@outlook.com>2015-08-12 11:36:22 +0200
commit738fbc66d096575bb9a1694056ce2d627a70c03d (patch)
treebdc56e4dc74cac201154176d02e32d57c6ab6958 /src/script/lua_api/l_settings.cpp
parentf0b325254fdf76f988f0d2ae83a8aa6825b6d60e (diff)
downloadminetest-738fbc66d096575bb9a1694056ce2d627a70c03d.tar.gz
minetest-738fbc66d096575bb9a1694056ce2d627a70c03d.tar.bz2
minetest-738fbc66d096575bb9a1694056ce2d627a70c03d.zip
Fix Lua PcgRandom
Before, this lua code led to a crash: local pcg = PcgRandom(42) local value = pcg:next() This was because if you called s32 PcgRandom::range(min, max) with the minimum and maximum possible values for s32 integers (which the lua binding code did), u32 PcgRandom::range(bound) got called with 0 as the bound. The bound however is one above the maximum value, so 0 is a "special" value to pass to this function. This commit fixes the lua crash by assigning the RNG's full range to the bound 0, which is also fits to the "maximum is bound - 1" principle, as (u32)-1 is the maximum value in the u32 range.
Diffstat (limited to 'src/script/lua_api/l_settings.cpp')
0 files changed, 0 insertions, 0 deletions