@@ -1629,53 +1629,60 @@ local function ItemLevelRangePatternCheck(details, text)
16291629 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
16301630end
16311631
1632+ local function CompareWithOperator (op , a , b )
1633+ if op == " <" then
1634+ return a < b
1635+ elseif op == " >" then
1636+ return a > b
1637+ elseif op == " <=" then
1638+ return a <= b
1639+ elseif op == " >=" then
1640+ return a >= b
1641+ else
1642+ return a == b
1643+ end
1644+ end
1645+
16321646local function AvgItemLevelPatternCheck (details , text )
16331647 if GetItemLevel (details ) == false then
16341648 return false
16351649 end
16361650
1637- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1651+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16381652 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16391653
16401654 if tonumber (diff ) then
16411655 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16421656 end
16431657
1644- if op1 == " <" then
1645- return details .itemLevel < avgIlvl
1646- elseif op1 == " >" then
1647- return details .itemLevel > avgIlvl
1648- else
1649- return details .itemLevel == avgIlvl
1650- end
1658+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16511659end
16521660
16531661local inventorySlotIlvl = {}
16541662
1655- local function UpdateInventorySlotIlvl (details )
1656- GetInvType ( details )
1663+ local function UpdateInventorySlotIlvl (cachedItems )
1664+ if not cachedItems then return end
16571665
1658- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1666+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1667+ GetInvType (details )
1668+
1669+ local slot = inventorySlots [details .invType ]
16591670
1660- local slot = inventorySlots [details .invType ]
1661- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1671+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1672+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1673+ end
1674+ end
16621675end
16631676
16641677Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1665- for i = 0 ,1 do
1666- local key = i == 0 and " bags" or " bank"
1678+ for _ ,key in pairs ({ " bags" , " bank" }) do
16671679 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1668- for index in pairs (data [key ]) do
1669- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1670- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1671- end
1680+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16721681 end
16731682end )
16741683
16751684Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1676- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1677- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1678- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1685+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16791686end )
16801687
16811688local function SlotItemLevelPatternCheck (details , text )
@@ -1685,11 +1692,9 @@ local function SlotItemLevelPatternCheck(details, text)
16851692 return false
16861693 end
16871694
1688- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1689- local ilvl = details .itemLevel
1690- local slot = inventorySlots [details .invType ]
1695+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1696+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16911697
1692- local slotilvl = inventorySlotIlvl [slot ]
16931698 if not slotilvl then
16941699 return false
16951700 end
@@ -1698,13 +1703,7 @@ local function SlotItemLevelPatternCheck(details, text)
16981703 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16991704 end
17001705
1701- if op1 == " <" then
1702- return ilvl < slotilvl
1703- elseif op1 == " >" then
1704- return ilvl > slotilvl
1705- else
1706- return ilvl == slotilvl
1707- end
1706+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
17081707end
17091708
17101709local function GetAuctionValue (details )
@@ -1765,8 +1764,8 @@ end
17651764local patterns = {
17661765 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17671766 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1768- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1769- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1767+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1768+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17701769
17711770 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17721771 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments