Fixed the way the queue is adjusted when an item is crafted.
pschifferer [04-25-09 - 04:30]
Fixed the way the queue is adjusted when an item is crafted.
diff --git a/CauldronMain.lua b/CauldronMain.lua
index 3e7c667..eaf5c20 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -82,8 +82,8 @@ function Cauldron:OnInitialize()
desc = L["Sets or displays the logging level"],
type = 'select',
values = {
- ['normal'] = L["Normal logging of warnings and errors"],
- ['debug'] = L["Debug logging (very verbose)"],
+ normal = L["Normal logging of warnings and errors"],
+ debug = L["Debug logging (very verbose)"],
},
get = function() Cauldron:Print(Cauldron:GetLogLevel()); end,
set = function(l)
@@ -375,10 +375,11 @@ function Cauldron:OnBagUpdate(event, bagid)
-- check if the item acquired is in the intermediate list or shopping list
local items = Cauldron:GetItemDeltas(bagid);
+ self:debug("items="..tostring(items));
local recalc = false;
for item, itemCount in pairs(items) do
--@alpha@
- self:debug("OnBagUpdate: item="..tostring(item).."; itemCount="..itemCount);
+ self:debug("OnBagUpdate: item="..tostring(item).."; itemCount="..tostring(itemCount));
--@end-alpha@
if itemCount > 0 then
-- adjust shopping list
@@ -397,9 +398,11 @@ function Cauldron:OnBagUpdate(event, bagid)
end
-- adjust queue, but only if window is open
+ self:debug("adjust queue? item="..item);
if CauldronFrame:IsShown() then
+ self:debug("window is open; self.makingItem="..self.makingItem);
if self.makingItem == item then
- self:debug("OnBagUpdate: adjust queue for item: "..self.makingItem);
+ self:debug("OnBagUpdate: adjust queue for item: "..self.makingItem.."; itemCount="..itemCount);
CauldronQueue:AdjustItemCount(queue, item, -itemCount);
end
end
@@ -641,9 +644,7 @@ function Cauldron:CreateTradeSkillItem()
end
function Cauldron:ProcessQueue()
---@alpha@
self:debug("ProcessQueue enter");
---@end-alpha@
if IsTradeSkillLinked() then
self:error("Can't process queue for linked tradeskill!");
@@ -652,52 +653,34 @@ function Cauldron:ProcessQueue()
-- find intermediate items that need to be crafted
local intQueue = CauldronQueue:GetIntermediates(self.db.realm.userdata[self.vars.playername].queue);
---@alpha@
self:debug("ProcessQueue: intQueue="..#intQueue);
---@end-alpha@
local queueInfo = nil;
local skillInfo = nil;
if #intQueue > 0 then
---@alpha@
self:debug("ProcessQueue: processing intermediate queue items");
---@end-alpha@
queueInfo = intQueue[1];
---@alpha@
self:debug("ProcessQueue: queueInfo="..queueInfo.name);
---@end-alpha@
skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name);
---@alpha@
self:debug("ProcessQueue: skillInfo="..tostring(skillInfo));
---@end-alpha@
else
local queue = CauldronQueue:GetItems(self.db.realm.userdata[self.vars.playername].queue);
---@alpha@
self:debug("ProcessQueue: queue="..#queue);
---@end-alpha@
if #queue > 0 then
---@alpha@
self:debug("ProcessQueue: processing main queue items");
---@end-alpha@
queueInfo = queue[1];
---@alpha@
self:debug("ProcessQueue: queueInfo="..queueInfo.name);
---@end-alpha@
skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name);
---@alpha@
self:debug("ProcessQueue: skillInfo="..tostring(skillInfo));
---@end-alpha@
end
end
if queueInfo and skillInfo then
---@alpha@
self:debug("ProcessQueue: queueInfo="..queueInfo.name);
---@end-alpha@
if queueInfo.tradeskill ~= CURRENT_TRADESKILL then
local msg = string.format(L["Crafting %1$s requires the %2$s skill."], queueInfo.name, queueInfo.tradeskill);
@@ -705,9 +688,7 @@ function Cauldron:ProcessQueue()
return;
end
---@alpha@
self:debug("ProcessQueue: process item: "..queueInfo.name);
---@end-alpha@
Cauldron:ProcessItem(skillInfo, queueInfo, queueInfo.amount);
else
if not queueInfo then
@@ -718,16 +699,12 @@ function Cauldron:ProcessQueue()
end
end
---@alpha@
self:debug("ProcessQueue exit");
---@end-alpha@
end
function Cauldron:ProcessItem(skillInfo, queueInfo, amount)
---@alpha@
self:debug("ProcessItem enter");
---@end-alpha@
if (not skillInfo) or (amount < 1) then
self:error("ProcessItem: Missing skill info!");
@@ -737,13 +714,9 @@ function Cauldron:ProcessItem(skillInfo, queueInfo, amount)
if ((not PartialPlayTime()) and (not NoPlayTime())) then
-- record the item we're making
self.makingItem, _ = GetItemInfo(skillInfo.itemLink);
---@alpha@
self:debug("ProcessItem: self.makingItem="..self.makingItem);
---@end-alpha@
self.itemCurrentCount = GetItemCount(skillInfo.itemLink);
---@alpha@
self:debug("ProcessItem: self.itemCurrentCount="..self.itemCurrentCount);
---@end-alpha@
self.queueInfo = queueInfo;
-- tell the user what we're doing
@@ -755,9 +728,7 @@ function Cauldron:ProcessItem(skillInfo, queueInfo, amount)
-- TODO: notify player?
end
---@alpha@
self:debug("ProcessItem exit");
---@end-alpha@
end
function Cauldron:RemoveQueueItem(name)
diff --git a/CauldronQueue.lua b/CauldronQueue.lua
index 4b6c20e..6e3e300 100644
--- a/CauldronQueue.lua
+++ b/CauldronQueue.lua
@@ -310,15 +310,15 @@ function CauldronQueue:AdjustItemCount(queue, name, delta)
return;
end
- local item = queue.main[name];
---[[
+ local item; -- = queue.main[name];
for qName, qInfo in pairs(queue.main) do
- if name == qInfo.item then
+ local qItem = Cauldron:GetNameFromLink(qInfo.link);
+ if name == qItem then
item = qInfo;
break;
end
end
---]]
+
Cauldron:debug("AdjustItemCount: item="..tostring(item));
if item then
Cauldron:debug("AdjustItemCount: item.amount="..item.amount);