diff --git a/data-otxserver/lib/core/load.lua b/data-otxserver/lib/core/load.lua index 186eca445..5cb7a687b 100644 --- a/data-otxserver/lib/core/load.lua +++ b/data-otxserver/lib/core/load.lua @@ -1,2 +1,3 @@ dofile(DATA_DIRECTORY .. '/lib/core/storages.lua') +dofile(DATA_DIRECTORY .. '/lib/core/storagesCustom.lua') dofile(DATA_DIRECTORY .. '/lib/core/quests.lua') diff --git a/data-otxserver/lib/core/storagesCustom.lua b/data-otxserver/lib/core/storagesCustom.lua new file mode 100644 index 000000000..6b41cad01 --- /dev/null +++ b/data-otxserver/lib/core/storagesCustom.lua @@ -0,0 +1,30 @@ +StorageCustom = { + testing = 90000, +} + +-- Values extraction function +local function extractValues(tab, ret) + if type(tab) == "number" then + table.insert(ret, tab) + else + for _, v in pairs(tab) do + extractValues(v, ret) + end + end +end + +local extraction = {} +extractValues(Storage, extraction) -- Call function +table.sort(extraction) -- Sort the table +-- The choice of sorting is due to the fact that sorting is very cheap O (n log2 (n)) +-- And then we can simply compare one by one the elements finding duplicates in O(n) + +-- Scroll through the extracted table for duplicates +if #extraction > 1 then + for i = 1, #extraction - 1 do + if extraction[i] == extraction[i + 1] then + logger.warn("Duplicate Storage Custom value found: {}", + extraction[i]) + end + end +end diff --git a/data-otxserver/world/forgotten.otbm b/data-otxserver/world/forgotten.otbm index 6b0e2d51a..a78cd3692 100644 Binary files a/data-otxserver/world/forgotten.otbm and b/data-otxserver/world/forgotten.otbm differ