fix a crash with veinstone, and simplify nvals_cave lookup now that overgen covers the same area

This commit is contained in:
FaceDeer 2019-11-11 09:42:56 -07:00
parent 85ab92f32d
commit b29f549d76
4 changed files with 33 additions and 33 deletions

View File

@ -97,7 +97,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
-- Partly fill flooded caverns and warrens
if minp.y <= subsea_level then
for vi in area:iterp(minp, maxp) do
if data[vi] == c_air and area:get_y(vi) <= subsea_level and nvals_cave[cave_area:transform(area, vi)] < -flooding_threshold then
if data[vi] == c_air and area:get_y(vi) <= subsea_level and nvals_cave[vi] < -flooding_threshold then
data[vi] = c_water
end
end
@ -111,7 +111,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local abs_cracks = math.abs(nvals_cracks[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then
-- underwater floor
@ -137,7 +137,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local abs_cracks = math.abs(nvals_cracks[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater ceiling, do nothing
@ -164,7 +164,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
@ -182,7 +182,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
@ -210,7 +210,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local ystride = area.ystride
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
@ -249,7 +249,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
@ -268,7 +268,7 @@ local decorate_level_1 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.column_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local dry = (biome_name == "barren") and (nvals_cave[cave_area:transform(area, vi)] > 0)
local dry = (biome_name == "barren") and (nvals_cave[vi] > 0)
if dry and data[vi] == c_wet_flowstone then
data[vi] = c_dry_flowstone

View File

@ -135,10 +135,11 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
local cavern_def = node_arrays.cavern_def
local vein_noise
local vein_area
-- Partly fill flooded caverns and warrens
for vi in area:iterp(minp, maxp) do
local cave_val = nvals_cave[cave_area:transform(area, vi)]
local cave_val = nvals_cave[vi]
if cave_val < -flooding_threshold then
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
@ -149,10 +150,9 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
if biome_name == "barren" and cave_val < -cave_threshold and cave_val > -cave_threshold - 0.01 then
-- add giant rooty structures to the flooded barren caverns
if vein_noise == nil then
vein_noise = mapgen_helper.perlin3d("df_caverns:wall_veins", minp, maxp, wall_vein_perlin_params)
vein_noise, vein_area = mapgen_helper.perlin3d("df_caverns:wall_veins", minp, maxp, wall_vein_perlin_params)
end
-- we can reuse cave_area here, its extents are minp, maxp too.
if data[vi] == c_air and math.abs(vein_noise[cave_area:transform(area, vi)]) < 0.02 then
if data[vi] == c_air and math.abs(vein_noise[vein_area:transform(area, vi)]) < 0.02 then
data[vi] = c_veinstone
end
end
@ -170,7 +170,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local abs_cracks = math.abs(nvals_cracks[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then
-- underwater floor
@ -198,7 +198,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local abs_cracks = math.abs(nvals_cracks[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater ceiling, do nothing
@ -230,7 +230,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
@ -248,7 +248,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local ystride = area.ystride
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
@ -287,7 +287,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name ~= "barren" then
@ -305,7 +305,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local ystride = area.ystride
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
@ -345,7 +345,7 @@ local decorate_level_2 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.column_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local dry = (biome_name == "barren") and (nvals_cave[cave_area:transform(area, vi)] > 0)
local dry = (biome_name == "barren") and (nvals_cave[vi] > 0)
if dry and data[vi] == c_wet_flowstone then
data[vi] = c_dry_flowstone

View File

@ -209,7 +209,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
if minp.y <= subsea_level then
for vi in area:iterp(minp, maxp) do
local y = area:get_y(vi)
if y <= subsea_level and nvals_cave[cave_area:transform(area, vi)] < -flooding_threshold then
if y <= subsea_level and nvals_cave[vi] < -flooding_threshold then
if data[vi] == c_air and y <= subsea_level then
data[vi] = c_water
end
@ -219,7 +219,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
if biome_name == "blackcap" then
-- oil slick
local cave = math.abs(nvals_cave[cave_area:transform(area, vi)])
local cave = math.abs(nvals_cave[vi])
if y == subsea_level and data[vi] == c_water and cave + nvals_cracks[index2d]*0.025 < cavern_def.cave_threshold + 0.1 then
data[vi] = c_oil
end
@ -240,7 +240,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local cracks = nvals_cracks[index2d]
local abs_cracks = math.abs(cracks)
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater floor
@ -285,7 +285,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local abs_cracks = math.abs(nvals_cracks[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater ceiling, do nothing
@ -346,7 +346,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name == "blackcap" then
@ -364,7 +364,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.tunnel_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if not (flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level) then
if flooded_caverns or biome_name == "blackcap" then
@ -393,7 +393,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_ceiling_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if flooded_caverns and minp.y < subsea_level and area:get_y(vi) < subsea_level then
-- underwater ceiling, do nothing
@ -431,7 +431,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.warren_floor_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0 -- this indicates if we're in the "flooded" set of caves or not.
local flooded_caverns = nvals_cave[vi] < 0 -- this indicates if we're in the "flooded" set of caves or not.
if minp.y < subsea_level and area:get_y(vi) < subsea_level and flooded_caverns then
-- underwater floor, do nothing
@ -473,7 +473,7 @@ local decorate_level_3 = function(minp, maxp, seed, vm, node_arrays, area, data)
for _, vi in ipairs(node_arrays.column_nodes) do
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local biome_name = get_biome(heatmap[index2d], humiditymap[index2d])
local flooded_caverns = nvals_cave[cave_area:transform(area, vi)] < 0
local flooded_caverns = nvals_cave[vi] < 0
if biome_name == "bloodnether" and data[vi] == c_wet_flowstone then
if not flooded_caverns then

View File

@ -185,7 +185,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
local cracks = nvals_cracks[index2d]
local abs_cracks = math.abs(cracks)
local humidity = humiditymap[index2d]
local jungle = nvals_cave[cave_area:transform(area, vi)] < 0
local jungle = nvals_cave[vi] < 0
if jungle then
jungle_cavern_floor(abs_cracks, humidity, vi, area, data, data_param2)
@ -201,7 +201,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local cracks = nvals_cracks[index2d]
local abs_cracks = math.abs(cracks)
local jungle = nvals_cave[cave_area:transform(area, vi)] < 0
local jungle = nvals_cave[vi] < 0
local humidity = humiditymap[index2d]
if jungle then
jungle_cavern_ceiling(abs_cracks, vi, area, data, data_param2)
@ -231,7 +231,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local cracks = nvals_cracks[index2d]
local abs_cracks = math.abs(cracks)
local jungle = nvals_cave[cave_area:transform(area, vi)] < 0
local jungle = nvals_cave[vi] < 0
-- if jungle then
-- jungle_warren_ceiling(abs_cracks, vi, area, data, data_param2)
@ -248,7 +248,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
local index2d = mapgen_helper.index2di(minp, maxp, area, vi)
local cracks = nvals_cracks[index2d]
local abs_cracks = math.abs(cracks)
local jungle = nvals_cave[cave_area:transform(area, vi)] < 0
local jungle = nvals_cave[vi] < 0
-- if jungle then
-- jungle_warren_floor(abs_cracks, vi, area, data, data_param2)
@ -259,7 +259,7 @@ local decorate_primordial = function(minp, maxp, seed, vm, node_arrays, area, da
-- columns
for _, vi in ipairs(node_arrays.column_nodes) do
local jungle = nvals_cave[cave_area:transform(area, vi)] < 0
local jungle = nvals_cave[vi] < 0
if jungle then
end
end