Update mapgen.lua

use math.floor on n in fun_caves.is_fortress to ensure it's integer when comparing it with 1
put the manual garbage collection into a minetest.after, else it doesn't know yet that data, etc. aren't longer used
This commit is contained in:
HybridDog 2016-05-28 14:31:10 +02:00
parent bde0274123
commit 7172568615

View file

@ -103,23 +103,21 @@ end
-- end -- end
--end --end
fun_caves.is_fortress = function(pos, csize) fun_caves.is_fortress = function(pos, cs)
local cs = csize
if not cs then
-- Fix this to get csize, somehow. -- Fix this to get csize, somehow.
cs = {x=80, y=80, z=80} local cs = cs or {x=80, y=80, z=80}
end
local x = math.floor((pos.x + 33) / cs.x)
local y = math.floor((pos.y + 33) / cs.y) local y = math.floor((pos.y + 33) / cs.y)
local z = math.floor((pos.z + 33) / cs.z)
if y > -3 or (pos.y + 33) % cs.y > cs.y - 5 then if y > -3 or (pos.y + 33) % cs.y > cs.y - 5 then
return false return false
end end
local x = math.floor((pos.x + 33) / cs.x)
local z = math.floor((pos.z + 33) / cs.z)
local n = minetest.get_perlin(fortress_noise):get3d({x=x, y=y, z=z}) local n = minetest.get_perlin(fortress_noise):get3d({x=x, y=y, z=z})
n = (n * 10000) % 20 n = math.floor((n * 10000) % 20)
if n == 1 or DEBUG then if n == 1 or DEBUG then
return true return true
@ -250,10 +248,12 @@ local function generate(p_minp, p_maxp, seed)
end end
-- Deal with memory issues. This, of course, is supposed to be automatic. -- Deal with memory issues. This, of course, is supposed to be automatic.
minetest.after(0, function()
if math.floor(collectgarbage("count")/1024) > 400 then if math.floor(collectgarbage("count")/1024) > 400 then
print("Fun Caves: Manually collecting garbage...") print("Fun Caves: Manually collecting garbage...")
collectgarbage("collect") collectgarbage("collect")
end end
end)
end end