View Single Post
05-21-20, 07:21 AM   #14
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Originally Posted by Xrystal View Post
Ah .. I see .. Replicate_Item_List_Update hangs the game and causes you to crash out .. Trying another angle.

I updated the wiki with an approach that caches items with ItemMixin:ContinueOnItemLoad()



https://wow.gamepedia.com/API_C_Auct...ReplicateItems
Lua Code:
  1. local initialQuery
  2. local auctions = {}
  3.  
  4. local function ScanAuctions()
  5.     local beginTime = debugprofilestop()
  6.     local continuables = {}
  7.     wipe(auctions)
  8.     for i = 0, C_AuctionHouse.GetNumReplicateItems()-1 do
  9.         auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
  10.         if not auctions[i][18] then -- hasAllInfo
  11.             local item = Item:CreateFromItemID(auctions[i][17]) -- itemID
  12.             continuables[item] = true
  13.  
  14.             item:ContinueOnItemLoad(function()
  15.                 auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
  16.                 continuables[item] = nil
  17.                 if not next(continuables) then
  18.                     print(format("Scanned %d items in %d milliseconds", #auctions+1, debugprofilestop()-beginTime))
  19.                 end
  20.             end)
  21.         end
  22.     end
  23. end
  24.  
  25. local function OnEvent(self, event)
  26.     if event == "AUCTION_HOUSE_SHOW" then
  27.         C_AuctionHouse.ReplicateItems()
  28.         initialQuery = true
  29.     elseif event == "REPLICATE_ITEM_LIST_UPDATE" then
  30.         if initialQuery then
  31.             ScanAuctions()
  32.             initialQuery = false
  33.         end
  34.     end
  35. end
  36.  
  37. local f = CreateFrame("Frame")
  38. f:RegisterEvent("AUCTION_HOUSE_SHOW")
  39. f:RegisterEvent("REPLICATE_ITEM_LIST_UPDATE")
  40. f:SetScript("OnEvent", OnEvent)
  Reply With Quote