aboutsummaryrefslogtreecommitdiff
path: root/advtrains/nodedb.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-01-14 11:08:16 +0100
committerorwell96 <orwell@bleipb.de>2021-02-10 16:42:15 +0100
commit1b8a3dfaf21cd485b7018491c70ebff4c639bfcf (patch)
tree3692266b5244096e991d51882f7875e93d38ca94 /advtrains/nodedb.lua
parent4d13b158420d4a8d5fc0020ee2b0f9a0014c5541 (diff)
downloadadvtrains-1b8a3dfaf21cd485b7018491c70ebff4c639bfcf.tar.gz
advtrains-1b8a3dfaf21cd485b7018491c70ebff4c639bfcf.tar.bz2
advtrains-1b8a3dfaf21cd485b7018491c70ebff4c639bfcf.zip
Add save interval setting, fix accidental global variable, at_sync_ndb on server priv not limited, timetaking for restore_all
Diffstat (limited to 'advtrains/nodedb.lua')
-rw-r--r--advtrains/nodedb.lua5
1 files changed, 3 insertions, 2 deletions
diff --git a/advtrains/nodedb.lua b/advtrains/nodedb.lua
index ca7b195..c664792 100644
--- a/advtrains/nodedb.lua
+++ b/advtrains/nodedb.lua
@@ -327,6 +327,7 @@ minetest.register_lbm({
--used when restoring stuff after a crash
ndb.restore_all = function()
--atlog("Updating the map from the nodedb, this may take a while")
+ local t1 = os.clock()
local cnt=0
local dcnt=0
for y, ny in pairs(ndb_nodes) do
@@ -352,7 +353,7 @@ ndb.restore_all = function()
end
end
end
- local text="Restore node database: Replaced "..cnt.." nodes, removed "..dcnt.." ghost nodes."
+ local text="Restore node database: Replaced "..cnt.." nodes, removed "..dcnt.." ghost nodes. (took "..math.floor((os.clock()-t1) * 1000).."ms)"
atlog(text)
return text
end
@@ -379,7 +380,7 @@ minetest.register_chatcommand("at_sync_ndb",
description = "Write node db back to map and find ghost nodes", -- Full description
privs = {train_operator=true},
func = function(name, param)
- if os.time() < ptime+30 then
+ if os.time() < ptime+30 and not minetest.get_player_privs(name, "server") then
return false, "Please wait at least 30s from the previous execution of /at_restore_ndb!"
end
local text = ndb.restore_all()