Quantcast

* adjusted unusable gear table. added new "relic" class

ckaotik [10-31-10 - 13:11]
* adjusted unusable gear table. added new "relic" class
* adjusted GetBagSlots() to only consider general bags
* fixed error when scanning professions
Filename
constants.lua
helper.lua
diff --git a/constants.lua b/constants.lua
index 20e78cd..1482ce2 100644
--- a/constants.lua
+++ b/constants.lua
@@ -122,16 +122,15 @@ BrokerGarbage.tradeSkills = {

 local armorTypes = { GetAuctionItemSubClasses(2) }
 local weaponTypes = { GetAuctionItemSubClasses(1) }
-local ammoTypes = { GetAuctionItemSubClasses(7) }
 BrokerGarbage.usableByClass = {
--- ------------- TODO ---------------------------
 	["DEATHKNIGHT"] = {
 		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
 		[armorTypes[5]] = true,		-- plate
-		[armorTypes[10]] = true,	-- seal
+		[armorTypes[10]] = true,	-- seal [old]
+		[armorTypes[11]] = true,	-- relic

 		[weaponTypes[1]] = true,	-- 1H axes
 		[weaponTypes[2]] = true,	-- 2H axes
@@ -147,7 +146,8 @@ BrokerGarbage.usableByClass = {
 		[armorTypes[1]] = true,		-- misc, e.g. tabards
 		[armorTypes[2]] = true,		-- cloth
 		[armorTypes[3]] = true,		-- leather
-		[armorTypes[8]] = true,		-- relic
+		[armorTypes[8]] = true,		-- relic [old]
+		[armorTypes[11]] = true,	-- relic

 		[weaponTypes[5]] = true,	-- 1H maces
 		[weaponTypes[6]] = true,	-- 2H maces
@@ -177,9 +177,6 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[13]] = true,	-- daggers
 		[weaponTypes[15]] = true,	-- crossbows
 		[weaponTypes[17]] = true,	-- fishing rod
-
-		[ammoTypes[1]] = true,		-- arrow
-		[ammoTypes[2]] = true,		-- bullet
 	},
 	["MAGE"] = {
 		[armorTypes[1]] = true,		-- misc, e.g. tabards
@@ -199,7 +196,8 @@ BrokerGarbage.usableByClass = {
 		[armorTypes[4]] = true,		-- mail
 		[armorTypes[5]] = true,		-- plate
 		[armorTypes[6]] = true,		-- shields
-		[armorTypes[7]] = true,		-- librams
+		[armorTypes[7]] = true,		-- librams [old]
+		[armorTypes[11]] = true,	-- relic

 		[weaponTypes[1]] = true,	-- 1H axes
 		[weaponTypes[2]] = true,	-- 2H axes
@@ -238,9 +236,6 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[14]] = true,	-- thrown weapons
 		[weaponTypes[15]] = true,	-- crossbows
 		[weaponTypes[17]] = true,	-- fishing rod
-
-		[ammoTypes[1]] = true,		-- arrow
-		[ammoTypes[2]] = true,		-- bullet
 	},
 	["SHAMAN"] = {
 		[armorTypes[1]] = true,		-- misc, e.g. tabards
@@ -248,7 +243,8 @@ BrokerGarbage.usableByClass = {
 		[armorTypes[3]] = true,		-- leather
 		[armorTypes[4]] = true,		-- mail
 		[armorTypes[6]] = true,		-- shields
-		[armorTypes[9]] = true,		-- totems
+		[armorTypes[9]] = true,		-- totems [old]
+		[armorTypes[11]] = true,	-- relic

 		[weaponTypes[1]] = true,	-- 1H axes
 		[weaponTypes[2]] = true,	-- 2H axes
@@ -295,9 +291,6 @@ BrokerGarbage.usableByClass = {
 		[weaponTypes[14]] = true,	-- thrown weapons
 		[weaponTypes[15]] = true,	-- crossbows
 		[weaponTypes[17]] = true,	-- fishing rod
-
-		[ammoTypes[1]] = true,		-- arrow
-		[ammoTypes[2]] = true,		-- bullet
 	},
 }

diff --git a/helper.lua b/helper.lua
index bdf275c..f639887 100644
--- a/helper.lua
+++ b/helper.lua
@@ -341,13 +341,13 @@ function BrokerGarbage:GetProfessionSkill(skill)
 	end

 	local rank, maxRank
-	for i = 1, 6 do
-		local profession = select(i, GetProfessions())
-		local pName, _, pRank, pMaxRank = profession and GetProfessionInfo(profession)
-		if name and name == skill then
+	local professions = { GetProfessions() }
+	for _, profession in ipairs(professions) do
+		local pName, _, pRank, pMaxRank = GetProfessionInfo(profession)
+		if pName and pName == skill then
 			rank = pRank
 			maxRank = pMaxRank
-			break;
+			break
 		end
 	end
 	return rank, maxRank
@@ -433,12 +433,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

 	local _, itemLink, quality, _, _, _, subClass, stackSize, invType, _, value = GetItemInfo(itemID)
-	BrokerGarbage:Debug("updating cache", itemID)
-	-- weird ...
+	local family = GetItemFamily(itemID)
 	if not quality then
 		BrokerGarbage:Debug("Could not retrieve quality information for "..(itemID or "<none>").." ("..(itemLink or "")..")")
 		return nil
@@ -562,6 +562,7 @@ function BrokerGarbage:UpdateCache(itemID)
 		BrokerGarbage.itemsCache[itemID] = {
 			classification = class,
 			quality = quality,
+			family = family,
 			value = value or 0,
 			limit = limit,
 			stackSize = stackSize,
@@ -570,6 +571,7 @@ function BrokerGarbage:UpdateCache(itemID)
 	else
 		BrokerGarbage.itemsCache[itemID].classification = class
 		BrokerGarbage.itemsCache[itemID].quality = quality
+		BrokerGarbage.itemsCache[itemID].family = family
 		BrokerGarbage.itemsCache[itemID].value = value or 0
 		BrokerGarbage.itemsCache[itemID].limit = limit
 		BrokerGarbage.itemsCache[itemID].stackSize = stackSize
@@ -586,7 +588,7 @@ function BrokerGarbage:GetCached(itemID)
 end

 -- returns total bag slots and free bag slots of your whole inventory
-function BrokerGarbage:GetBagSlots()
+--[[function BrokerGarbage:GetBagSlots()
 	local total, free = 0, 0
 	local num

@@ -599,6 +601,20 @@ function BrokerGarbage:GetBagSlots()
 	end

 	return total, free
+end]]
+
+function BrokerGarbage:GetBagSlots()
+	local numSlots, freeSlots = 0, 0
+
+	for i = 0, 4 do
+		numSlots = numSlots + (GetContainerNumSlots(i) or 0)
+		emptySlots, bagType = GetContainerNumFreeSlots(i)
+
+		if bagType and bagType == 0 then
+			freeSlots = freeSlots + emptySlots
+		end
+	end
+	return numSlots, freeSlots
 end

 -- formats money int values, depending on settings