Disable fast dungeon initialization methods

Apparently on top of dungeons regenerating
over top of themselves, caves can also carve
into dungeons, and this may cause issues
with dungeon loot, where the loot nodes are
removed (but w/o the destructor) so that
floating fake visinv entities are sometimes
left floating in place.

Instead, give the engine time to finish
initializing dungeons, and then use only the
ABM (sigh, it's always only ABMs that are
actually eventually reliable after all) to do
delayed initialization.

This kind of sucks if the player starts out in
a dungeon in a new map, but the old "fast"
methods weren't fast enough to prevent a
flash of uninitialized dungeon anyway, so we
just have to hope that the dungeons will get
initialized while on the map horizon before
the player gets close enough for it to matter.

Get rid of the different dungeon cobble now
to mitigate this, also since we no longer
need it to debug uninitialized dungeons.
This commit is contained in:
Aaron Suen 2021-03-05 21:02:36 -05:00
parent 3fe2d58872
commit b89f2b7d86

View File

@ -1,6 +1,6 @@
-- LUALOCALS < ---------------------------------------------------------
local ipairs, math, minetest, next, nodecore, pairs, table
= ipairs, math, minetest, next, nodecore, pairs, table
local ipairs, math, minetest, nodecore, table
= ipairs, math, minetest, nodecore, table
local math_floor, table_insert
= math.floor, table.insert
-- LUALOCALS > ---------------------------------------------------------
@ -58,7 +58,6 @@ local function regdungeon(name)
local def = nodecore.underride({groups = {dungeon_mapgen = 1}},
minetest.registered_nodes[cobble])
def.description = "Dungeon Cobble"
def.tiles = {modname .. "_stone.png^" .. modname .. "_cobble.png"}
def.mapgen = nil
return minetest.register_node(modname .. ":" .. name, def)
end
@ -79,13 +78,6 @@ end
------------------------------------------------------------------------
-- DUNGEON MODIFIER HOOKS
nodecore.register_lbm({
name = modname .. ":dungeons",
run_at_every_load = true,
nodenames = {"group:dungeon_mapgen"},
action = dungeonprocess
})
minetest.register_abm({
label = modname .. " dungeon cleanup",
interval = 1,
@ -93,45 +85,3 @@ minetest.register_abm({
nodenames = {"group:dungeon_mapgen"},
action = dungeonprocess
})
local queue = {}
minetest.register_globalstep(function()
if not next(queue) then return end
local batch = queue
queue = {}
for _, pos in pairs(batch) do
local node = minetest.get_node(pos)
local cid = minetest.get_content_id(node.name)
if cid == node.cid then dungeonprocess(pos, node) end
end
end)
local hash = minetest.hash_node_position
local cid_cobble = minetest.get_content_id(modname .. ":dungeon_cobble")
local cid_cobble_alt = minetest.get_content_id(modname .. ":dungeon_cobble_alt")
local cid_cobble_stair = minetest.get_content_id(modname .. ":dungeon_cobble_stair")
nodecore.register_mapgen_shared({
label = "dungeon loot",
func = function(minp, maxp, area, data)
local ai = area.index
for z = minp.z, maxp.z do
for y = minp.y, maxp.y - 1 do
local offs = ai(area, 0, y, z)
for x = minp.x, maxp.x do
local i = offs + x
local d = data[i]
if d == cid_cobble
or d == cid_cobble_alt
or d == cid_cobble_stair then
local pos = {x = x, y = y, z = z}
pos.cid = d
queue[hash(pos)] = pos
end
end
end
end
end,
priority = -100
})