Skip to content

Commit

Permalink
Merge pull request #844 from FIr3baL/FB_reverseAvoidParsing
Browse files Browse the repository at this point in the history
Fix parsing of avoids
  • Loading branch information
FIr3baL authored Dec 6, 2024
2 parents 165362d + b213ef8 commit 2d40461
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
9 changes: 9 additions & 0 deletions libs/chiliui/chili/headers/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,15 @@ function table:ifind(element)
return false
end

function table:ifindByKey(element, key)
for i = 1, #self do
if self[i][key] and self[i][key] == element then
return i
end
end
return false
end

function table:sum()
local r = 0
for i = 1, #self do
Expand Down
11 changes: 4 additions & 7 deletions libs/liblobby/lobby/interface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2148,18 +2148,15 @@ local function buildDisregardListID(ignores, avoids, blocks)
for _, userID in ipairs(blocks) do
table.insert(disregardListID, {userID = userID, status = Configuration.BLOCK})
end

for _, userID in ipairs(avoids) do
if table.ifind(disregardListID, userID) then
Spring.Log(LOG_SECTION, LOG.ERROR, string.format("Found same user in 2 disregard lists (%s and %s):%s", "blocks", "avoids", userID))
else
if not table.ifindByKey(disregardListID, userID, "userID") then
table.insert(disregardListID, {userID = userID, status = Configuration.AVOID})
end
end

for _, userID in ipairs(ignores) do
local i = table.ifind(disregardListID, userID)
if i then
Spring.Log(LOG_SECTION, LOG.ERROR, string.format("Found same user in 2 disregard lists (%s and %s):%s", disregardListID[i].status == Configuration.BLOCK and "blocks" or "avoids", "ignores" , userID))
else
if not table.ifindByKey(disregardListID, userID, "userID") then
table.insert(disregardListID, {userID = userID, status = Configuration.IGNORE})
end
end
Expand Down

0 comments on commit 2d40461

Please sign in to comment.