mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 20:11:06 +01:00
Add check for unknown nodes.
* Check if node has a definition table before attempting to evaluate its attributes. * Define local variable to cache multiple accesses to `registered_nodes[]` and improve readability. * Clarify code flow.
This commit is contained in:
parent
3f4dafc68f
commit
f5a8d6d17a
1 changed files with 11 additions and 5 deletions
|
@ -134,10 +134,15 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param)
|
||||||
-- Check floor and ceiling: Must be *completely* solid
|
-- Check floor and ceiling: Must be *completely* solid
|
||||||
local y_floor = y
|
local y_floor = y
|
||||||
local y_ceiling = y + dim.y + 1
|
local y_ceiling = y + dim.y + 1
|
||||||
if check then for tx = x+1, x+dim.x do for tz = z+1, z+dim.z do
|
if check then
|
||||||
if not registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name].walkable
|
for tx = x+1, x+dim.x do
|
||||||
or not registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name].walkable then return false end
|
for tz = z+1, z+dim.z do
|
||||||
end end end
|
local fdef = registered_nodes[get_node({x = tx, y = y_floor , z = tz}).name]
|
||||||
|
local cdef = registered_nodes[get_node({x = tx, y = y_ceiling, z = tz}).name]
|
||||||
|
if not fdev or not fdev.walkable or not cdev or not cdev.walkable then return false end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Check for air openings (2 stacked air at ground level) in wall positions
|
-- Check for air openings (2 stacked air at ground level) in wall positions
|
||||||
local openings_counter = 0
|
local openings_counter = 0
|
||||||
|
@ -287,7 +292,8 @@ local function ecb_spawn_dungeon(blockpos, action, calls_remaining, param)
|
||||||
-- Do not overwrite nodes with is_ground_content == false (e.g. bedrock)
|
-- Do not overwrite nodes with is_ground_content == false (e.g. bedrock)
|
||||||
-- Exceptions: cobblestone and mossy cobblestone so neighborings dungeons nicely connect to each other
|
-- Exceptions: cobblestone and mossy cobblestone so neighborings dungeons nicely connect to each other
|
||||||
local name = get_node(p).name
|
local name = get_node(p).name
|
||||||
if registered_nodes[name].is_ground_content or name == "mcl_core:cobble" or name == "mcl_core:mossycobble" then
|
local rn = registered_nodes[name]
|
||||||
|
if rn and rn.is_ground_content or name == "mcl_core:cobble" or name == "mcl_core:mossycobble" then
|
||||||
-- Floor
|
-- Floor
|
||||||
if ty == y then
|
if ty == y then
|
||||||
if pr:next(1,4) == 1 then
|
if pr:next(1,4) == 1 then
|
||||||
|
|
Loading…
Reference in a new issue