From e72f2b03e84d269537b98d215ce6ad143024c41d Mon Sep 17 00:00:00 2001 From: Xruptor Date: Wed, 10 Aug 2016 11:25:21 -0400 Subject: [PATCH] Updated Guild Parsing for CrossRealm/BNet Support -Added Cross Realm / BNet support for guilds. You can now see items in guilds if XR/BNet is enabled. -Changed how the Guild names are displayed so they can include the realm information if XR/BNet is enabled. -Added XR/BNet support for guilds in the BagSync Search window. It will now properly scan the guilds across XR/BNET if it's enabled. -Fixed a bug in the BagSync search where @guild was not properly returning the items of the currently logged in characters guild bank. It should now work as intended. -Changed the BagSync addon header as it was super old already. The code has been reworked so many times now that it's not even closely related to the original code back in 2007, which was based off Tuller's Bagnon_Forever code. -Kept the credit towards Tuller cause he's awesome :) <3 Bagnon --- BagSync.lua | 63 ++++++++++++++++++++++++++++++++++++---------------- BagSync_Search.lua | 15 ++++++++----- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/BagSync.lua b/BagSync.lua index e64a633..46217dd 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -1,17 +1,9 @@ --[[ BagSync.lua - A item tracking addon similar to Bagnon_Forever (special thanks to Tuller). - Works with practically any Bag mod available, Bagnon not required. - - NOTE: Parts of this mod were inspired by code from Bagnon_Forever by Tuller. - - This project was originally done a long time ago when I used the default blizzard bags. I wanted something like what - was available in Bagnon for tracking items, but I didn't want to use Bagnon. So I decided to code one that works with - pretty much any inventory addon. - - It was intended to be a beta addon as I never really uploaded it to a interface website. Instead I used the - SVN of wowace to work on it. The last revision done on the old BagSync was r50203.11 (29 Sep 2007). - Note: This addon has been completely rewritten. + A item tracking addon that works with practically any bag addon available. + This addon has been heavily rewritten several times since it's creation back in 2007. + + This addon was inspired by Tuller and his Bagnon addon. (Thanks Tuller!) Author: Xruptor @@ -95,6 +87,10 @@ BagSync:SetScript('OnEvent', function(self, event, ...) end end) +function BagSync:Debug(...) + Debug(...) +end + if IsLoggedIn() then BagSync:PLAYER_LOGIN() else BagSync:RegisterEvent('PLAYER_LOGIN') end ---------------------- @@ -264,7 +260,7 @@ function BagSync:getFilteredDB() return xIndex end -function BagSync:getCharacterInfo(charName, charRealm) +function BagSync:getCharacterRealmInfo(charName, charRealm) local yName, yRealm = strsplit('^', charName) @@ -293,6 +289,32 @@ function BagSync:getCharacterInfo(charName, charRealm) return charName end +function BagSync:getGuildRealmInfo(guildName, guildRealm) + + --add Cross-Realm and BNet identifiers to Guilds not on same realm + if BagSyncOpt.enableBNetAccountItems then + if guildRealm and guildRealm ~= currentRealm then + if not crossRealmNames[guildRealm] then + guildName = guildName.." |cff3588ff[BNet-"..guildRealm.."]|r" + else + guildName = guildName.." |cffff7d0a[XR-"..guildRealm.."]|r" + end + else + guildName = guildName + end + elseif BagSyncOpt.enableCrossRealmsItems then + if guildRealm and guildRealm ~= currentRealm then + guildName = guildName.." |cffff7d0a[XR-"..guildRealm.."]|r" + else + guildName = guildName + end + else + --to cover our buttocks lol, JUST IN CASE + guildName = guildName + end + + return guildName +end ---------------------- -- Local -- ---------------------- @@ -648,7 +670,7 @@ function BagSync:ShowMoneyTooltip() for k, v in pairs(xDB) do if v.gold then - k = BagSync:getCharacterInfo(k, v.realm) + k = BagSync:getCharacterRealmInfo(k, v.realm) table.insert(usrData, { name=k, gold=v.gold } ) end end @@ -987,12 +1009,15 @@ local function AddItemToTooltip(frame, link) --workaround local guildN = v.guild or nil --check the guild bank if the character is in a guild - if BS_GD and guildN and BS_GD[guildN] then + if BagSyncGUILD_DB and guildN and BagSyncGUILD_DB[v.realm][guildN] then --check to see if this guild has already been done through this run (so we don't do it multiple times) - if not previousGuilds[guildN] then + --check for XR/B.Net support + local gName = BagSync:getGuildRealmInfo(guildN, v.realm) + + if not previousGuilds[gName] then --we only really need to see this information once per guild local tmpCount = 0 - for q, r in pairs(BS_GD[guildN]) do + for q, r in pairs(BagSyncGUILD_DB[v.realm][guildN]) do local dblink, dbcount = strsplit(',', r) if dblink and dblink == itemLink then allowList["guild"] = allowList["guild"] + (dbcount or 1) @@ -1000,7 +1025,7 @@ local function AddItemToTooltip(frame, link) --workaround grandTotal = grandTotal + (dbcount or 1) end end - previousGuilds[guildN] = tmpCount + previousGuilds[gName] = tmpCount end end end @@ -1010,7 +1035,7 @@ local function AddItemToTooltip(frame, link) --workaround infoString = CountsToInfoString(allowList) if infoString and infoString ~= '' then - k = BagSync:getCharacterInfo(k, v.realm) + k = BagSync:getCharacterRealmInfo(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 d07cd34..d59df67 100644 --- a/BagSync_Search.lua +++ b/BagSync_Search.lua @@ -239,18 +239,21 @@ local function DoSearch() if BagSyncOpt.enableGuild then local guildN = v.guild or nil - + --check the guild bank if the character is in a guild - if BagSyncGUILD_DB and guildN and BagSyncGUILD_DB[currentRealm][guildN] then + if BagSyncGUILD_DB and guildN and BagSyncGUILD_DB[v.realm][guildN] then --check to see if this guild has already been done through this run (so we don't do it multiple times) - if not previousGuilds[guildN] then + --check for XR/B.Net support + local gName = BagSync:getGuildRealmInfo(guildN, v.realm) + + if not previousGuilds[gName] then --we only really need to see this information once per guild - for q, r in pairs(BagSyncGUILD_DB[currentRealm][guildN]) do + for q, r in pairs(BagSyncGUILD_DB[v.realm][guildN]) do local dblink, dbcount = strsplit(',', r) 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 yName == currentPlayer and not tempList[dblink] then + if playerSearch and string.sub(searchStr, 2) == "guild" and GetGuildInfo("player") and guildN == GetGuildInfo("player") and not tempList[dblink] then table.insert(searchTable, { name=dName, link=dItemLink, rarity=dRarity } ) tempList[dblink] = dName count = count + 1 @@ -263,7 +266,7 @@ local function DoSearch() end end end - previousGuilds[guildN] = true + previousGuilds[gName] = true end end end -- 1.7.9.5