@@ -1606,53 +1606,60 @@ local function ItemLevelRangePatternCheck(details, text)
16061606 return details .itemLevel and details .itemLevel >= tonumber (minText ) and details .itemLevel <= tonumber (maxText )
16071607end
16081608
1609+ local function CompareWithOperator (op , a , b )
1610+ if op == " <" then
1611+ return a < b
1612+ elseif op == " >" then
1613+ return a > b
1614+ elseif op == " <=" then
1615+ return a <= b
1616+ elseif op == " >=" then
1617+ return a >= b
1618+ else
1619+ return a == b
1620+ end
1621+ end
1622+
16091623local function AvgItemLevelPatternCheck (details , text )
16101624 if GetItemLevel (details ) == false then
16111625 return false
16121626 end
16131627
1614- local op1 , op2 , diff = text :match (" ^([<>=] ?)avgilvl([+-]?)(%d*)$" )
1628+ local op1 , op2 , diff = text :match (" ^([><]?= ?)avgilvl([+-]?)(%d*)$" )
16151629 local avgIlvl = floor (GetAverageItemLevel () + 0.5 )
16161630
16171631 if tonumber (diff ) then
16181632 avgIlvl = avgIlvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16191633 end
16201634
1621- if op1 == " <" then
1622- return details .itemLevel < avgIlvl
1623- elseif op1 == " >" then
1624- return details .itemLevel > avgIlvl
1625- else
1626- return details .itemLevel == avgIlvl
1627- end
1635+ return CompareWithOperator (op1 , details .itemLevel , avgIlvl )
16281636end
16291637
16301638local inventorySlotIlvl = {}
16311639
1632- local function UpdateInventorySlotIlvl (details )
1633- GetInvType ( details )
1640+ local function UpdateInventorySlotIlvl (cachedItems )
1641+ if not cachedItems then return end
16341642
1635- if details .invType == " NONE" or GetItemLevel (details ) == false then return end
1643+ for _ ,details in pairs (Syndicator .Search .GetBaseInfoFromList (cachedItems )) do
1644+ GetInvType (details )
1645+
1646+ local slot = inventorySlots [details .invType ]
16361647
1637- local slot = inventorySlots [details .invType ]
1638- inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1648+ if slot and GetItemLevel (details ) ~= false and details .itemLevel then
1649+ inventorySlotIlvl [slot ] = max (inventorySlotIlvl [slot ] or 0 , details .itemLevel )
1650+ end
1651+ end
16391652end
16401653
16411654Syndicator .CallbackRegistry :RegisterCallback (" BagCacheUpdate" , function (_ , character , data )
1642- for i = 0 ,1 do
1643- local key = i == 0 and " bags" or " bank"
1655+ for _ ,key in pairs ({ " bags" , " bank" }) do
16441656 local inventory = SYNDICATOR_DATA .Characters [character ][key ]
1645- for index in pairs (data [key ]) do
1646- local list = Syndicator .Search .GetBaseInfoFromList (inventory [index + 1 ])
1647- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1648- end
1657+ for index in pairs (data [key ]) do UpdateInventorySlotIlvl (inventory [index + 1 ]) end
16491658 end
16501659end )
16511660
16521661Syndicator .CallbackRegistry :RegisterCallback (" EquippedCacheUpdate" , function (_ , character )
1653- local equipped = SYNDICATOR_DATA .Characters [character ].equipped
1654- local list = Syndicator .Search .GetBaseInfoFromList (equipped )
1655- for _ , details in pairs (list ) do UpdateInventorySlotIlvl (details ) end
1662+ UpdateInventorySlotIlvl (SYNDICATOR_DATA .Characters [character ].equipped )
16561663end )
16571664
16581665local function SlotItemLevelPatternCheck (details , text )
@@ -1662,11 +1669,9 @@ local function SlotItemLevelPatternCheck(details, text)
16621669 return false
16631670 end
16641671
1665- local op1 , op2 , diff = text :match (" ^([<>=]?)slotilvl([+-]?)(%d*)$" )
1666- local ilvl = details .itemLevel
1667- local slot = inventorySlots [details .invType ]
1672+ local op1 , op2 , diff = text :match (" ^([><]?=?)slotilvl([+-]?)(%d*)$" )
1673+ local slotilvl = inventorySlotIlvl [inventorySlots [details .invType ]]
16681674
1669- local slotilvl = inventorySlotIlvl [slot ]
16701675 if not slotilvl then
16711676 return false
16721677 end
@@ -1675,13 +1680,7 @@ local function SlotItemLevelPatternCheck(details, text)
16751680 slotilvl = slotilvl + tonumber (diff ) * (op2 == " -" and - 1 or 1 )
16761681 end
16771682
1678- if op1 == " <" then
1679- return ilvl < slotilvl
1680- elseif op1 == " >" then
1681- return ilvl > slotilvl
1682- else
1683- return ilvl == slotilvl
1684- end
1683+ return CompareWithOperator (op1 , details .itemLevel , slotilvl )
16851684end
16861685
16871686local function GetAuctionValue (details )
@@ -1742,8 +1741,8 @@ end
17421741local patterns = {
17431742 [" ^[><=]?%d+$" ] = ItemLevelPatternCheck ,
17441743 [" ^%d+%-%d+$" ] = ItemLevelRangePatternCheck ,
1745- [" ^[><=] ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1746- [" ^[><=] ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
1744+ [" ^[><]?= ?avgilvl[+-]?%d*$" ] = AvgItemLevelPatternCheck ,
1745+ [" ^[><]?= ?slotilvl[+-]?%d*$" ] = SlotItemLevelPatternCheck ,
17471746
17481747 [" ^[><=]?%d+[gsc]$" ] = AHValuePatternCheck ,
17491748 [" ^%d+[gsc]%-%d+[gsc]$" ] = AHValueRangePatternCheck ,
0 commit comments