From 7a1720d916595cbf2333ecc421a22aa22eea2bfb Mon Sep 17 00:00:00 2001 From: Xruptor Date: Fri, 29 Jul 2016 10:33:03 -0400 Subject: [PATCH] Added Cross-Realm / BNet support to Search Window -Slowly but surely. Had to change a local function to global for obvious reasons. -The @ commands only still work for the current logged in character. Such as @bank or @void etc... --- BagSync.lua | 45 +++++++++++++++++++++++---------------------- BagSync_Search.lua | 9 ++++++--- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/BagSync.lua b/BagSync.lua index 22a48ba..56abffb 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -236,7 +236,7 @@ function BagSync:FixDB_Data(onlyChkGuild) end end -local function getFilteredDB() +function BagSync:getFilteredDB() local xIndex = {} @@ -264,23 +264,7 @@ local function getFilteredDB() return xIndex end ----------------------- --- Local -- ----------------------- - -local function doRegularTradeSkill(numIndex, dbIdx) - local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(numIndex) - if name and skillLevel then - BS_CD[dbIdx] = format('%s,%s', name, skillLevel) - end -end - -local function ToShortLink(link) - if not link then return nil end - return link:match("item:(%d+):") or nil -end - -local function getCharacterInfo(charName, charRealm) +function BagSync:getCharacterInfo(charName, charRealm) local yName, yRealm = strsplit('^', charName) @@ -310,6 +294,23 @@ local function getCharacterInfo(charName, charRealm) end ---------------------- +-- Local -- +---------------------- + +local function doRegularTradeSkill(numIndex, dbIdx) + local name, icon, skillLevel, maxSkillLevel, numAbilities, spelloffset, skillLine, skillModifier = GetProfessionInfo(numIndex) + if name and skillLevel then + BS_CD[dbIdx] = format('%s,%s', name, skillLevel) + end +end + +local function ToShortLink(link) + if not link then return nil end + return link:match("item:(%d+):") or nil +end + + +---------------------- -- Bag Functions -- ---------------------- @@ -643,11 +644,11 @@ function BagSync:ShowMoneyTooltip() tooltip:AddLine(" ") --loop through our characters - local xDB = getFilteredDB() + local xDB = BagSync:getFilteredDB() for k, v in pairs(xDB) do if v.gold then - k = getCharacterInfo(k, v.realm) + k = BagSync:getCharacterInfo(k, v.realm) table.insert(usrData, { name=k, gold=v.gold } ) end end @@ -960,7 +961,7 @@ local function AddItemToTooltip(frame, link) --workaround local grandTotal = 0 local first = true - local xDB = getFilteredDB() + local xDB = BagSync:getFilteredDB() --loop through our characters --k = player, v = stored data for player @@ -1037,7 +1038,7 @@ local function AddItemToTooltip(frame, link) --workaround frame:AddDoubleLine(" ", " ") end - k = getCharacterInfo(k, v.realm) + k = BagSync:getCharacterInfo(k, v.realm) table.insert(lastDisplayed, getNameColor(k or 'Unknown', pClass).."@"..(infoString or 'unknown')) end diff --git a/BagSync_Search.lua b/BagSync_Search.lua index b98fb56..d07cd34 100644 --- a/BagSync_Search.lua +++ b/BagSync_Search.lua @@ -192,11 +192,14 @@ local function DoSearch() if string.len(searchStr) > 1 and string.find(searchStr, "@") and allowList[string.sub(searchStr, 2)] ~= nil then playerSearch = true end + local xDB = BagSync:getFilteredDB() + --loop through our characters --k = player, v = stored data for player - for k, v in pairs(BagSyncDB[currentRealm]) do + for k, v in pairs(xDB) do local pFaction = v.faction or playerFaction --just in case ;) if we dont know the faction yet display it anyways + local yName, yRealm = strsplit('^', k) --check if we should show both factions or not if BagSyncOpt.enableFaction or pFaction == playerFaction then @@ -216,7 +219,7 @@ local function DoSearch() local dName, dItemLink, dRarity = GetItemInfo(dblink) if dName and dItemLink then --are we checking in our bank,void, etc? - if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) ~= "guild" and k == currentPlayer and not tempList[dblink] then + if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) ~= "guild" and yName == currentPlayer and not tempList[dblink] then table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) tempList[dblink] = dName count = count + 1 @@ -247,7 +250,7 @@ local function DoSearch() if dblink then local dName, dItemLink, dRarity = GetItemInfo(dblink) if dName then - if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) == "guild" and k == currentPlayer and not tempList[dblink] then + if playerSearch and string.sub(searchStr, 2) == q and string.sub(searchStr, 2) == "guild" and yName == currentPlayer and not tempList[dblink] then table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) tempList[dblink] = dName count = count + 1 -- 1.7.9.5