@@ -1599,53 +1599,60 @@ local function ItemLevelRangePatternCheck(details, text)
15991599 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
16001600end
16011601
1602+ local function CompareWithOperator (op , a , b )
1603+ if op == " <" then
1604+ return a < b
1605+ elseif op == " >" then
1606+ return a > b
1607+ elseif op == " <=" then
1608+ return a <= b
1609+ elseif op == " >=" then
1610+ return a >= b
1611+ else
1612+ return a == b
1613+ end
1614+ end
1615+
16021616local function AvgItemLevelPatternCheck (details , text )
16031617 if GetItemLevel (details ) == false then
16041618 return false
16051619 end
16061620
1607- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1621+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16081622 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16091623
16101624 if tonumber (diff ) then
16111625 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16121626 end
16131627
1614- if op1 == " <" then
1615- return details .itemLevel < avgIlvl
1616- elseif op1 == " >" then
1617- return details .itemLevel > avgIlvl
1618- else
1619- return details .itemLevel == avgIlvl
1620- end
1628+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16211629end
16221630
16231631local inventorySlotIlvl = {}
16241632
1625- local function UpdateInventorySlotIlvl (details )
1626- GetInvType ( details )
1633+ local function UpdateInventorySlotIlvl (cachedItems )
1634+ if not cachedItems then return end
16271635
1628- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1636+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1637+ GetInvType (details )
1638+
1639+ local slot = inventorySlots [details .invType ]
16291640
1630- local slot = inventorySlots [details .invType ]
1631- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1641+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1642+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1643+ end
1644+ end
16321645end
16331646
16341647Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1635- for i = 0 ,1 do
1636- local key = i == 0 and " bags" or " bank"
1648+ for _ ,key in pairs ({ " bags" , " bank" }) do
16371649 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1638- for index in pairs (data [key ]) do
1639- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1640- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1641- end
1650+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16421651 end
16431652end )
16441653
16451654Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1646- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1647- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1648- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1655+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16491656end )
16501657
16511658local function SlotItemLevelPatternCheck (details , text )
@@ -1655,11 +1662,9 @@ local function SlotItemLevelPatternCheck(details, text)
16551662 return false
16561663 end
16571664
1658- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1659- local ilvl = details .itemLevel
1660- local slot = inventorySlots [details .invType ]
1665+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1666+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16611667
1662- local slotilvl = inventorySlotIlvl [slot ]
16631668 if not slotilvl then
16641669 return false
16651670 end
@@ -1668,13 +1673,7 @@ local function SlotItemLevelPatternCheck(details, text)
16681673 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16691674 end
16701675
1671- if op1 == " <" then
1672- return ilvl < slotilvl
1673- elseif op1 == " >" then
1674- return ilvl > slotilvl
1675- else
1676- return ilvl == slotilvl
1677- end
1676+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
16781677end
16791678
16801679local function GetAuctionValue (details )
@@ -1735,8 +1734,8 @@ end
17351734local patterns = {
17361735 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17371736 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1738- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1739- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1737+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1738+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17401739
17411740 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17421741 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments