Skip to content

Commit

Permalink
apparently math.random calls can have trouble with ranges outside of …
Browse files Browse the repository at this point in the history
…a 32 bit integer
  • Loading branch information
FaceDeer committed Jul 10, 2019
1 parent 108153f commit 47f6791
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions random.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-- Returns a consistent list of random points within a volume.
-- Each call to this method will give the same set of points if the same parameters are provided
mapgen_helper.get_random_points = function(minp, maxp, min_output_size, max_output_size)
local next_seed = math.random(1, 1000000000)
local next_seed = math.random(1, 2^31)
math.randomseed(minetest.hash_node_position(minp) + mapgen_helper.mapgen_seed)

local count = math.random(min_output_size, max_output_size)
Expand All @@ -22,7 +22,7 @@ end

-- Returns a random value based on the x and z coordinates of pos, always the same for the same x and z
mapgen_helper.xz_consistent_randomp = function(pos)
local next_seed = math.random(1, 1000000000000)
local next_seed = math.random(1, 2^31)
math.randomseed(pos.x + pos.z * 2 ^ 8)
local output = math.random()
math.randomseed(next_seed)
Expand Down

0 comments on commit 47f6791

Please sign in to comment.