From 639d6d87441a6f366fb678979b51fcac5485b8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Lien=20Sell=C3=A6g?= Date: Thu, 15 Jan 2026 05:07:07 +0100 Subject: [PATCH] fix gather mail tasks --- TradeSkillMaster/TradeSkillMaster.toc | 2 +- .../TradeSkillMaster_AuctionDB.toc | 4 +-- .../Modules/CraftingGUI.lua | 21 ++++++++--- TradeSkillMaster_Crafting/Modules/Gather.lua | 14 +++++++- .../Modules/Inventory.lua | 36 +++++++++++-------- 5 files changed, 53 insertions(+), 24 deletions(-) diff --git a/TradeSkillMaster/TradeSkillMaster.toc b/TradeSkillMaster/TradeSkillMaster.toc index 20f7377..59efe3f 100644 --- a/TradeSkillMaster/TradeSkillMaster.toc +++ b/TradeSkillMaster/TradeSkillMaster.toc @@ -2,7 +2,7 @@ ## Title: |cff00fe00TradeSkillMaster: Revived|r ## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed. ## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors... -## Version: 2.3.41 +## Version: 2.3.44 ## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB ## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE ## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0 diff --git a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc index d38cf91..2ce3dfb 100644 --- a/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc +++ b/TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc @@ -2,10 +2,10 @@ ## Title: |cff00ff00TradeSkillMaster_AuctionDB|r ## Notes: Stores auction house data and calculates market prices. ## Author: Sapu94, Bart39 -## Version: 2.3.41 +## Version: 2.3.44 ## SavedVariables: AscensionTSM_AuctionDB ## Dependency: TradeSkillMaster -## X-Curse-Packaged-Version: 2.3.41 +## X-Curse-Packaged-Version: 2.3.44 ## X-Curse-Project-Name: TradeSkillMaster_AuctionDB ## X-Curse-Project-ID: tradeskillmaster_auctiondb ## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline diff --git a/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua b/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua index 645cc16..00da16c 100644 --- a/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua +++ b/TradeSkillMaster_Crafting/Modules/CraftingGUI.lua @@ -17,6 +17,17 @@ private.gather = {} private.shown = {} private.eventObj = nil +local function IsCrafterPlayer(crafter) + if not crafter then return false end + local player = UnitName("player") + if not player then return false end + if strlower(crafter) == strlower(player) then + return true + end + local baseName = strmatch(crafter, "^[^-]+") + return baseName and strlower(baseName) == strlower(player) or false +end + -- list of profession skills that do not have crafting. used by UpdateTradeSkills local invalidTrade = { ["Herbalism"] = true, @@ -2816,9 +2827,9 @@ function GUI:UpdateGathering() local crafterMail = TSMAPI:ModuleAPI("ItemTracker", "playermail", crafter) or {} for itemString, quantity in pairs(neededMats) do local need = quantity - (crafterBags[itemString] or 0) - if UnitName("player") ~= crafter then - need = need - (crafterMail[itemString] or 0) - end + if not IsCrafterPlayer(crafter) then + need = need - (crafterMail[itemString] or 0) + end if need > 0 then if next(sources) then for _, source in ipairs(sources) do @@ -2836,7 +2847,7 @@ function GUI:UpdateGathering() end if task.taskType == L["Mail Items"] or task.taskType == L["Collect Mail"] then availQty = min(need, taskQuantity) - elseif not crafter == UnitName("player") then + elseif not IsCrafterPlayer(crafter) then availQty = min(need, taskQuantity) - (playerBags[itemString] or 0) else availQty = min(need, taskQuantity) -- (crafterBags[itemString] or 0) @@ -2922,7 +2933,7 @@ function GUI:GatheringEventHandler(event) elseif event == "MAIL_SHOW" then private.currentSource = UnitName("player") local crafter = TSM.db.realm.gathering.crafter - if crafter and crafter == UnitName("player") then + if IsCrafterPlayer(crafter) then private.currentTask = L["Collect Mail"] else private.currentTask = L["Mail Items"] diff --git a/TradeSkillMaster_Crafting/Modules/Gather.lua b/TradeSkillMaster_Crafting/Modules/Gather.lua index 9f7e9c8..f6fb924 100644 --- a/TradeSkillMaster_Crafting/Modules/Gather.lua +++ b/TradeSkillMaster_Crafting/Modules/Gather.lua @@ -14,6 +14,17 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Crafting") -- loa local next = next local private = { shoppingItems = {} } +local function IsCrafterPlayer(crafter) + if not crafter then return false end + local player = UnitName("player") + if not player then return false end + if strlower(crafter) == strlower(player) then + return true + end + local baseName = strmatch(crafter, "^[^-]+") + return baseName and strlower(baseName) == strlower(player) or false +end + function Gather:BuyFromMerchant(neededMats) for i = 1, GetMerchantNumItems() do local itemString = TSMAPI:GetItemString(GetMerchantItemLink(i)) @@ -37,12 +48,13 @@ end function Gather:gatherItems(source, task) local items = TSM.db.realm.gathering.availableMats + local crafter = TSM.db.realm.gathering.crafter if source == L["Vendor"] then Gather:BuyFromMerchant(items) elseif source == UnitName("player") and (task == L["Visit Bank"] or task == L["Visit Guild Bank"]) then Gather:GatherBank(items) - elseif source == UnitName("player") and task == L["Collect Mail"] then + elseif source == UnitName("player") and (task == L["Collect Mail"] or (task == L["Mail Items"] and IsCrafterPlayer(crafter))) then TSMAPI:ModuleAPI("Mailing", "collectItems", items, Gather.PrintMsg) elseif source == UnitName("player") and task == L["Mail Items"] then Gather:MailItems(items) diff --git a/TradeSkillMaster_Crafting/Modules/Inventory.lua b/TradeSkillMaster_Crafting/Modules/Inventory.lua index 4fbce8b..c396689 100644 --- a/TradeSkillMaster_Crafting/Modules/Inventory.lua +++ b/TradeSkillMaster_Crafting/Modules/Inventory.lua @@ -110,6 +110,15 @@ return count end + + local function IsSamePlayer(a, b) + if not a or not b then return false end + local function Normalize(name) + local base = strmatch(name, "^[^-]+") or name + return strlower(base) + end + return Normalize(a) == Normalize(b) + end function Inventory:GetItemSources(crafter, neededMats) if not neededMats then return end @@ -161,7 +170,7 @@ -- add bags/bank/mail "tasks" for needed items of all non-ignored characters (always include crafter) for _, player in pairs(TSMAPI:ModuleAPI("ItemTracker", "playerlist") or {}) do - if player == crafter or not TSM.db.global.ignoreCharacters[player] then + if IsSamePlayer(player, crafter) or not TSM.db.global.ignoreCharacters[player] then local task = {} local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player) or {} local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player) or {} @@ -182,24 +191,21 @@ soulboundBagCount = GetItemCount(itemString) soulboundBankCount = GetItemCount(itemString, true) - soulboundBagCount end - if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) and shortItems[itemString] then - if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then - bankItems[itemString] = bank[itemString] or soulboundBankCount + local remainingNeed = shortItems[itemString] and shortItems[itemString] - (crafterMail[itemString] or 0) or 0 + if remainingNeed > 0 then + if (bank[itemString] or (soulboundBankCount and soulboundBankCount > 0)) then + bankItems[itemString] = min(bank[itemString] or soulboundBankCount, remainingNeed) end - end - if gbank[itemString] and shortItems[itemString] then - if shortItems[itemString] - (crafterMail[itemString] or 0) - (player ~= crafter and bags[itemString] or 0) > 0 then - gbankItems[itemString] = gbank[itemString] + if gbank[itemString] then + gbankItems[itemString] = min(gbank[itemString], remainingNeed) end end if mail[itemString] and shortItems[itemString] then mailItems[itemString] = mail[itemString] end - if bags[itemString] and shortItems[itemString] then - if player ~= crafter then - if shortItems[itemString] - (crafterMail[itemString] or 0) > 0 then - bagItems[itemString] = bags[itemString] - end + if bags[itemString] and shortItems[itemString] and not IsSamePlayer(player, crafter) then + if remainingNeed > 0 then + bagItems[itemString] = min(bags[itemString], remainingNeed) end end end @@ -223,7 +229,7 @@ tinsert(task, { taskType = L["Mail Items"], items = bagItems }) end if next(task) then - tinsert(sources, { sourceName = player, isCrafter = player == crafter, isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) + tinsert(sources, { sourceName = player, isCrafter = IsSamePlayer(player, crafter), isVendor = false, isAH = false, tasks = task, isCurrent = (player == UnitName("player")) }) end end end @@ -337,4 +343,4 @@ if itemString and not TSMAPI.DisenchantingData.notDisenchantable[itemString] and (iType == ARMOR or iType == WEAPON) then return true end - end \ No newline at end of file + end