mirror of
https://github.com/joe7575/techpack.git
synced 2024-08-21 13:44:13 +02:00
number recycling removed
This commit is contained in:
parent
d9b6a96941
commit
8aa52ac3cc
@ -26,7 +26,6 @@ local storage = minetest.get_mod_storage()
|
|||||||
local NextNumber = minetest.deserialize(storage:get_string("NextNumber")) or 1
|
local NextNumber = minetest.deserialize(storage:get_string("NextNumber")) or 1
|
||||||
local Version = minetest.deserialize(storage:get_string("Version")) or 1
|
local Version = minetest.deserialize(storage:get_string("Version")) or 1
|
||||||
local Number2Pos = minetest.deserialize(storage:get_string("Number2Pos")) or {}
|
local Number2Pos = minetest.deserialize(storage:get_string("Number2Pos")) or {}
|
||||||
local FreeNumbers = {}
|
|
||||||
|
|
||||||
local function update_mod_storage()
|
local function update_mod_storage()
|
||||||
minetest.log("action", "[Tubelib] Store data...")
|
minetest.log("action", "[Tubelib] Store data...")
|
||||||
@ -71,18 +70,11 @@ end
|
|||||||
-- Determine position related node number for addressing purposes
|
-- Determine position related node number for addressing purposes
|
||||||
local function get_number(pos)
|
local function get_number(pos)
|
||||||
local key = get_key_str(pos)
|
local key = get_key_str(pos)
|
||||||
local num
|
|
||||||
if not Key2Number[key] then
|
if not Key2Number[key] then
|
||||||
num = table.remove(FreeNumbers)
|
Key2Number[key] = NextNumber
|
||||||
if not num then
|
NextNumber = NextNumber + 1
|
||||||
Key2Number[key] = NextNumber
|
|
||||||
NextNumber = NextNumber + 1
|
|
||||||
num = string.format("%.04u", Key2Number[key])
|
|
||||||
end
|
|
||||||
else
|
|
||||||
num = string.format("%.04u", Key2Number[key])
|
|
||||||
end
|
end
|
||||||
return num
|
return string.format("%.04u", Key2Number[key])
|
||||||
end
|
end
|
||||||
|
|
||||||
local function generate_Key2Number()
|
local function generate_Key2Number()
|
||||||
@ -552,15 +544,6 @@ local function data_maintenance()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- collect unused node numbers
|
|
||||||
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
|
|
||||||
minetest.log("info", "[Tubelib] "..#FreeNumbers.." numbers recycled")
|
|
||||||
minetest.log("info", "[Tubelib] Data maintenance finished")
|
minetest.log("info", "[Tubelib] Data maintenance finished")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user