Add save interval setting, fix accidental global variable, at_sync_ndb on server priv not limited, timetaking for restore_all
This commit is contained in:
parent
4d13b15842
commit
1b8a3dfaf2
|
@ -52,7 +52,7 @@ local NO_SAVE = false
|
|||
|
||||
-- Use a global slowdown factor to slow down train movements. Now a setting
|
||||
local DTIME_LIMIT = tonumber(minetest.settings:get("advtrains_dtime_limit")) or 0.2
|
||||
|
||||
local SAVE_INTERVAL = tonumber(minetest.settings:get("advtrains_save_interval")) or 60
|
||||
|
||||
--Constant for maximum connection value/division of the circle
|
||||
AT_CMAX = 16
|
||||
|
@ -564,8 +564,7 @@ end
|
|||
--## MAIN LOOP ##--
|
||||
--Calls all subsequent main tasks of both advtrains and atlatc
|
||||
local init_load=false
|
||||
local save_interval=60
|
||||
local save_timer=save_interval
|
||||
local save_timer = SAVE_INTERVAL
|
||||
advtrains.mainloop_runcnt=0
|
||||
advtrains.global_slowdown = 1
|
||||
|
||||
|
@ -624,7 +623,7 @@ minetest.register_globalstep(function(dtime_mt)
|
|||
local t=os.clock()
|
||||
--save
|
||||
advtrains.save()
|
||||
save_timer=save_interval
|
||||
save_timer = SAVE_INTERVAL
|
||||
atprintbm("saving", t)
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -83,7 +83,7 @@ local function look_ahead(id, train)
|
|||
|
||||
--local brake_i = advtrains.path_get_index_by_offset(train, train.index, brakedst + params.BRAKE_SPACE)
|
||||
-- worst case (don't use index_by_offset)
|
||||
brake_i = atfloor(train.index + brakedst + params.BRAKE_SPACE)
|
||||
local brake_i = atfloor(train.index + brakedst + params.BRAKE_SPACE)
|
||||
atprint("LZB: looking ahead up to ", brake_i)
|
||||
|
||||
--local aware_i = advtrains.path_get_index_by_offset(train, brake_i, AWARE_ZONE)
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -52,3 +52,7 @@ advtrains_wagon_load_range (Wagon Entity Load/Unload Range) int 96 32 512
|
|||
# acceleration of wagons to decrease server load.
|
||||
# A value of 0 (default) disables this behavior.
|
||||
advtrains_dtime_limit (DTime Limit for slow-down) float 0.2 0 5
|
||||
|
||||
# Time interval in seconds in which advtrains stores its save data to disk
|
||||
# Nevertheless, advtrains saves all data when shutting down the server.
|
||||
advtrains_save_interval (Save Interval) int 60 20 3600
|
||||
|
|
Loading…
Reference in New Issue