Browse Source

fix gather mail tasks

dev
Jørgen Lien Sellæg 4 months ago
parent
commit
639d6d8744
  1. 2
      TradeSkillMaster/TradeSkillMaster.toc
  2. 4
      TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc
  3. 21
      TradeSkillMaster_Crafting/Modules/CraftingGUI.lua
  4. 14
      TradeSkillMaster_Crafting/Modules/Gather.lua
  5. 34
      TradeSkillMaster_Crafting/Modules/Inventory.lua

2
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

4
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

21
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"]

14
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)

34
TradeSkillMaster_Crafting/Modules/Inventory.lua

@ -111,6 +111,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
local sources = {}
@ -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

Loading…
Cancel
Save