Quantcast

Fixed an issue with the queue not recalculating when acquiring an intermediate item.

pschifferer [02-01-09 - 22:22]
Fixed an issue with the queue not recalculating when acquiring an intermediate item.
Added some error printing in some queue management functions.
Filename
CauldronMain.lua
CauldronMainUI.lua
CauldronQueue.lua
CauldronTradeskill.lua
CauldronUtil.lua
diff --git a/CauldronMain.lua b/CauldronMain.lua
index ebd32e6..9407781 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -230,7 +230,7 @@ function Cauldron:OnSkillUpdate()
 		Cauldron.db.realm.userdata[Cauldron.vars.playername].skills[CURRENT_TRADESKILL].window.selected = 0;

 		Cauldron:UpdateSkills();
-		CauldronQueue:CalculateAllRequiredItems();
+		CauldronQueue:CalculateAllRequiredItems(Cauldron.db.realm.userdata[Cauldron.vars.playername].queue);
 	end

 	self:Frame_Update();
@@ -419,7 +419,7 @@ function Cauldron:ProcessQueue()
 	self:debug("ProcessQueue enter");

 	if IsTradeSkillLinked() then
-		-- TODO: display error/warning
+		self:error("Can't process queue for linked tradeskill!");
 		return;
 	end

@@ -479,7 +479,7 @@ function Cauldron:ProcessItem(skillInfo, queueInfo, amount)
 	self:debug("ProcessItem enter");

 	if (not skillInfo) or (amount < 1) then
-		self:warn("Cauldron:ProcessItem: Missing skill info!");
+		self:error("ProcessItem: Missing skill info!");
 		return;
 	end

@@ -699,7 +699,6 @@ end
 							["defaultCategory"] = "<category>",
 							["reagents"] = {
 								{
-									["toonHas"] = <has>, -- how many of this reagent the character has
 									["name"] = "<reagent name>",
 									["numRequired"] = <required>, -- the number required of this reagent to complete one execution of the skill
 									["index"] = <reagent index>, -- the index of the reagent, for API call usage
diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index 97b6742..97c8811 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -323,7 +323,7 @@ function Cauldron:UpdateSkillList()
 					SetItemButtonTexture(reagentFrame, reagentInfo.icon);
 					reagentNameFrame:SetText(reagentInfo.name);

-					local playerReagentCount = reagentInfo.toonHas;
+					local playerReagentCount = GetItemCount(reagentInfo.link);

 					if playerReagentCount < reagentInfo.numRequired then
 						-- Grayout items
diff --git a/CauldronQueue.lua b/CauldronQueue.lua
index f748b60..4b6c20e 100644
--- a/CauldronQueue.lua
+++ b/CauldronQueue.lua
@@ -68,7 +68,7 @@ function CauldronQueue:GetItems(queue)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("GetItems: No queue found!");
 		return nil;
 	end

@@ -90,7 +90,7 @@ function CauldronQueue:GetIntermediates(queue)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("GetIntermediates: No queue found!");
 		return nil;
 	end

@@ -116,7 +116,7 @@ function CauldronQueue:GetReagents(queue)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("GetReagents: No queue found!");
 		return nil;
 	end

@@ -139,7 +139,7 @@ function CauldronQueue:AddItem(queue, skillInfo, amount, suppressCalc)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("AddItem: No queue found!");
 		return;
 	end

@@ -166,7 +166,8 @@ function CauldronQueue:CalculateAllRequiredItems(queue)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("CalculateAllRequiredItems: No queue found!");
+--		Cauldron:Print(debugstack(1));
 		return;
 	end

@@ -186,7 +187,7 @@ function CauldronQueue:CalculateRequiredItems(queue, skillInfo, amount)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("CalculateRequiredItems: No queue found!");
 		return;
 	end

@@ -251,7 +252,7 @@ function CauldronQueue:AddIntermediate(queue, reagent, amount)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("AddIntermediate: No queue found!");
 		return;
 	end

@@ -279,7 +280,7 @@ function CauldronQueue:AddReagent(queue, reagent, amount, tradeskill)

 	-- sanity checks
 	if not queue then
-		-- TODO: display error
+		Cauldron:error("AddReagent: No queue found!");
 		return;
 	end

@@ -305,7 +306,7 @@ function CauldronQueue:AdjustItemCount(queue, name, delta)

 	-- sanity checks
 	if not queue then
-		Cauldron:warn("CauldronQueue:AdjustItemCount: queue not found!");
+		Cauldron:error("AdjustItemCount: No queue found!");
 		return;
 	end

@@ -340,7 +341,7 @@ function CauldronQueue:RemoveItem(queue, itemName)

 	-- sanity checks
 	if (not queue) and (not itemName) then
-		-- TODO: display error
+		Cauldron:error("RemoveItem: No queue or item name found!");
 		return;
 	end

@@ -358,7 +359,7 @@ function CauldronQueue:IncreasePriority(queue, itemName, top)

 	-- sanity checks
 	if (not queue) and (not itemName) then
-		-- TODO: display error
+		Cauldron:error("IncreasePriority: No queue or item name found!");
 		return;
 	end

@@ -388,7 +389,7 @@ function CauldronQueue:DecreasePriority(queue, itemName, bottom)

 	-- sanity checks
 	if (not queue) and (not itemName) then
-		-- TODO: display error
+		Cauldron:error("DecreasePriority: No queue or item name found!");
 		return;
 	end

@@ -418,7 +419,7 @@ function CauldronQueue:ClearQueue(queue)

 	-- sanity checks
 	if not queue then
-		Cauldron:error("No queue found!");
+		Cauldron:error("ClearQueue: No queue found!");
 		return;
 	end

@@ -464,7 +465,7 @@ function CauldronQueue:GetIntermediateItem(queue, itemName)

 	-- sanity checks
 	if not queue then
-		Cauldron:error("No queue found!");
+		Cauldron:error("GetIntermediateItem: No queue found!");
 		return nil;
 	end

diff --git a/CauldronTradeskill.lua b/CauldronTradeskill.lua
index 78101c1..1ca1b64 100644
--- a/CauldronTradeskill.lua
+++ b/CauldronTradeskill.lua
@@ -126,7 +126,6 @@ function Cauldron:UpdateSkills()
 						['name'] = rname,
 						['icon'] = rtex,
 						['numRequired'] = rcount,
-						['toonHas'] = hasCount,
 						['index'] = j,
 						['skillIndex'] = i,
 					});
@@ -301,7 +300,7 @@ function Cauldron:GetSkillList(playername, skillName)
 			-- check if the reagent count for any reagent is 0
 			for rname, rinfo in pairs(recipe.reagents) do
 				-- check possession count
-				if rinfo.toonHas == 0 then
+				if GetItemCount(rname) == 0 then
 --					if Cauldron:GetAltReagentCount(rinfo) == 0 then
 						add = false;
 --					end
@@ -480,7 +479,7 @@ function Cauldron:GetReagentsForSkill(skillInfo)
 			local link = GetTradeSkillReagentItemLink(skillInfo.index, i);

 			local r = {
-				["toonHas"] = GetItemCount(link),
+--				["toonHas"] = GetItemCount(link),
 				["name"] = name,
 				["numRequired"] = count,
 				["skillIndex"] = skillInfo.index,
@@ -522,7 +521,7 @@ function Cauldron:GetReagentsForSkill(skillInfo)
 			local name, link, _, _, _, _, _, _, _, icon = GetItemInfo(id);

 			local r = {
-				["toonHas"] = GetItemCount(id),
+--				["toonHas"] = GetItemCount(id),
 				["name"] = name,
 				["numRequired"] = tonumber(numRequired),
 				["skillIndex"] = skillInfo.index,
diff --git a/CauldronUtil.lua b/CauldronUtil.lua
index b73def0..1f6f5cc 100644
--- a/CauldronUtil.lua
+++ b/CauldronUtil.lua
@@ -33,34 +33,16 @@ function Cauldron:ReagentCount(reagent)

 	-- sanity checks
 	if not reagent then
-		-- TODO: display error
+		self:error("No reagent specified for count!");
 		return count;
 	end

 	count.has = GetItemCount(reagent, false);
 	count.bank = GetItemCount(reagent, true) - count.has;

---[[
-	-- TODO: find in banks, on alts, etc.
-	if BankItems_SelfCache then
-		-- TODO
-		count.bank = BankItems_SelfCache[reagent].bank;
-		count.mail = BankItems_SelfCache[reagent].mail;
-	end
-
-	if BankItems_GuildCache then
---		count.guildBank = BankItems_GuildCache[reagent].
-	end
---]]
-
 	return count;
 end

-function Cauldron:ScanForItem(name)
-	-- look through bags
-
-end
-
 function Cauldron:SkillContainsText(recipe, text)

 	-- sanity checks