diff --git a/LookingForGuildBrowseSort/LookingForGuildBrowseSort.lua b/LookingForGuildBrowseSort/LookingForGuildBrowseSort.lua index 54cc58f..0ae7d48 100755 --- a/LookingForGuildBrowseSort/LookingForGuildBrowseSort.lua +++ b/LookingForGuildBrowseSort/LookingForGuildBrowseSort.lua @@ -44,6 +44,7 @@ local GUILDSCORE = nil; local GUILDSCOREOLD = nil; local GUILDMEMBERCOUNTS = nil; local GUILDRANKS = nil; +local GUILDTRACKEDCUT = nil; local GUILDSORT = "SCORE"; @@ -62,6 +63,7 @@ local function MapReset() GUILDSCORE = nil; GUILDMEMBERCOUNTS = nil; GUILDRANKS = nil; + GUILDTRACKEDCUT = nil; end -- @@ -331,6 +333,15 @@ local function MapCollate(oG) GUILDMEMBERCOUNTS = {}; GUILDRANKS = {}; + GUILDTRACKEDCUT = {}; + local oTracked = {}; + do + local iTrackedMax, iTracked = #LookingForGuildBrowseSortListLocal.Tracker; + for iTracked = 1, iTrackedMax do + oTracked[LookingForGuildBrowseSortListLocal.Tracker[iTracked].Name] = iTracked; + end + end + iGetNumRecruitingGuildsCut = 0; local iG; for iG = 1, #oG do @@ -338,6 +349,7 @@ local function MapCollate(oG) if (iG <= 3) then iGetNumRecruitingGuildsCut = iGetNumRecruitingGuildsCut + iMax; end + for i = 1, iMax do tinsert(GUILDLIST, oG[iG][i].index); tinsert(GUILDNAMES, oG[iG][i].name); @@ -346,6 +358,14 @@ local function MapCollate(oG) tinsert(GUILDMEMBERCOUNTS, oG[iG][i].members); tinsert(GUILDRANKS, oG[iG][i].rank); + if (iG > 3) and (next(oTracked) ~= nil) then + -- if tracked, add to extra list + if (oTracked[oG[iG][i].name]) then + tinsert(GUILDTRACKEDCUT, #GUILDLIST); + end + + oTracked[oG[iG][i].name] = nil; + end end end @@ -532,7 +552,7 @@ local function MapCreateByScore() local oTracked = {}; local iTrackedMax, iTracked = #LookingForGuildBrowseSortListLocal.Tracker; for iTracked = 1, iTrackedMax do - oTracked[LookingForGuildBrowseSortListLocal.Tracker[iTracked].Name] = true; + oTracked[LookingForGuildBrowseSortListLocal.Tracker[iTracked].Name] = iTracked; end local oColor = GroupGuildnameColors[1]; @@ -564,6 +584,7 @@ local function MapCreateByScore() local bModified = MapCollate(oG); if (bModified) then + local nTrackedTotal = 0; for iG = 1, #oG do local nTracked = 0; local iMax, i, j = #oG[iG]; @@ -574,8 +595,9 @@ local function MapCreateByScore() end if ((iG ~= 5) or (#oG[5] > 0)) then - sTotals = sTotals .. (iMax > 0 and iMax or "zero"); + sTotals = sTotals .. (iMax > 0 and iMax or "none"); if (nTracked > 0) then + nTrackedTotal = nTrackedTotal + nTracked; sTotals = sTotals .. " (tracked: " .. nTracked .. ")"; end end @@ -599,7 +621,17 @@ local function MapCreateByScore() end end - DEFAULT_CHAT_FRAME:AddMessage(sTotals .. "|r"); + sTotals = sTotals .. "|r"; + if (LookingForGuildBrowseSortListLocal.Config.HideRedGrey) then + if ((type(GUILDTRACKEDCUT) == "table") and (#GUILDTRACKEDCUT > 0)) then + sTotals = sTotals .. " - red/grey tracked: " .. #GUILDTRACKEDCUT; + end + end + if (iTrackedMax > nTrackedTotal) then + sTotals = sTotals .. " - tracked unlisted: " .. (iTrackedMax - nTrackedTotal); + end + + DEFAULT_CHAT_FRAME:AddMessage(sTotals); end end @@ -608,7 +640,7 @@ function LFGBSPrivate.Map.Cmp.NAME(oA, oB) end function LFGBSPrivate.Map.Cmp.SIZE(oA, oB) - return oA.members < oB.members; + return (oA.members < oB.members) or (oA.members == oB.members) and (oA.rank < oB.rank); end function LFGBSPrivate.Map.Cmp.RANK(oA, oB) @@ -623,12 +655,16 @@ local function MapCreateByNameOrSizeOrRank(bName) local iRankMin = oMUST and oMUST.RANK or 0; for i = 1, iCnt do local name, rank, members, achieved, infotext, cached, requestPending = GetRecruitingGuildInfo_original(i); - if ((GUILDSORT == "SIZE") and (members < iSizeMin)) then - iG = 2; - elseif ((GUILDSORT == "RANK") and (rank < iRankMin)) then - iG = 2; - else - iG = 1; + + iG = 1; + if (GUILDSORT == "SIZE") then + if (members < iSizeMin) then + iG = 2; + end + elseif (GUILDSORT == "RANK") then + if (rank < iRankMin) then + iG = 2; + end end local fScore = 40000.001 * (iG - 1); @@ -672,7 +708,18 @@ local function MapDo(iNum) if (GUILDLIST == nil) then MapCreate(); end + if (GUILDLIST ~= nil) then + if (LookingForGuildBrowseSortListLocal.Config.HideRedGrey and (iGetNumRecruitingGuildsCut ~= nil)) then + if (iNum > iGetNumRecruitingGuildsCut) then + local iSub = iNum - iGetNumRecruitingGuildsCut; + if (type(GUILDTRACKEDCUT) == "table") and (iSub <= #GUILDTRACKEDCUT) then + iSub = GUILDTRACKEDCUT[iSub]; + return GUILDLIST[iSub]; + end + end + end + return GUILDLIST[iNum]; else return iNum; @@ -680,8 +727,13 @@ local function MapDo(iNum) end local function GetNumRecruitingGuilds_ordered() - if (iGetNumRecruitingGuildsCut and LookingForGuildBrowseSortListLocal.Config.HideRedGrey) then - return iGetNumRecruitingGuildsCut; + if (LookingForGuildBrowseSortListLocal.Config.HideRedGrey and (iGetNumRecruitingGuildsCut ~= nil)) then + local iTotal = iGetNumRecruitingGuildsCut or 0; + if (type(GUILDTRACKEDCUT) == "table") then + iTotal = iTotal + #GUILDTRACKEDCUT; + end + + return iTotal; end return GetNumRecruitingGuilds_original(); @@ -984,8 +1036,9 @@ function Cmd(sCmd, bSilent) DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'rank' allows you to define a minimum acceptable guild rank for top listing."); DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'findname' and 'findcomment' accept a search string and jump to the next guild name/comment containing that string"); DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'sort' allows you to choose a different way of sorting"); - DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'tracktoggle' toggles tracking status of the currently selected guild"); + DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'tracktoggle[full]' toggles tracking status of the currently selected guild (full generates more data)"); DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'tracklist' lists all currently tracked guilds and their max. actually seen size"); + DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'trackreset [<guild name>]' resets the data tracked from the given guild or all guilds if none given"); DEFAULT_CHAT_FRAME:AddMessage("[LFBGS] 'hideredgrey' toggles if the list of guilds (sorted by score) hides red/grey guilds (default: show all)"); end @@ -1479,20 +1532,32 @@ function Cmd(sCmd, bSilent) end if (args[1] == "trackreset") then + local sName; + if (args[2]) then + sName = args[2]; + local iSub = 3; + while (args[iSub]) do + sName = sName .. " " .. args[iSub]; + iSub = iSub + 1; + end + end + local oTracker = LookingForGuildBrowseSortListLocal.Tracker; local iMax, i = #oTracker; for i = 1, iMax do - oTracker[i].SeenCount = 0; - oTracker[i].SeenStat = nil; - oTracker[i].SeenStatLog = nil; - if (type(oTracker[i].Data) == "table") then - oTracker[i].Data = {}; - end + if ((sName == nil) or (oTracker[i].Name == sName)) then + oTracker[i].SeenCount = 0; + oTracker[i].SeenStat = nil; + oTracker[i].SeenStatLog = nil; + if (type(oTracker[i].Data) == "table") then + oTracker[i].Data = {}; + end - local k, v; - for k, v in pairs(oTracker[i]) do - if (strsub(k, 1, 7) == "SEENMAX") then - oTracker[i].k = nil; + local k, v; + for k, v in pairs(oTracker[i]) do + if (strsub(k, 1, 7) == "SEENMAX") then + oTracker[i].k = nil; + end end end end @@ -1697,7 +1762,7 @@ function LFGBSPrivate.TrackerFrame.OnUpdate(oFrame, iElapsed) FriendsFrame:UnregisterEvent("WHO_LIST_UPDATE"); SetWhoToUI(1); - DEFAULT_CHAT_FRAME:AddMessage("[LFGBS] TF::OU: Sent [" .. sWho .. "]"); + -- DEFAULT_CHAT_FRAME:AddMessage("[LFGBS] TF::OU: Sent [" .. sWho .. "]"); end else oFrame.At = iFrequency / 4; @@ -1814,7 +1879,13 @@ function LFGBSPrivate.TrackerFrame.OnEvent(oFrame, sEvent, arg1, ...) LookingForGuildBrowseSortList = {}; end - local sServer = GetCVar("RealmName"); + local sServer; + if (GetRealmName ~= nil) then + -- 5.4: realmname is no longer a global variable + sServer = GetRealmName(); + else + sServer = GetCVar("RealmName"); + end if (LookingForGuildBrowseSortList[sServer] == nil) then LookingForGuildBrowseSortList[sServer] = { Config = {} }; end