diff options
author | orwell96 <mono96.mml@gmail.com> | 2017-05-31 15:55:45 +0200 |
---|---|---|
committer | orwell96 <mono96.mml@gmail.com> | 2017-05-31 15:55:45 +0200 |
commit | 93250ca3a2a6fd5bf8704b2f8075be874fd815c2 (patch) | |
tree | 54d5c393db5a9fadf8974ba3e7f44a27840fd24c | |
parent | ca6989b560cf99af606bbeead1f6551e4f5f3349 (diff) | |
download | advtrains-93250ca3a2a6fd5bf8704b2f8075be874fd815c2.tar.gz advtrains-93250ca3a2a6fd5bf8704b2f8075be874fd815c2.tar.bz2 advtrains-93250ca3a2a6fd5bf8704b2f8075be874fd815c2.zip |
Fix still broken ndb restoring, and make sid() honor nil values
-rw-r--r-- | advtrains.zip | bin | 4996801 -> 4996806 bytes | |||
-rw-r--r-- | advtrains/advtrains/init.lua | 2 | ||||
-rw-r--r-- | advtrains/advtrains/nodedb.lua | 24 |
3 files changed, 15 insertions, 11 deletions
diff --git a/advtrains.zip b/advtrains.zip Binary files differindex cba0602..435877d 100644 --- a/advtrains.zip +++ b/advtrains.zip diff --git a/advtrains/advtrains/init.lua b/advtrains/advtrains/init.lua index 926619c..7793a42 100644 --- a/advtrains/advtrains/init.lua +++ b/advtrains/advtrains/init.lua @@ -90,7 +90,7 @@ atwarn=function(t, ...) minetest.log("warning", "[advtrains]"..text) minetest.chat_send_all("[advtrains] -!- "..text) end -sid=function(id) return string.sub(id, -6) end +sid=function(id) if id then return string.sub(id, -6) end end if minetest.settings:get_bool("advtrains_enable_debugging") then atprint=function(t, ...) diff --git a/advtrains/advtrains/nodedb.lua b/advtrains/advtrains/nodedb.lua index 4dc451a..3986633 100644 --- a/advtrains/advtrains/nodedb.lua +++ b/advtrains/advtrains/nodedb.lua @@ -107,14 +107,7 @@ function ndb.get_node_or_nil(pos) return node else --maybe we have the node in the database... - local cid=ndbget(pos.x, pos.y, pos.z) - if cid then - local nodeid = ndb_nodeids[u14b(cid)] - if nodeid then - --atprint("ndb.get_node_or_nil",pos,"found node",nodeid,"cid",cid,"par2",l2b(cid)) - return {name=nodeid, param2 = l2b(cid)} - end - end + return ndb.get_node_raw(pos) end atprint("ndb.get_node_or_nil",pos,"not found") end @@ -125,6 +118,17 @@ function ndb.get_node(pos) end return n end +function ndb.get_node_raw(pos) + local cid=ndbget(pos.x, pos.y, pos.z) + if cid then + local nodeid = ndb_nodeids[u14b(cid)] + if nodeid then + return {name=nodeid, param2 = l2b(cid)} + end + end + return nil +end + function ndb.swap_node(pos, node) minetest.swap_node(pos, node) @@ -248,7 +252,7 @@ ndb.restore_all = function() local node=minetest.get_node_or_nil(pos) if node then local ori_ndef=minetest.registered_nodes[node.name] - local ndbnode=ndb.get_node(pos) + local ndbnode=ndb.get_node_raw(pos) if ori_ndef and ori_ndef.groups.save_in_nodedb then --check if this node has been worldedited, and don't replace then if (ndbnode.name~=node.name or ndbnode.param2~=node.param2) then minetest.swap_node(pos, ndbnode) @@ -283,7 +287,7 @@ advtrains.ndb=ndb local ptime=0 -minetest.register_chatcommand("at_restore_ndb", +minetest.register_chatcommand("at_sync_ndb", { params = "", -- Short parameter description description = "Write node db back to map and find ghost nodes", -- Full description |