Quantcast

The new GetItemInfo() is annoying. Just a little ...

ckaotik [11-28-10 - 16:05]
The new GetItemInfo() is annoying. Just a little ...
Filename
core.lua
helper.lua
diff --git a/core.lua b/core.lua
index cd6ecd9..335753d 100644
--- a/core.lua
+++ b/core.lua
@@ -382,7 +382,10 @@ end

 -- returns which of the items values is the highest (value, type)
 function BrokerGarbage:GetSingleItemValue(item)
-	local hasData, itemLink, itemQuality, itemLevel, _, _, _, _, _, _, vendorPrice = item and GetItemInfo(item) or nil
+	local hasData = item and GetItemInfo(item) or nil
+	BrokerGarbage:Debug("GetSingleItemValue("..(item or "?")..")", hasData)
+
+	local hasData, itemLink, itemQuality, itemLevel, vendorPrice = GetItemInfo(item)
 	local itemID = itemLink and BrokerGarbage:GetItemID(itemLink) or nil

 	if not hasData or not itemID then		-- invalid argument
@@ -392,12 +395,13 @@ function BrokerGarbage:GetSingleItemValue(item)

 	-- ignore AH prices for gray items
     if not itemQuality or itemQuality == 0 then
-        return vendorPrice, BrokerGarbage.VENDOR
+        return vendorPrice, vendorPrice and BrokerGarbage.VENDOR
     end

     local auctionPrice, disenchantPrice, source
 	local canDE = BrokerGarbage:CanDisenchant(itemLink)

+	BrokerGarbage.auctionAddon = nil
     -- calculate auction value
     if IsAddOnLoaded("Auctionator") then
         BrokerGarbage.auctionAddon = "Auctionator"
@@ -486,6 +490,8 @@ function BrokerGarbage:GetSingleItemValue(item)
         disenchantPrice = (canDE and not disenchantPrice and GetDisenchantValue) and GetDisenchantValue(itemLink) or nil
     end

+	BrokerGarbage:Print("AuctionAddon: "..(BrokerGarbage.auctionAddon or "?"))
+
     -- simply return the highest value price
     local maximum = math.max((disenchantPrice or 0), (auctionPrice or 0), (vendorPrice or 0))
     if vendorPrice and maximum == vendorPrice then
diff --git a/helper.lua b/helper.lua
index dae746a..a385454 100644
--- a/helper.lua
+++ b/helper.lua
@@ -462,13 +462,12 @@ end

 -- gets an item's classification and saves it to the item cache
 function BrokerGarbage:UpdateCache(itemID)
-	BrokerGarbage:Debug("updating cache", itemID)
 	if not itemID then return nil end
 	local class, temp, limit
-
+	-- TODO: maybe a second call to getiteminfo is needed?
 	local hasData, itemLink, quality, _, _, _, subClass, stackSize, invType, _, value = GetItemInfo(itemID)
 	local family = GetItemFamily(itemID)
-	if not hasData or not itemLink or not quality) then
+	if not hasData or not itemLink or not quality then
 		BrokerGarbage:Debug("Could not retrieve quality information for "..(itemID or "<none>").." ("..(itemLink or "")..")")
 		return nil
 	end