@@ -1598,53 +1598,60 @@ local function ItemLevelRangePatternCheck(details, text)
15981598 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
15991599end
16001600
1601+ local function CompareWithOperator (op , a , b )
1602+ if op == " <" then
1603+ return a < b
1604+ elseif op == " >" then
1605+ return a > b
1606+ elseif op == " <=" then
1607+ return a <= b
1608+ elseif op == " >=" then
1609+ return a >= b
1610+ else
1611+ return a == b
1612+ end
1613+ end
1614+
16011615local function AvgItemLevelPatternCheck (details , text )
16021616 if GetItemLevel (details ) == false then
16031617 return false
16041618 end
16051619
1606- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1620+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16071621 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16081622
16091623 if tonumber (diff ) then
16101624 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16111625 end
16121626
1613- if op1 == " <" then
1614- return details .itemLevel < avgIlvl
1615- elseif op1 == " >" then
1616- return details .itemLevel > avgIlvl
1617- else
1618- return details .itemLevel == avgIlvl
1619- end
1627+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16201628end
16211629
16221630local inventorySlotIlvl = {}
16231631
1624- local function UpdateInventorySlotIlvl (details )
1625- GetInvType ( details )
1632+ local function UpdateInventorySlotIlvl (cachedItems )
1633+ if not cachedItems then return end
16261634
1627- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1635+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1636+ GetInvType (details )
1637+
1638+ local slot = inventorySlots [details .invType ]
16281639
1629- local slot = inventorySlots [details .invType ]
1630- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1640+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1641+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1642+ end
1643+ end
16311644end
16321645
16331646Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1634- for i = 0 ,1 do
1635- local key = i == 0 and " bags" or " bank"
1647+ for _ ,key in pairs ({ " bags" , " bank" }) do
16361648 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1637- for index in pairs (data [key ]) do
1638- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1639- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1640- end
1649+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16411650 end
16421651end )
16431652
16441653Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1645- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1646- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1647- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1654+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16481655end )
16491656
16501657local function SlotItemLevelPatternCheck (details , text )
@@ -1654,11 +1661,9 @@ local function SlotItemLevelPatternCheck(details, text)
16541661 return false
16551662 end
16561663
1657- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1658- local ilvl = details .itemLevel
1659- local slot = inventorySlots [details .invType ]
1664+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1665+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16601666
1661- local slotilvl = inventorySlotIlvl [slot ]
16621667 if not slotilvl then
16631668 return false
16641669 end
@@ -1667,13 +1672,7 @@ local function SlotItemLevelPatternCheck(details, text)
16671672 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16681673 end
16691674
1670- if op1 == " <" then
1671- return ilvl < slotilvl
1672- elseif op1 == " >" then
1673- return ilvl > slotilvl
1674- else
1675- return ilvl == slotilvl
1676- end
1675+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
16771676end
16781677
16791678local function GetAuctionValue (details )
@@ -1734,8 +1733,8 @@ end
17341733local patterns = {
17351734 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17361735 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1737- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1738- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1736+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1737+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17391738
17401739 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17411740 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments