Skip to content

Commit

Permalink
lite fixes on map only for test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattyx14 committed Aug 29, 2023
1 parent 9bf7920 commit 33c7130
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions data-otxserver/lib/core/load.lua
Original file line number Diff line number Diff line change
@@ -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')
30 changes: 30 additions & 0 deletions data-otxserver/lib/core/storagesCustom.lua
Original file line number Diff line number Diff line change
@@ -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
Binary file modified data-otxserver/world/forgotten.otbm
Binary file not shown.

0 comments on commit 33c7130

Please sign in to comment.