mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 17:43:45 +01:00
Use better randomseed for Lua too
see e985b7a0bf5ddf4999330a5a1a878654f68b254e This solves a concrete issue with async workers generating the same random numbers (as discovered in #14518).
This commit is contained in:
parent
ef0c19477c
commit
f87994edc7
@ -26,7 +26,15 @@ do
|
||||
core.print = nil -- don't pollute our namespace
|
||||
end
|
||||
end
|
||||
math.randomseed(os.time())
|
||||
|
||||
do
|
||||
-- Note that PUC Lua just calls srand() which is already initialized by C++,
|
||||
-- but we don't want to rely on this implementation detail.
|
||||
local seed = 1048576 * (os.time() % 1048576)
|
||||
seed = seed + core.get_us_time() % 1048576
|
||||
math.randomseed(seed)
|
||||
end
|
||||
|
||||
minetest = core
|
||||
|
||||
-- Load other files
|
||||
|
Loading…
Reference in New Issue
Block a user