C_AuctionHouse.ReplicateItems

From Warcraft Wiki
Jump to navigation Jump to search

Queries all auctions listed on the Auction House.

C_AuctionHouse.ReplicateItems()

Details

  • There's a 15 min account-wide throttle between each successful C_AuctionHouse.ReplicateItems() call, which triggers REPLICATE_ITEM_LIST_UPDATE.
  • Afterwards item information can be queried with C_AuctionHouse.GetReplicateItemInfo() which accepts an index from 0 up to C_AuctionHouse.GetNumReplicateItems()-1
  • REPLICATE_ITEM_LIST_UPDATE will also fire for each auction item that was cached from the server after calling C_AuctionHouse.GetReplicateItemInfo()
  • This disconnected clients on busy servers with more than 80k auctions, even with throttling.[1] But was hotfixed during patch 9.0.2 to not include player names anymore.
  • As of 2022-12-10, there seems to be a limit on how many REPLICATE_ITEM_LIST_UPDATE fire per frame, about 2000. Hence, if more C_AuctionHouse.GetReplicateItemInfo() calls are made recently, they'll be ignored or cause unnecessary slowdowns.

Example

Attempts to query the auction house when opened and loads any uncached items from the server.

local initialQuery
local auctions = {}
 
local function ScanAuctions()
	local beginTime = debugprofilestop()
	local continuables = {}
	wipe(auctions)
	for i = 0, C_AuctionHouse.GetNumReplicateItems()-1 do
		auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
		if not auctions[i][18] then -- hasAllInfo
			local item = Item:CreateFromItemID(auctions[i][17]) -- itemID
			continuables[item] = true

			item:ContinueOnItemLoad(function()
				auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
				continuables[item] = nil
				if not next(continuables) then
					print(format("Scanned %d auctions in %d milliseconds", #auctions+1, debugprofilestop()-beginTime))
					-- do something with `auctions` or fire some callback
				end
			end)
		end
	end
end

local function OnEvent(self, event)
	if event == "AUCTION_HOUSE_SHOW" then
		C_AuctionHouse.ReplicateItems()
		initialQuery = true
	elseif event == "REPLICATE_ITEM_LIST_UPDATE" then
		if initialQuery then
			ScanAuctions()
			initialQuery = false
		end
	end
end

local f = CreateFrame("Frame")
f:RegisterEvent("AUCTION_HOUSE_SHOW")
f:RegisterEvent("REPLICATE_ITEM_LIST_UPDATE")
f:SetScript("OnEvent", OnEvent)
> Scanned 81338 auctions in 2644 milliseconds

Patch changes

Shadowlands Patch 9.0.2 (2020-11-17): Hotfixed owner and ownerFullName to always return nil (except for your own auctions) as that seemed to be the cause of disconnects.
Battle for Azeroth Patch 8.3.0 (2020-01-14): Added. Replaces performing a "getall" QueryAuctionItems()[2]

See also

References

 
  1. ^ plusmouse 2020-12-06. Remove C_AuctionHouse.ReplicateItems scan #928.
  2. ^ Deprecated_8_3_0.lua, patch 8.3.0, near line 13, archived at Townlong-Yak