@@ -1634,53 +1634,60 @@ local function ItemLevelRangePatternCheck(details, text)
16341634 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
16351635end
16361636
1637+ local function CompareWithOperator (op , a , b )
1638+ if op == " <" then
1639+ return a < b
1640+ elseif op == " >" then
1641+ return a > b
1642+ elseif op == " <=" then
1643+ return a <= b
1644+ elseif op == " >=" then
1645+ return a >= b
1646+ else
1647+ return a == b
1648+ end
1649+ end
1650+
16371651local function AvgItemLevelPatternCheck (details , text )
16381652 if GetItemLevel (details ) == false then
16391653 return false
16401654 end
16411655
1642- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1656+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16431657 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16441658
16451659 if tonumber (diff ) then
16461660 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16471661 end
16481662
1649- if op1 == " <" then
1650- return details .itemLevel < avgIlvl
1651- elseif op1 == " >" then
1652- return details .itemLevel > avgIlvl
1653- else
1654- return details .itemLevel == avgIlvl
1655- end
1663+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16561664end
16571665
16581666local inventorySlotIlvl = {}
16591667
1660- local function UpdateInventorySlotIlvl (details )
1661- GetInvType ( details )
1668+ local function UpdateInventorySlotIlvl (cachedItems )
1669+ if not cachedItems then return end
16621670
1663- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1671+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1672+ GetInvType (details )
1673+
1674+ local slot = inventorySlots [details .invType ]
16641675
1665- local slot = inventorySlots [details .invType ]
1666- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1676+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1677+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1678+ end
1679+ end
16671680end
16681681
16691682Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1670- for i = 0 ,1 do
1671- local key = i == 0 and " bags" or " bank"
1683+ for _ ,key in pairs ({ " bags" , " bank" }) do
16721684 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1673- for index in pairs (data [key ]) do
1674- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1675- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1676- end
1685+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16771686 end
16781687end )
16791688
16801689Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1681- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1682- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1683- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1690+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16841691end )
16851692
16861693local function SlotItemLevelPatternCheck (details , text )
@@ -1690,11 +1697,9 @@ local function SlotItemLevelPatternCheck(details, text)
16901697 return false
16911698 end
16921699
1693- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1694- local ilvl = details .itemLevel
1695- local slot = inventorySlots [details .invType ]
1700+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1701+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16961702
1697- local slotilvl = inventorySlotIlvl [slot ]
16981703 if not slotilvl then
16991704 return false
17001705 end
@@ -1703,13 +1708,7 @@ local function SlotItemLevelPatternCheck(details, text)
17031708 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
17041709 end
17051710
1706- if op1 == " <" then
1707- return ilvl < slotilvl
1708- elseif op1 == " >" then
1709- return ilvl > slotilvl
1710- else
1711- return ilvl == slotilvl
1712- end
1711+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
17131712end
17141713
17151714local function GetAuctionValue (details )
@@ -1770,8 +1769,8 @@ end
17701769local patterns = {
17711770 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17721771 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1773- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1774- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1772+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1773+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17751774
17761775 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17771776 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments