Page 1 of 1

ABM gets executed even if node(block) is not longer in group

PostPosted: Sun Jan 10, 2016 10:09
by addi
If you remove a group of an node (igniter group of lava_source) and there is a abm registered to this node (fire) than the abm does trigger on this node. (burnable nodes starts burning)

example:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.override_item("default:lava_source", {
    groups = {lava = 3, liquid = 2, igniter = nil, hot = 3},--remove igniter from lava source
})

expected behaviour: Lava will not longer burn nodes.
real behaviour: Lava still sets nodes on fire
if you check
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.registered_nodes["default:lava_source"].groups

it shows what you expect:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
{
   liquid = 2,
   lava = 3,
   hot = 3
}
(igniter is not aviable)

but the fire ABM
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_abm({
    nodenames = {"group:flammable"},
    neighbors = {"group:igniter"},

still gets executed

To reproduce this behaviour install test mod in attachment and place a burnable node near lava_source

Re: ABM gets executed even if node(block) is not longer in g

PostPosted: Sun Jan 10, 2016 16:35
by kahrl
Yes, this is a bug / missing feature in CNodeDefManager::set() which is called when registering or overriding a node. There is a data structure that maps each group to a list of nodes in that group. CNodeDefManager::set() adds the node to each group it is in, but it doesn't remove it from groups it is no longer in.

This is even mentioned in a comment inside that method: "// FIXME: This should remove a node from groups it no longer belongs to when a node is re-registered."