forked from mtcontrib/minetest-mod-snow
do not assume a fixed chunksize when generating map
This commit is contained in:
parent
745fca1c84
commit
9d2211b0b5
@ -49,19 +49,19 @@ end
|
|||||||
|
|
||||||
-- caching functions
|
-- caching functions
|
||||||
|
|
||||||
local default_sidelen = (tonumber(minetest.setting_get("chunksize")) or 5)*16-1
|
local ws_values = {}
|
||||||
local ws_lists = {}
|
local function get_ws_value(a, x)
|
||||||
local function get_ws_list(a,x)
|
local v = ws_values[a]
|
||||||
ws_lists[a] = ws_lists[a] or {}
|
|
||||||
local v = ws_lists[a][x]
|
|
||||||
if v then
|
if v then
|
||||||
return v
|
v = v[x]
|
||||||
|
if v then
|
||||||
|
return v
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ws_values[a] = {}
|
||||||
end
|
end
|
||||||
v = {}
|
v = do_ws_func(a, x)
|
||||||
for x = x, x + default_sidelen do
|
ws_values[a][x] = v
|
||||||
v[x] = do_ws_func(a, x)
|
|
||||||
end
|
|
||||||
ws_lists[a][x] = v
|
|
||||||
return v
|
return v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -474,18 +474,13 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
-- set snow
|
-- set snow
|
||||||
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
data[area:index(i[3], i[1]+1, i[2])] = c.snow
|
||||||
end
|
end
|
||||||
local wsz, wsx
|
|
||||||
for _,i in pairs(snow_tab) do
|
for _,i in pairs(snow_tab) do
|
||||||
local y,z,x,test = unpack(i)
|
local y,z,x,test = unpack(i)
|
||||||
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
test = (test-nosmooth_rarity)/(1-nosmooth_rarity) -- /(1-0.53)
|
||||||
if test > 0 then
|
if test > 0 then
|
||||||
local maxh = math.floor(test*10)%10+1
|
local maxh = math.floor(test*10)%10+1
|
||||||
if maxh ~= 1 then
|
if maxh ~= 1 then
|
||||||
if not wsz then
|
local h = math.floor(get_ws_value(2, x) + get_ws_value(5, z)*5)%10+1
|
||||||
wsz = get_ws_list(5, z0)
|
|
||||||
wsx = get_ws_list(2, x0)
|
|
||||||
end
|
|
||||||
local h = math.floor(wsx[x]+wsz[z]*5)%10+1
|
|
||||||
if h ~= 1 then
|
if h ~= 1 then
|
||||||
-- search for nearby snow
|
-- search for nearby snow
|
||||||
y = y+1
|
y = y+1
|
||||||
|
Loading…
Reference in New Issue
Block a user