@@ -1630,53 +1630,60 @@ local function ItemLevelRangePatternCheck(details, text)
16301630 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
16311631end
16321632
1633+ local function CompareWithOperator (op , a , b )
1634+ if op == " <" then
1635+ return a < b
1636+ elseif op == " >" then
1637+ return a > b
1638+ elseif op == " <=" then
1639+ return a <= b
1640+ elseif op == " >=" then
1641+ return a >= b
1642+ else
1643+ return a == b
1644+ end
1645+ end
1646+
16331647local function AvgItemLevelPatternCheck (details , text )
16341648 if GetItemLevel (details ) == false then
16351649 return false
16361650 end
16371651
1638- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1652+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16391653 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16401654
16411655 if tonumber (diff ) then
16421656 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16431657 end
16441658
1645- if op1 == " <" then
1646- return details .itemLevel < avgIlvl
1647- elseif op1 == " >" then
1648- return details .itemLevel > avgIlvl
1649- else
1650- return details .itemLevel == avgIlvl
1651- end
1659+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16521660end
16531661
16541662local inventorySlotIlvl = {}
16551663
1656- local function UpdateInventorySlotIlvl (details )
1657- GetInvType ( details )
1664+ local function UpdateInventorySlotIlvl (cachedItems )
1665+ if not cachedItems then return end
16581666
1659- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1667+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1668+ GetInvType (details )
1669+
1670+ local slot = inventorySlots [details .invType ]
16601671
1661- local slot = inventorySlots [details .invType ]
1662- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1672+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1673+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1674+ end
1675+ end
16631676end
16641677
16651678Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1666- for i = 0 ,1 do
1667- local key = i == 0 and " bags" or " bank"
1679+ for _ ,key in pairs ({ " bags" , " bank" }) do
16681680 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1669- for index in pairs (data [key ]) do
1670- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1671- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1672- end
1681+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16731682 end
16741683end )
16751684
16761685Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1677- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1678- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1679- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1686+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16801687end )
16811688
16821689local function SlotItemLevelPatternCheck (details , text )
@@ -1686,11 +1693,9 @@ local function SlotItemLevelPatternCheck(details, text)
16861693 return false
16871694 end
16881695
1689- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1690- local ilvl = details .itemLevel
1691- local slot = inventorySlots [details .invType ]
1696+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1697+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16921698
1693- local slotilvl = inventorySlotIlvl [slot ]
16941699 if not slotilvl then
16951700 return false
16961701 end
@@ -1699,13 +1704,7 @@ local function SlotItemLevelPatternCheck(details, text)
16991704 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
17001705 end
17011706
1702- if op1 == " <" then
1703- return ilvl < slotilvl
1704- elseif op1 == " >" then
1705- return ilvl > slotilvl
1706- else
1707- return ilvl == slotilvl
1708- end
1707+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
17091708end
17101709
17111710local function GetAuctionValue (details )
@@ -1766,8 +1765,8 @@ end
17661765local patterns = {
17671766 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17681767 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1769- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1770- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1768+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1769+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17711770
17721771 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17731772 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments