more optimization of inner loops related to mvps_push

This commit is contained in:
binarycat 2023-12-17 15:13:54 -05:00
parent ba9b2509a0
commit bc9ed16c91
1 changed files with 5 additions and 4 deletions

View File

@ -98,15 +98,16 @@ function mesecon.mvps_get_stack(pos, dir, maximum, all_pull_sticky)
-- optimization: don't check blocks that are already part of the stack -- optimization: don't check blocks that are already part of the stack
if not pos_set[minetest.hash_node_position(adjpos)] then if not pos_set[minetest.hash_node_position(adjpos)] then
local adjnode = minetest.get_node(adjpos) local adjnode = minetest.get_node(adjpos)
if minetest.registered_nodes[adjnode.name] local adjdef = minetest.registered_nodes[adjnode.name]
and minetest.registered_nodes[adjnode.name].mvps_sticky then if adjdef
local sticksto = minetest.registered_nodes[adjnode.name] and adjdef.mvps_sticky then
.mvps_sticky(adjpos, adjnode) local sticksto = adjdef.mvps_sticky(adjpos, adjnode)
-- connects to this position? -- connects to this position?
for _, link in ipairs(sticksto) do for _, link in ipairs(sticksto) do
if vector.equals(link, np) then if vector.equals(link, np) then
frontiers:add(adjpos) frontiers:add(adjpos)
break
end end
end end
end end