diff options
author | orwell96 <orwell@bleipb.de> | 2018-10-17 21:02:43 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-10-17 21:05:06 +0200 |
commit | fe4b4a695af2df5a9c0c43efb9255bbdbf783a12 (patch) | |
tree | 818657ffc2ef1fc0190c36cf13fc8132d07c5d2b | |
parent | 267ce6fe6da5c8a59c6ccdbb86b0c66d4398e098 (diff) | |
download | advtrains-fe4b4a695af2df5a9c0c43efb9255bbdbf783a12.tar.gz advtrains-fe4b4a695af2df5a9c0c43efb9255bbdbf783a12.tar.bz2 advtrains-fe4b4a695af2df5a9c0c43efb9255bbdbf783a12.zip |
Fix node database ATC rail bug
After successfully registering newly-placed ATC rails in the nodedb, the rail's after_place_node() callback
(local apn_func()) immediately cleared it again by passing a "node" object that was actually a player object
and thus had no "name" or "param2" to ndb.update(), which it handled how it should not in this situation.
Since those ndb.update calls were unnecessary anyways, I removed them completely.
-rw-r--r-- | advtrains/atc.lua | 4 | ||||
-rw-r--r-- | advtrains/nodedb.lua | 7 | ||||
-rw-r--r-- | advtrains_luaautomation/active_common.lua | 1 |
3 files changed, 7 insertions, 5 deletions
diff --git a/advtrains/atc.lua b/advtrains/atc.lua index b00849d..40809d2 100644 --- a/advtrains/atc.lua +++ b/advtrains/atc.lua @@ -78,8 +78,8 @@ end --nodes local idxtrans={static=1, mesecon=2, digiline=3} -local apn_func=function(pos, node) - advtrains.ndb.update(pos, node) +local apn_func=function(pos) + -- FIX for long-persisting ndb bug: there's no node in parameter 2 of this function! local meta=minetest.get_meta(pos) if meta then meta:set_string("infotext", attrans("ATC controller, unconfigured.")) diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua index edb3329..9513740 100644 --- a/advtrains/nodedb.lua +++ b/advtrains/nodedb.lua @@ -153,10 +153,13 @@ function ndb.update(pos, pnode) nid=#ndb_nodeids+1 ndb_nodeids[nid]=node.name end - ndbset(pos.x, pos.y, pos.z, (nid * 4) + (l2b(node.param2 or 0)) ) - --atprint("nodedb: updating node", pos, "stored nid",nid,"assigned",ndb_nodeids[nid],"resulting cid",ndb_nodes[hash]) + local resid = (nid * 4) + (l2b(node.param2 or 0)) + ndbset(pos.x, pos.y, pos.z, resid ) + --atdebug("nodedb: updating node", pos, "stored nid",nid,"assigned",ndb_nodeids[nid],"resulting cid",resid) + advtrains.invalidate_all_paths(pos) else --at this position there is no longer a node that needs to be tracked. + --atdebug("nodedb: updating node", pos, "cleared") ndbset(pos.x, pos.y, pos.z, nil) end end diff --git a/advtrains_luaautomation/active_common.lua b/advtrains_luaautomation/active_common.lua index 27255a3..5d8cc48 100644 --- a/advtrains_luaautomation/active_common.lua +++ b/advtrains_luaautomation/active_common.lua @@ -12,7 +12,6 @@ function ac.save() end function ac.after_place_node(pos, player) - advtrains.ndb.update(pos) local meta=minetest.get_meta(pos) meta:set_string("formspec", ac.getform(pos, meta)) meta:set_string("infotext", "LuaAutomation component, unconfigured.") |