From b03e402c718e8bc39d8aa57c5fe67c5722708c37 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 17 Oct 2018 21:02:43 +0200 Subject: 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. --- advtrains/nodedb.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'advtrains/nodedb.lua') diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua index 592e730..ad58b37 100644 --- a/advtrains/nodedb.lua +++ b/advtrains/nodedb.lua @@ -151,10 +151,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 -- cgit v1.2.3