View Single Post
01-25-20, 08:49 AM   #1
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 137
How to hook C_AuctionHouse.PostItem?

I have tried several methods to hook into C_AuctionHouse.PostItem. I want to fire off an event and function when this function is used. However, I don't want to indirectly taint the above function.

Code:
oldFunction = C_AuctionHouse.PostItem
C_AuctionHouse.PostItem = function newFunction() end
I don't want to use code above. That is just insecure and will cause taint issues.

I've used the following code but it does not track whether an item is posted or failed from being posted. It just triggers C_AuctionHouse.PostItem.
Code:
AuctionHouseFrame.CommoditiesSellFrame.PostButton:HookScript("OnClick", function () print('test') end)
I've tried the following.

Code:
hooksecurefunc(C_AuctionHouse, "PostItem", function() print('test') end)
Although it does not cause an error and does hook the function, the hook never properly fires off and I never see the test print. Mind you this is just an example.

Code:
hooksecurefunc(AuctionHouseFrame.CommoditiesSellFrame, "PostItem", function(self)
  print("CommoditiesSellFrame",self:CanPostItem())
end)
I've tried the above code and although it DOES hook properly and fire off when an item is posted. It never registers the item properly in the hook return and thus CanPostItem() is always false.

Here is the global Blizzard code dump I use.
(https://github.com/Gethe/wow-ui-sour...mSellFrame.lua)

There seems to be several mixins that use C_AuctionHouse.PostItem. That is why I just want to hook the parent C_AuctionHouse.PostItem function.

NOTE: I want to point out that the event "OWNED_AUCTIONS_UPDATED" does not fire when using the Sell Frame or Sell Tab on the Auction House. When an item is posted that event is never triggered for some reason. The only other event that seems to fire is "COMMODITY_SEARCH_RESULTS_UPDATED" but it's very unreliable.

So what would be the appropriate way to hook into C_AuctionHouse.PostItem so I can track when items are posted? Is there a better way with the new Auction House code?
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }

Last edited by Xruptor : 01-25-20 at 08:53 AM.
  Reply With Quote