quarry restart issues fixed

This commit is contained in:
Joachim Stolberg 2019-01-03 10:28:07 +01:00
parent 3f98da7961
commit d69b96928e
3 changed files with 15 additions and 13 deletions

@ -508,7 +508,7 @@ end
-- Data Maintenance
-------------------------------------------------------------------------------
local function data_maintenance()
print("[Tubelib] Data maintenance started")
minetest.log("info", "[Tubelib] Data maintenance started")
if Version == 1 then
-- Add day_count for aging of unused positions
for num,item in pairs(Number2Pos) do
@ -526,27 +526,28 @@ local function data_maintenance()
if item.name then
Number2Pos[num] = item
-- data not older than 5 real days
elseif item.time and (item.time + 360) > day_cnt then
elseif item.time and (item.time + (72*5)) > day_cnt then
Number2Pos[num] = item
else
print("Position deleted", num)
minetest.log("info", "Position deleted", num)
end
end
end
-- collect unused node numbers
for idx = 1,NextNumber-1 do
for idx = NextNumber-1,1,-1 do
--FreeNumbers
local num = string.format("%.04u", idx)
if not Number2Pos[num] then
FreeNumbers[#FreeNumbers+1] = num
end
end
print("[Tubelib] Data maintenance finished")
minetest.log("info", "[Tubelib] "..#FreeNumbers.." numbers recycled")
minetest.log("info", "[Tubelib] Data maintenance finished")
end
generate_Key2Number()
-- maintain data after one minute
-- maintain data after 5 seconds
-- (minetest.get_day_count() will not be valid at start time)
minetest.after(5, data_maintenance)

@ -358,7 +358,7 @@ function NodeStates:on_receive_message(pos, topic, payload)
end
-- repair corrupt node data and/or migrate node to state2
function NodeStates:on_node_load(pos)
function NodeStates:on_node_load(pos, not_start_timer)
local meta = minetest.get_meta(pos)
-- legacy node number/state/counter?
@ -398,7 +398,7 @@ function NodeStates:on_node_load(pos)
else
meta:set_int("tubelib_state", STOPPED)
end
elseif state == RUNNING then
elseif state == RUNNING and not not_start_timer then
minetest.get_node_timer(pos):start(self.cycle_time)
elseif state == STANDBY then
minetest.get_node_timer(pos):start(self.cycle_time * self.standby_ticks)

@ -459,11 +459,12 @@ tubelib.register_node("tubelib_addons1:quarry",
return "unsupported"
end
end,
-- Function has some negative impact on the cycle time for the
-- cobble generator mode (5s on/5s off)
-- on_node_load = function(pos)
-- State:on_node_load(pos)
-- end,
on_node_load = function(pos)
local depth = M(pos):get_int("max_levels") or 1
-- If depth is 1, it is likely that the quarry is used as cobble generator,
-- controlled by a sequencer. If so, don't restart the timer.
State:on_node_load(pos, depth == 1)
end,
on_node_repair = function(pos)
return State:on_node_repair(pos)
end,