EmFor@0: --[[ EmFor@0: CensusPlus for World of Warcraft(tm). EmFor@0: EmFor@0: Copyright 2005 - 2007 Cooper Sellers and WarcraftRealms.com EmFor@0: EmFor@0: License: EmFor@0: This program is free software; you can redistribute it and/or EmFor@0: modify it under the terms of the GNU General Public License EmFor@0: as published by the Free Software Foundation; either version 2 EmFor@0: of the License, or (at your option) any later version. EmFor@0: EmFor@0: This program is distributed in the hope that it will be useful, EmFor@0: but WITHOUT ANY WARRANTY; without even the implied warranty of EmFor@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the EmFor@0: GNU General Public License for more details. EmFor@0: EmFor@0: You should have received a copy of the GNU General Public License EmFor@0: along with this program(see GLP.txt); if not, write to the Free Software EmFor@0: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. EmFor@0: ]] EmFor@0: EmFor@0: EmFor@0: ------------------------------------------------------------------------------------ EmFor@0: -- EmFor@0: -- CensusPlus EmFor@0: -- A WoW UI customization by Cooper Sellers EmFor@0: -- EmFor@0: -- EmFor@0: ------------------------------------------------------------------------------------ EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- EURO vs US localization problem workaround for common server names EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: local g_InterfaceVersion = 40000; EmFor@0: g_CensusPlusLocale = "N/A"; -- Must read either US or EU EmFor@0: g_CensusPlusTZOffset = -999; EmFor@0: local g_LocaleSet = false; EmFor@0: local g_TZWarningSent = false; EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@13: --rm EmFor@13: -- guild to search (Extra button 'Take guild') EmFor@13: --local CensusPlus_MYGUILD = "The Last Journey"; EmFor@13: --local CensusPlus_MYGUILD = "Worgengrauen"; EmFor@13: CensusPlus_MYGUILD = "Flieht Ihr Narren"; EmFor@13: --------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Constants EmFor@13: local CensusPlus_VERSION = "5.0.2"; -- version EmFor@0: local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars EmFor@13: local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI? EmFor@13: local MAX_CHARACTER_LEVEL = 85; -- Maximum level a PC can attain EmFor@0: --rm EmFor@0: local MAX_LEVEL_DISPLAY = 255; -- Maximum level a PC can attain EmFor@13: local MAX_WHO_RESULTS = 49; -- Maximum number of who results the server will return EmFor@0: CensusPlus_GUILDBUTTONSIZEY = 16; EmFor@13: local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages EmFor@0: local CP_MAX_TIMES = 50; EmFor@0: EmFor@13: local g_ServerPrefix = ""; -- formerly only US VERSION EmFor@13: --local g_ServerPrefix = "EU-"; -- EU VERSION automatically EmFor@0: EmFor@0: local wholib EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Print a string to the chat frame EmFor@0: -- msg - message to print EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Msg(msg) EmFor@0: if( msg == nil ) then EmFor@0: msg = " NIL "; EmFor@0: end EmFor@0: ChatFrame1:AddMessage("Census+: "..msg, 1.0, 1.0, 0.5); EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_WhoMsg(msg) EmFor@0: if( msg == nil ) then EmFor@0: msg = " NIL "; EmFor@0: end EmFor@0: ChatFrame1:AddMessage("Census+ Who: "..msg, 0.8, 0.8, 0.1); EmFor@0: end EmFor@0: EmFor@0: local function CensusPlus_Msg2( msg ) EmFor@0: if( msg == nil ) then EmFor@0: msg = " NIL "; EmFor@0: end EmFor@0: ChatFrame2:AddMessage("Census+: "..msg, 0.5, 1.0, 1.0); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Global scope variables EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: CensusPlus_Database = {}; -- Database of all CensusPlus results EmFor@0: CensusPlus_BGInfo = {}; -- Battleground info EmFor@0: CensusPlus_PerCharInfo = {}; -- Per character settings EmFor@0: CensusPlus_Unhandled = {}; EmFor@0: local g_TrackUnhandled = false; EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- File scope variables EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local g_CensusPlusInitialized; -- Is CensusPlus initialized? EmFor@0: local g_JobQueue = {}; -- The queue of pending jobs EmFor@0: local g_CurrentJob = {}; -- Current job being executed EmFor@0: g_IsCensusPlusInProgress = false; -- Is a CensusPlus in progress? EmFor@0: g_CensusPlusPaused = false; -- Is CensusPlus in progress paused? EmFor@0: g_CensusPlusManuallyPaused = false; -- Is CensusPlus in progress manually paused? EmFor@0: local g_WhoAutoClose = 0; -- AutoClose who window? EmFor@0: EmFor@0: local g_NumNewCharacters = 0; -- How many new characters found this CensusPlus EmFor@0: local g_NumUpdatedCharacters = 0; -- How many characters were updated during this CensusPlus EmFor@0: EmFor@0: local g_MobXPByLevel = {}; -- XP earned for killing EmFor@0: local g_CharacterXPByLevel = {}; -- XP required to advance through the given level EmFor@0: local g_TotalCharacterXPPerLevel = {}; -- Total XP required to attain the given level EmFor@0: EmFor@0: CensusPlus_Guilds = {}; -- All known guild EmFor@0: EmFor@0: local g_TotalCharacterXP = 0; -- Total character XP for currently selected search EmFor@0: local g_TotalCount = 0; -- Total number of characters which meet search criteria EmFor@0: local g_RaceCount = {}; -- Totals for each race given search criteria EmFor@0: local g_ClassCount = {}; -- Totals for each class given search criteria EmFor@0: local g_LevelCount = {}; -- Totals for each level given search criteria EmFor@0: local g_TempCount = {}; EmFor@0: local g_TempZoneCount = {}; EmFor@0: EmFor@0: g_GuildSelected = nil; -- Search criteria: Currently selected guild, 0 indicates none EmFor@0: g_RaceSelected = 0; -- Search criteria: Currently selected race, 0 indicates none EmFor@0: g_ClassSelected = 0; -- Search criteria: Currently selected class, 0 indicates none EmFor@0: g_LevelSelected = 0; EmFor@0: EmFor@0: local g_LastOnUpdateTime = 0; -- Last time OnUpdate was called EmFor@0: local g_WaitingForWhoUpdate = false; -- Are we waiting for a who update event? EmFor@0: EmFor@0: local g_WhoAttempts = 0; -- Counter for detecting stuck who results EmFor@0: local g_MiniOnStart = 1; -- Flag to have the mini-censusP displayed on startup EmFor@0: EmFor@0: local g_CompleteCensusStarted = false; -- Flag for counter EmFor@0: local g_TakeHour = 0; -- Our timing hour EmFor@0: local g_TimeDatabase = {}; -- Time database EmFor@0: local g_ResetHour = true; -- Rest hour EmFor@0: local g_VariablesLoaded = false; -- flag to tell us if vars are loaded EmFor@0: local g_FirstRun = true; EmFor@0: local g_LastCensusRun = time() - 1500; -- timer used if auto census is turned on EmFor@0: EmFor@0: local g_Pre_FriendsFrameOnHideOverride = nil; -- override for friend's frame to stop the close window sound EmFor@0: local g_Pre_FriendsFrameOnShowOverride = nil; -- override for friend's frame to stop the close window sound EmFor@0: local g_Pre_WhoList_UpdateOverride = nil; -- override for friend's frame to stop the close window sound EmFor@0: local g_Pre_WhoHandler = nil; -- override for submiting a who EmFor@0: local CP_Pre_OnEvent = nil; EmFor@0: local g_Pre_FriendsFrame_Update = nil; EmFor@0: local g_SetItemRef_Override = nil; EmFor@0: local CP_updatingGuild = nil; EmFor@0: g_CensusPlusLastTarget = nil; EmFor@0: g_CensusPlusLastTargetName = nil; EmFor@0: local g_CurrentlyInBG = false; EmFor@0: local g_CurrentlyInBG_Msg = false; EmFor@0: local g_InternalSearchName = nil; EmFor@0: local g_InternalSearchLevel = nil; EmFor@0: local g_InternalSearchCount = 0; EmFor@0: CensusPlus_EnableProfiling = false; EmFor@0: local g_CensusPlus_StartTime = 0; EmFor@0: local g_CensusWhoOverrideMsg = nil; EmFor@0: local g_WaitingForOverrideUpdate = false; EmFor@0: local g_ProblematicMessageShown = false; EmFor@0: local g_WhoLibLoaded = false; EmFor@0: local g_PratLoaded = false; EmFor@0: local g_WhoLibSubvert = nil; EmFor@0: local g_WhoLibSendWhoSubvert = nil; EmFor@0: local g_whoLibResultSubvert = nil; EmFor@0: local g_WhoLibChatSubvert = nil; EmFor@0: local g_WhoLibAskWhoSubvert = nil; EmFor@0: EmFor@0: -- Battleground info EmFor@0: CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES = {}; EmFor@0: EmFor@0: local g_AccumulatedPruneData = {}; EmFor@0: EmFor@0: g_RaceClassList = { }; -- Used to pick the right icon EmFor@0: g_RaceClassList[CENSUSPlus_DRUID] = 10; EmFor@0: g_RaceClassList[CENSUSPlus_HUNTER] = 11; EmFor@0: g_RaceClassList[CENSUSPlus_MAGE] = 12; EmFor@0: g_RaceClassList[CENSUSPlus_PRIEST] = 13; EmFor@0: g_RaceClassList[CENSUSPlus_ROGUE] = 14; EmFor@0: g_RaceClassList[CENSUSPlus_WARLOCK] = 15; EmFor@0: g_RaceClassList[CENSUSPlus_WARRIOR] = 16; EmFor@0: g_RaceClassList[CENSUSPlus_SHAMAN] = 17; EmFor@0: g_RaceClassList[CENSUSPlus_PALADIN] = 18; EmFor@0: g_RaceClassList[CENSUSPlus_DEATHKNIGHT] = 30; EmFor@0: EmFor@0: g_RaceClassList[CENSUSPlus_DWARF] = 20; EmFor@0: g_RaceClassList[CENSUSPlus_GNOME] = 21; EmFor@0: g_RaceClassList[CENSUSPlus_HUMAN] = 22; EmFor@0: g_RaceClassList[CENSUSPlus_NIGHTELF] = 23; EmFor@0: g_RaceClassList[CENSUSPlus_ORC] = 24; EmFor@0: g_RaceClassList[CENSUSPlus_TAUREN] = 25; EmFor@0: g_RaceClassList[CENSUSPlus_TROLL] = 26; EmFor@0: g_RaceClassList[CENSUSPlus_UNDEAD] = 27; EmFor@0: g_RaceClassList[CENSUSPlus_DRAENEI] = 28; EmFor@0: g_RaceClassList[CENSUSPlus_BLOODELF] = 29; EmFor@13: g_RaceClassList[CENSUSPlus_WORGEN] = 32; EmFor@13: g_RaceClassList[CENSUSPlus_GOBLIN] = 31; EmFor@11: EmFor@0: EmFor@0: g_TimeDatabase[CENSUSPlus_DRUID] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_HUNTER] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_MAGE] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_PRIEST] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_ROGUE] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WARLOCK] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WARRIOR] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_SHAMAN] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_PALADIN] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WarsongGulch] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_AlteracValley] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_ArathiBasin] = 0; EmFor@0: EmFor@0: -- These two DO NOT need to be localized EmFor@0: local CENSUSPlus_HORDE = "Horde"; EmFor@0: local CENSUSPlus_ALLIANCE = "Alliance"; EmFor@0: EmFor@0: EmFor@0: local g_FactionCheck = {}; EmFor@0: g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE; EmFor@0: g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE; EmFor@0: g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE; EmFor@0: g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE; EmFor@0: g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE; EmFor@6: g_FactionCheck[CENSUSPlus_GOBLIN] = CENSUSPlus_HORDE; EmFor@0: EmFor@0: g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE; EmFor@0: g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE; EmFor@0: g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE; EmFor@0: g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE; EmFor@0: g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE; EmFor@6: g_FactionCheck[CENSUSPlus_WORGEN] = CENSUSPlus_ALLIANCE; EmFor@0: local g_ReturnedZero = false; EmFor@0: EmFor@0: do EmFor@0: -- HACK EmFor@0: --[[ EmFor@0: seeing as Blizzard improperly coded GuildControlPopupFrame_OnEvent to mess up when GUILD_ROSTER_EVENT is dispatched, EmFor@0: and there is no real harm in removing the handler entirely, that's what's happening. If and when Blizzard decides to fix it, this should be removed. EmFor@0: Thanks to ckknight of wowace for this EmFor@0: ]] EmFor@6: -- GuildControlPopupFrame:SetScript("OnEvent", nil) EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Set up confirmation boxes EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: StaticPopupDialogs["CP_PURGE_CONFIRM"] = { EmFor@0: text = CENSUSPlus_PURGE_LOCAL_CONFIRM, EmFor@0: button1 = CENSUSPlus_YES, EmFor@0: button2 = CENSUSPlus_NO, EmFor@0: OnAccept = function() EmFor@0: CensusPlus_DoPurge(); EmFor@0: end, EmFor@0: sound = "levelup2", EmFor@0: timeout = 0, EmFor@0: whileDead = 1, EmFor@0: hideOnEscape = 1, EmFor@0: showAlert = 1 EmFor@0: }; EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Set up Continue after override box EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: StaticPopupDialogs["CP_CONTINUE_CENSUS"] = { EmFor@0: text = CENSUSPlus_OVERRIDE_COMPLET_PAUSED, EmFor@0: button1 = CENSUSPlus_CONTINUE, EmFor@0: OnAccept = function() EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE ); EmFor@0: end, EmFor@0: sound = "levelup2", EmFor@0: timeout = 0, EmFor@0: whileDead = 1, EmFor@0: hideOnEscape = 1, EmFor@0: showAlert = 1 EmFor@0: }; EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Chat msg hook EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local function CP_HookAddMessage(frame) EmFor@0: local AddMessage = frame.AddMessage; EmFor@0: -- Create a closure to cleanly hook the AddMessage routine. EmFor@0: frame.AddMessage = EmFor@0: function (this, msg, r, g, b, id) EmFor@0: if( ( g_TrackUnhandled or g_IsCensusPlusInProgress ) and msg ) then EmFor@0: local s, e; EmFor@0: local results = { }; EmFor@0: local whoMsg = false; EmFor@0: --CensusPlus_Msg2( "Something : " .. msg ); EmFor@0: EmFor@0: -- EmFor@0: -- We don't need to process results from chat, we can get it straight from the who window (DUHH!) EmFor@0: -- So, we just need to see if we have a match, and suppress the output if so EmFor@0: -- EmFor@0: EmFor@0: -- results = CensusPlus_GatherSingleReturn( msg ); EmFor@0: -- if( results["NAME"] ~= nil ) then EmFor@0: results = { }; EmFor@0: s, e = strmatch(msg, CENSUS_SINGLE_MATCH_PATTERN); EmFor@0: if( s ~= nil ) then EmFor@0: -- CensusPlus_Msg2( " Name : " .. results["NAME"] .. " L: " .. results["LEVEL"] .. " R: " .. results["RACE"] .. " C: " .. results["CLASS"].. " G: " .. results["GUILD"].. " Z: " .. results["ZONE"] ); EmFor@0: whoMsg = true; EmFor@0: -- WR_ProcessSingleEntry( results["NAME"], results["LEVEL"], results["RACE"], results["CLASS"], results["GUILD"], results["ZONE"] ); EmFor@0: else EmFor@0: if( g_TrackUnhandled ) then EmFor@0: CensusPlus_Unhandled[msg] = 1; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: results = { }; EmFor@0: s, e = strmatch(msg, WHO_NUM_RESULTS); EmFor@0: if( s ~= nil ) then EmFor@0: -- We got a match, now just need to determine if it's 0 or not, so we'll use a bit more lax check EmFor@0: whoMsg = true; EmFor@0: EmFor@0: local result; EmFor@0: s, e, result = string.find( msg, "(%d+).*" ); EmFor@0: if( result == "0" ) then EmFor@0: g_ReteurnedZero = true; EmFor@0: end EmFor@0: EmFor@0: CensusPlus_ProcessWhoResults(); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: if( whoMsg ) then EmFor@0: -- EmFor@0: -- Also bail out of an override if in place EmFor@0: -- EmFor@0: if( g_CensusWhoOverrideMsg ~= nil and g_WaitingForOverrideUpdate == true ) then EmFor@0: -- EmFor@0: -- Allow the who to act normally EmFor@0: -- EmFor@0: g_CensusWhoOverrideMsg = nil; EmFor@0: g_WaitingForOverrideUpdate = false; EmFor@0: CensusPlus_Msg( CENSUSPlus_OVERRIDE_COMPLETE ); EmFor@0: return AddMessage(this, msg, r, g, b, id) EmFor@0: elseif( CensusPlus_PerCharInfo["Verbose"] ~= true and EmFor@0: not g_CensusPlusPaused and EmFor@0: not g_CensusPlusManuallyPaused ) then EmFor@0: return; EmFor@0: EmFor@0: end EmFor@0: EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: end EmFor@0: EmFor@0: return AddMessage(this, msg, r, g, b, id) EmFor@0: else EmFor@0: return AddMessage(this, msg, r, g, b, id) EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Insert a job at the end of the job queue EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: local function InsertJobIntoQueue(job) EmFor@0: --CensusPlus_DumpJob( job ); EmFor@0: table.insert(g_JobQueue, job); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Initialize the tables of constants for XP calculations EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: local function InitConstantTables() EmFor@0: -- EmFor@0: -- XP earned for killing EmFor@0: -- EmFor@0: --rm EmFor@0: for i = 1, MAX_LEVEL_DISPLAY, 1 do EmFor@0: g_MobXPByLevel[i] = i; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- XP required to advance through the given level EmFor@0: -- EmFor@0: for i = 1, MAX_LEVEL_DISPLAY, 1 do EmFor@0: g_CharacterXPByLevel[i] = ((8 * i * g_MobXPByLevel[i]) / 100) * 100; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Total XP required to attain the given level EmFor@0: -- EmFor@0: local totalCharacterXP = 0; EmFor@0: for i = 1, MAX_LEVEL_DISPLAY, 1 do EmFor@0: -- g_TotalCharacterXPPerLevel[i] = totalCharacterXP; EmFor@0: --totalCharacterXP = totalCharacterXP + g_CharacterXPByLevel[i]; EmFor@0: val = (i*5)/MAX_LEVEL_DISPLAY; EmFor@0: g_TotalCharacterXPPerLevel[i] = math.exp(val); EmFor@0: end EmFor@0: EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Return a table of races for the input faction EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_GetFactionRaces(faction) EmFor@0: local ret = {}; EmFor@0: if (faction == CENSUSPlus_HORDE) then EmFor@6: ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF, CENSUSPlus_GOBLIN}; EmFor@0: elseif (faction == CENSUSPlus_ALLIANCE) then EmFor@6: ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI, CENSUSPlus_WORGEN}; EmFor@0: end EmFor@0: return ret; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Return a table of classes for the input faction EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_GetFactionClasses(faction) EmFor@0: local ret = {}; EmFor@0: if (faction == CENSUSPlus_HORDE) then EmFor@0: ret = {CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (faction == CENSUSPlus_ALLIANCE) then EmFor@0: ret = {CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT}; EmFor@0: end EmFor@0: return ret; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Return a table of classes for the input race EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: local function GetRaceClasses(race) EmFor@0: local ret = {}; EmFor@0: if (race == CENSUSPlus_ORC) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_TAUREN) then EmFor@13: ret = {CENSUSPlus_PALADIN, CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_TROLL) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_UNDEAD) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_DWARF) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_GNOME) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_HUMAN) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_NIGHTELF) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_BLOODELF) then EmFor@13: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT}; EmFor@0: elseif (race == CENSUSPlus_DRAENEI) then EmFor@0: ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT}; EmFor@6: elseif (race == CENSUSPlus_WORGEN) then EmFor@13: ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR}; EmFor@6: elseif (race == CENSUSPlus_GOBLIN) then EmFor@13: ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR}; EmFor@0: end EmFor@0: return ret; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Return common letters found in zone names EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: local function GetZoneLetters() EmFor@0: return {"t", "d", "g", "f", "h", "b", "x", "gulch", "valley", "basin" }; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Return common letters found in names, may override this for other languages EmFor@0: -- Worst case scenario is to do it for every letter in the alphabet EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: local function GetNameLetters() EmFor@11: -- return { "a", "b", "c", "d", "e", "f", "g", "i", "o", "p", "r", "s", "t", "u", "y" }; EmFor@0: --rm EmFor@0: -- return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152" }; EmFor@0: return { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "\195\134", "\195\164", "\195\182", "\195\188", "\195\152", "\195\184" }; EmFor@0: end EmFor@0: EmFor@0: --------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Register with Cosmos UI EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local function CensusPlus_RegisterCosmos() EmFor@0: -- EmFor@0: -- If Cosmos is installed, add a button to the Cosmos page to activate CensusPlus EmFor@0: -- EmFor@0: if ( EarthFeature_AddButton ) then EmFor@0: EarthFeature_AddButton( EmFor@0: { EmFor@0: id = "CensusPlus"; EmFor@0: name = CENSUSPlus_BUTTON_TEXT; EmFor@0: subtext = CENSUSPlus_BUTTON_SUBTEXT; EmFor@0: tooltip = CENSUSPlus_BUTTON_TIP; EmFor@0: icon = "Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_Icon"; EmFor@0: callback = CensusPlus_Toggle; EmFor@0: } EmFor@0: ); EmFor@0: elseif ( Cosmos_RegisterButton ) then EmFor@0: Cosmos_RegisterButton(CENSUSPlus_BUTTON_TEXT, CENSUSPlus_BUTTON_SUBTEXT, CENSUSPlus_BUTTON_TIP, "Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_Icon", CensusPlus_Toggle); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Called when the main window is shown EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_OnShow() EmFor@0: -- Initialize if this is the first OnShow event EmFor@0: if (g_CensusPlusInitialized == false) then EmFor@0: g_CensusPlusInitialized = true; EmFor@0: end EmFor@0: CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Toggle hidden status EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Toggle() EmFor@0: if ( CensusPlus:IsVisible() ) then EmFor@0: CensusPlus:Hide(); EmFor@0: else EmFor@0: CensusPlus:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Toggle options pane EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ToggleOptions() EmFor@0: if ( CP_OptionsWindow:IsVisible() ) then EmFor@0: CP_OptionsWindow:Hide(); EmFor@0: else EmFor@0: CP_OptionsWindow:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Called once on load EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnLoad( this ) EmFor@0: -- EmFor@0: -- Update the version number EmFor@0: -- EmFor@0: CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale ); EmFor@0: CensusPlusText2:SetText( CENSUSPlus_UPLOAD ); EmFor@0: EmFor@0: -- EmFor@0: -- Init constant tables EmFor@0: -- EmFor@0: InitConstantTables(); EmFor@0: EmFor@0: -- EmFor@0: -- Register with Cosmos, if it is installed EmFor@0: -- EmFor@0: CensusPlus_RegisterCosmos(); EmFor@0: EmFor@0: -- EmFor@0: -- Register for events EmFor@0: -- EmFor@0: this:RegisterEvent("VARIABLES_LOADED"); EmFor@0: -- this:RegisterEvent("WHO_LIST_UPDATE"); EmFor@0: EmFor@0: EmFor@0: this:RegisterEvent("CHAT_MSG_SYSTEM"); EmFor@0: EmFor@0: EmFor@0: this:RegisterEvent("ZONE_CHANGED_NEW_AREA"); EmFor@0: EmFor@0: -- EmFor@0: -- Register a slash command EmFor@0: -- EmFor@0: SLASH_CensusPlusCMD1 = "/CensusPlus"; EmFor@0: SLASH_CensusPlusCMD2 = "/Census+"; EmFor@0: SLASH_CensusPlusCMD3 = "/Census"; EmFor@0: SlashCmdList["CensusPlusCMD"] = CensusPlus_Command; EmFor@0: EmFor@0: SLASH_CensusPlusVerbose1 = "/censusverbose"; EmFor@0: SlashCmdList["CensusPlusVerbose"] = CensusPlus_Verbose; EmFor@0: EmFor@0: -- EmFor@0: -- Set the auto close to true EmFor@0: -- EmFor@0: CensusPlus_AutoCloseWho( 1 ); EmFor@0: --AutoClose:SetChecked( 1 ); EmFor@0: EmFor@0: -- g_Pre_FriendsFrameOnHideOverride = FriendsFrame_OnHide; EmFor@0: -- FriendsFrame_OnHide = CensusPlus_FriendsFrame_OnHide; EmFor@0: EmFor@0: -- g_Pre_FriendsFrameOnShowOverride = FriendsFrame_OnShow; EmFor@0: -- FriendsFrame_OnShow = CensusPlus_FriendsFrame_OnShow; EmFor@0: EmFor@0: -- g_Pre_WhoList_UpdateOverride = WhoList_Update; EmFor@0: -- WhoList_Update = CensusPlus_WhoList_Update; EmFor@0: EmFor@0: -- g_Pre_FriendsFrame_Update = FriendsFrame_Update; EmFor@0: -- FriendsFrame_Update = CensusPlus_FriendsFrame_Update; EmFor@0: EmFor@0: g_SetItemRef_Override = SetItemRef; EmFor@0: SetItemRef = CensusPlus_SetItemRef; EmFor@0: EmFor@0: CP_Pre_OnEvent = FriendsFrame_OnEvent; EmFor@0: FriendsFrame_OnEvent = CensusPlus_FriendsFrame_OnEvent; EmFor@0: EmFor@0: g_Pre_WhoHandler = SlashCmdList["WHO"]; EmFor@0: SlashCmdList["WHO"] = CensusPlus_WhoHandler; EmFor@0: EmFor@0: CensusPlus_CheckForBattleground(); EmFor@0: EmFor@0: -- Hook the default chat frame's AddMessage method. EmFor@0: CP_HookAddMessage(ChatFrame1); EmFor@0: EmFor@0: -- EmFor@0: -- Set up an empty frame to do updates EmFor@0: -- EmFor@0: local updateFrame = CreateFrame("Frame"); EmFor@0: updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate); EmFor@0: end EmFor@0: EmFor@6: function CensusPlus_FriendsFrame_OnEvent(self, event, ...) EmFor@0: EmFor@0: -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event ); EmFor@0: EmFor@0: if(wholib == nil and EmFor@0: event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then EmFor@0: -- EmFor@0: -- First check for an override EmFor@0: -- EmFor@0: if( g_CensusWhoOverrideMsg ~= nil and g_WaitingForOverrideUpdate == true ) then EmFor@0: -- EmFor@0: -- Allow the who to act normally EmFor@0: -- EmFor@0: g_CensusWhoOverrideMsg = nil; EmFor@0: g_WaitingForOverrideUpdate = false; EmFor@0: CensusPlus_Msg( CENSUSPlus_OVERRIDE_COMPLETE_BUT_PAUSED ); EmFor@0: -- g_Pre_WhoList_UpdateOverride(); EmFor@0: EmFor@0: EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: CP_Pre_OnEvent(...); EmFor@0: -- EmFor@0: -- If we opened the who window, do a manual pause and open a dialog EmFor@0: -- EmFor@0: g_CensusPlusManuallyPaused = true; EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE ); EmFor@0: EmFor@0: StaticPopup_Show ("CP_CONTINUE_CENSUS"); EmFor@0: EmFor@0: elseif ( g_IsCensusPlusInProgress ) then EmFor@0: -- EmFor@0: -- Only process who results if a CensusPlus is in progress EmFor@0: -- EmFor@0: EmFor@0: CP_ProcessWhoEvent() EmFor@0: EmFor@0: EmFor@0: else EmFor@0: -- EmFor@0: -- This is just a random /who done by the player EmFor@0: -- EmFor@0: CensusPlus_ProcessWhoResults(); EmFor@0: end EmFor@0: -- EmFor@0: -- We got the who update EmFor@0: -- EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: EmFor@0: return; EmFor@0: EmFor@0: end EmFor@0: EmFor@6: CP_Pre_OnEvent(self, event, ...); EmFor@0: EmFor@0: end EmFor@0: EmFor@0: function CP_ProcessWhoEvent(query, ...) EmFor@0: local numWhoResults = GetNumWhoResults(); EmFor@0: if( numWhoResults == 0 ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: CensusPlus_ProcessWhoResults(); EmFor@0: if (numWhoResults > MAX_WHO_RESULTS) then EmFor@0: -- EmFor@0: -- Who list is overflowed, split the query to make the return smaller EmFor@0: -- EmFor@0: local minLevel = g_CurrentJob.m_MinLevel; EmFor@0: local maxLevel = g_CurrentJob.m_MaxLevel; EmFor@0: local race = g_CurrentJob.m_Race; EmFor@0: local class = g_CurrentJob.m_Class; EmFor@0: local zoneLetter = g_CurrentJob.m_zoneLetter; EmFor@0: local letter = g_CurrentJob.m_Letter; EmFor@0: --rmg EmFor@0: local guild = g_CurrentJob.m_Guild; EmFor@0: EmFor@0: if (minLevel ~= maxLevel) then EmFor@0: EmFor@0: -- EmFor@0: -- The level range is greater than a single level, so split it in half and submit the two jobs EmFor@0: -- EmFor@0: local pivot = floor((minLevel + maxLevel) / 2); EmFor@0: local jobLower = CensusPlus_CreateJob( minLevel, pivot, nil, nil, nil , guild ); EmFor@0: InsertJobIntoQueue(jobLower); EmFor@0: local jobUpper = CensusPlus_CreateJob( pivot + 1, maxLevel, nil, nil, nil , guild ); EmFor@0: InsertJobIntoQueue(jobUpper); EmFor@0: else EmFor@0: -- EmFor@0: -- We cannot split the level range any more EmFor@0: -- EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: local level = minLevel; EmFor@0: if (race == nil) then EmFor@0: -- EmFor@0: -- This job does not specify race, so split it that way, making four new jobs EmFor@0: -- EmFor@0: local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); EmFor@0: local numRaces = table.getn(thisFactionRaces); EmFor@0: for i = 1, numRaces, 1 do EmFor@0: local job = CensusPlus_CreateJob( level, level, thisFactionRaces[i], nil, nil , guild ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: end EmFor@0: else EmFor@0: if (class == nil) then EmFor@0: -- EmFor@0: -- This job does not specify class, so split it that way, making more jobs EmFor@0: -- EmFor@0: local thisRaceClasses = GetRaceClasses(race); EmFor@0: local numClasses = table.getn(thisRaceClasses); EmFor@0: for i = 1, numClasses, 1 do EmFor@0: local job = CensusPlus_CreateJob( level, level, race, thisRaceClasses[i], nil , guild ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: end EmFor@0: else EmFor@0: if( letter == nil ) then EmFor@0: -- There are too many characters with a single level, class and race EmFor@0: -- The work around we are going to pursue is to check by name for a,e,i,o,r,s,t,u EmFor@0: local letters = GetNameLetters(); EmFor@0: for i=1, table.getn( letters ), 1 do EmFor@0: local job = CensusPlus_CreateJob( level, level, race, class, letters[i] , guild ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: end EmFor@0: else EmFor@0: -- There are too many characters with a single level, class, race and letter, give up EmFor@0: local whoText = CensusPlus_CreateWhoText(g_CurrentJob); EmFor@0: CensusPlus_Msg(format(CENSUSPlus_TOOMANY, whoText)); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: local whoText = CensusPlus_CreateWhoText(g_CurrentJob); EmFor@0: EmFor@0: if whoText == query then EmFor@0: g_WaitingForWhoUpdate = false EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Load Handler for options box EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CP_OptionsOnShow() EmFor@0: CP_OptionAutoClose:SetChecked(g_WhoAutoClose); EmFor@0: CP_OptionAutoStartButton:SetChecked(g_MiniOnStart); EmFor@0: CP_OptionVerboseButton:SetChecked(CensusPlus_PerCharInfo["Verbose"]); EmFor@0: CP_OptionAutoCensusButton:SetChecked( CensusPlus_Database["Info"]["AutoCensus"] ); EmFor@0: -- CP_OptionProcessCharProfileButton:SetChecked( CensusPlus_DoThisCharacter ); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Friends Frame override to stop the window close sound EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_FriendsFrame_OnHide() EmFor@0: g_Pre_FriendsFrameOnHideOverride(); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Friends Frame override to stop the window close sound EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_FriendsFrame_OnShow() EmFor@0: g_Pre_FriendsFrameOnShowOverride(); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_WhoList_Update EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_WhoList_Update() EmFor@0: --InCombatLockdown() == false EmFor@0: if( g_IsCensusPlusInProgress == true and g_WhoAutoClose ) then EmFor@0: local numWhos, totalCount = GetNumWhoResults(); EmFor@0: local name, guild, level, race, class, zone, group; EmFor@0: local button; EmFor@0: local columnTable; EmFor@0: local whoOffset = FauxScrollFrame_GetOffset(WhoListScrollFrame); EmFor@0: local whoIndex; EmFor@0: local showScrollBar = nil; EmFor@0: if ( numWhos > WHOS_TO_DISPLAY ) then EmFor@0: showScrollBar = 1; EmFor@0: end EmFor@0: local displayedText = ""; EmFor@0: if ( totalCount > MAX_WHOS_FROM_SERVER ) then EmFor@0: displayedText = format(WHO_FRAME_SHOWN_TEMPLATE, MAX_WHOS_FROM_SERVER); EmFor@0: end EmFor@0: WhoFrameTotals:SetText(format(GetText("WHO_FRAME_TOTAL_TEMPLATE", nil, totalCount), totalCount).." "..displayedText); EmFor@0: for i=1, WHOS_TO_DISPLAY, 1 do EmFor@0: whoIndex = whoOffset + i; EmFor@0: button = getglobal("WhoFrameButton"..i); EmFor@0: button.whoIndex = whoIndex; EmFor@0: name, guild, level, race, class, zone, group = GetWhoInfo(whoIndex); EmFor@0: columnTable = { zone, guild, race }; EmFor@0: getglobal("WhoFrameButton"..i.."Name"):SetText(name); EmFor@0: getglobal("WhoFrameButton"..i.."Level"):SetText(level); EmFor@0: getglobal("WhoFrameButton"..i.."Class"):SetText(class); EmFor@0: local variableText = getglobal("WhoFrameButton"..i.."Variable"); EmFor@0: variableText:SetText(columnTable[UIDropDownMenu_GetSelectedID(WhoFrameDropDown)]); EmFor@0: if ( not group ) then EmFor@0: group = ""; EmFor@0: end EmFor@0: --getglobal("WhoFrameButton"..i.."Group"):SetText(getglobal(strupper(group))); EmFor@0: EmFor@0: -- If need scrollbar resize columns EmFor@0: if ( showScrollBar ) then EmFor@0: variableText:SetWidth(95); EmFor@0: else EmFor@0: variableText:SetWidth(110); EmFor@0: end EmFor@0: EmFor@0: -- Highlight the correct who EmFor@0: if ( WhoFrame.selectedWho == whoIndex ) then EmFor@0: button:LockHighlight(); EmFor@0: else EmFor@0: button:UnlockHighlight(); EmFor@0: end EmFor@0: EmFor@0: if ( whoIndex > numWhos ) then EmFor@0: button:Hide(); EmFor@0: else EmFor@0: button:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: if ( not WhoFrame.selectedWho ) then EmFor@0: WhoFrameGroupInviteButton:Disable(); EmFor@0: WhoFrameAddFriendButton:Disable(); EmFor@0: else EmFor@0: WhoFrameGroupInviteButton:Enable(); EmFor@0: WhoFrameAddFriendButton:Enable(); EmFor@0: WhoFrame.selectedName = GetWhoInfo(WhoFrame.selectedWho); EmFor@0: end EmFor@0: EmFor@0: -- If need scrollbar resize columns EmFor@0: if ( showScrollBar ) then EmFor@0: WhoFrameColumn_SetWidth(WhoFrameColumnHeader2, 105); EmFor@0: UIDropDownMenu_SetWidth(WhoFrameDropDown, 80); EmFor@0: else EmFor@0: WhoFrameColumn_SetWidth(WhoFrameColumnHeader2, 120); EmFor@0: UIDropDownMenu_SetWidth(WhoFrameDropDown, 95); EmFor@0: end EmFor@0: EmFor@0: -- ScrollFrame update EmFor@0: FauxScrollFrame_Update(WhoListScrollFrame, numWhos, WHOS_TO_DISPLAY, FRIENDS_FRAME_WHO_HEIGHT ); EmFor@0: EmFor@0: else EmFor@0: g_Pre_WhoList_UpdateOverride(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_FriendsFrame_Update EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_FriendsFrame_Update() EmFor@0: if ( FriendsFrame.selectedTab == 3 and g_IsCensusPlusInProgress == true and g_WhoAutoClose ) then EmFor@0: FriendsFrameTopLeft:SetTexture("Interface\\ClassTrainerFrame\\UI-ClassTrainer-TopLeft"); EmFor@0: FriendsFrameTopRight:SetTexture("Interface\\ClassTrainerFrame\\UI-ClassTrainer-TopRight"); EmFor@0: FriendsFrameBottomLeft:SetTexture("Interface\\FriendsFrame\\GuildFrame-BotLeft"); EmFor@0: FriendsFrameBottomRight:SetTexture("Interface\\FriendsFrame\\GuildFrame-BotRight"); EmFor@0: local guildName, title, rank = GetGuildInfo("player"); EmFor@0: if ( guildName ) then EmFor@0: FriendsFrameTitleText:SetText(format(GUILD_TITLE_TEMPLATE, title, guildName)); EmFor@0: else EmFor@0: FriendsFrameTitleText:SetText(""); EmFor@0: end EmFor@0: --GuildStatus_Update(); EmFor@0: FriendsFrameTitleText:SetText(guildName); EmFor@0: FriendsFrame_ShowSubFrame("GuildFrame"); EmFor@0: else EmFor@0: g_Pre_FriendsFrame_Update(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Who Handler EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_WhoHandler( msg ) EmFor@0: if( g_IsCensusPlusInProgress == true ) then EmFor@0: CensusPlus_Msg( "Census Who Handler" ); EmFor@0: if ( msg == "" ) then EmFor@0: msg = WhoFrame_GetDefaultWhoCommand(); EmFor@0: ShowWhoPanel(); EmFor@0: elseif ( msg == "cheat" ) then EmFor@0: -- Remove the "cheat" part later! EmFor@0: ShowWhoPanel(); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Queue up the command to run next EmFor@0: -- EmFor@0: g_CensusWhoOverrideMsg = msg; EmFor@0: CensusPlus_Msg( CENSUSPlus_OVERRIDE ); EmFor@0: -- CensusPlus_SendWho(msg); EmFor@0: else EmFor@0: g_Pre_WhoHandler(msg); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus command EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Command( param ) EmFor@0: EmFor@0: local i,j, command, value = string.find(param, "^([^ ]+) (.+)$"); EmFor@0: EmFor@0: -- local firsti, lasti, command, value = string.find (param, "(%w+) (%w+) (%w+)") ; EmFor@0: EmFor@0: -- if( string.lower(param) == "locale" ) then EmFor@0: -- CP_EU_US_Version:Show(); EmFor@0: -- else EmFor@0: if( string.lower(param) == "options" ) then EmFor@0: CP_OptionsWindow:Show(); EmFor@0: -- elseif( string.lower(param) == "tz" ) then EmFor@0: -- CensusPlus_DetermineServerDate(); EmFor@0: elseif( command ~= nil and string.lower(command) == "prune" ) then EmFor@0: if( value ~= nil ) then EmFor@0: CensusPlus_PruneData( value, nil ); EmFor@0: else EmFor@0: CensusPlus_PruneData( 30, nil ); EmFor@0: end EmFor@0: elseif( command ~= nil and string.lower(command) == "timer" ) then EmFor@0: if( value ~= nil ) then EmFor@0: CensusPlus_Database["Info"]["AutoCensusTimer"] = value * 60; EmFor@0: CensusPlus_Msg( "Set autocensus timer to " .. value .. " minutes" ); EmFor@0: else EmFor@0: CensusPlus_Database["Info"]["AutoCensusTimer"] = 1800; EmFor@0: CensusPlus_Msg( "Set autocensus timer to 30 minutes" ); EmFor@0: end EmFor@0: elseif( string.lower(param) == "serverprune" ) then EmFor@0: CensusPlus_PruneData( 0, 1 ); EmFor@0: elseif( string.lower(param) == "bufftest" ) then EmFor@0: showAllUnitBuffs("player"); EmFor@0: elseif( string.lower(param) == "verbose" ) then EmFor@0: CensusPlus_Verbose(); EmFor@0: elseif( string.lower(param) == "take" ) then EmFor@0: CensusPlus_Take_OnClick(); EmFor@0: elseif( string.lower(param) == "stop" ) then EmFor@0: CensusPlus_StopCensus(); EmFor@0: elseif( string.lower(param) == "track" ) then EmFor@0: if( g_TrackUnhandled ) then EmFor@0: CensusPlus_Msg( "Tracking disabled!" ); EmFor@0: g_TrackUnhandled = false; EmFor@0: else EmFor@0: CensusPlus_Msg( "TRACKING ALL CHAT!" ); EmFor@0: g_TrackUnhandled = true; EmFor@0: end EmFor@0: elseif( command ~= nil and string.lower(command) == "who" ) then EmFor@0: local m,n, check, level = string.find(value, "(%w+) (%w+)"); EmFor@0: if( check ~= nil ) then EmFor@0: CensusPlus_InternalWho( string.lower(check), level ); EmFor@0: else EmFor@0: CensusPlus_InternalWho( string.lower(value), nil ); EmFor@0: end EmFor@0: elseif( command ~= nil and string.lower(command) == "test" ) then EmFor@0: if( value ~= nil ) then EmFor@0: CensusPlus_Test( value ); EmFor@0: else EmFor@0: CensusPlus_Test( 1 ); EmFor@0: end EmFor@0: else EmFor@0: CensusPlus_DisplayUsage(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Display Usage EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DisplayUsage() EmFor@0: local text; EmFor@0: EmFor@0: CensusPlus:Show(); EmFor@0: EmFor@0: CensusPlus_Msg("Usage:\n /CensusPlus"); EmFor@0: CensusPlus_Msg(" /censusPlus verbose Toggle verbose mode off/on"); EmFor@0: -- CensusPlus_Msg(" /CensusPlus locale Bring up the locale selection dialog - (WARNING -- CHANGING YOUR LOCALE WILL PURGE YOUR DATABASE)"); EmFor@0: CensusPlus_Msg(" /CensusPlus options Bring up the Option window"); EmFor@0: CensusPlus_Msg(" /CensusPlus take Start a Census snapshot"); EmFor@0: CensusPlus_Msg(" /CensusPlus stop Stop a Census snapshot"); EmFor@0: CensusPlus_Msg(" /CensusPlus prune X Prune the database by removing characters not seen in X days"); EmFor@0: CensusPlus_Msg(" /CensusPlus serverprune Prune the database by removing all data from servers other than the one you are currently on."); EmFor@0: CensusPlus_Msg(" /CensusPlus who XXX Will display info that matches names or guilds."); EmFor@0: CensusPlus_Msg(" /CensusPlus who unguilded ## Will list unguilded characters of that level."); EmFor@0: CensusPlus_Msg(" /CensusPlus timer X ## Will set the autocensus timer (in minutes)."); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_InternalWho - will go through our local database and see if we have EmFor@0: -- any info on this person EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_InternalWho( search, level ) EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: g_InternalSearchName = search; EmFor@0: g_InternalSearchLevel = level; EmFor@0: g_InternalSearchCount = 0; EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: CensusPlus_ForAllCharacters( realmName, UnitFactionGroup("player"), nil, nil, nil, nil, CensusPlus_InternalWhoResult) EmFor@0: EmFor@0: CensusPlus_WhoMsg( "Found " .. g_InternalSearchCount .. " players." ); EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_InternalWhoResult(name, level, guild, race, class, lastSeen ) EmFor@0: lowerName = string.lower( name ); EmFor@0: level = string.lower( level ); EmFor@0: lowerGuild = string.lower( CensusPlus_SafeCheck( guild ) ); EmFor@0: EmFor@0: if( g_InternalSearchName == "unguilded" ) then EmFor@0: if( guild == "" ) then EmFor@0: local doit = 1; EmFor@0: if( g_InternalSearchLevel ~= nil ) then EmFor@0: if( g_InternalSearchLevel ~= level ) then EmFor@0: doit = 0; EmFor@0: end EmFor@0: end EmFor@0: if( doit == 1 ) then EmFor@0: local out = name .. " : Level " .. level .. " " .. race .. " " .. " " .. class; EmFor@0: out = out .. " Last Seen: " .. lastSeen; EmFor@0: CensusPlus_WhoMsg( out ); EmFor@0: g_InternalSearchCount = g_InternalSearchCount + 1; EmFor@0: end EmFor@0: end EmFor@0: elseif( string.find( lowerName, g_InternalSearchName ) or string.find( lowerGuild, g_InternalSearchName ) ) then EmFor@0: -- found someone! EmFor@0: local out = name .. " : Level " .. level .. " " .. race .. " " .. " " .. class; EmFor@0: if( guild ~= "" ) then EmFor@0: out = out .. " <" .. guild .. ">"; EmFor@0: end EmFor@0: out = out .. " Last Seen: " .. lastSeen; EmFor@0: CensusPlus_WhoMsg( out ); EmFor@0: g_InternalSearchCount = g_InternalSearchCount + 1; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Verbose option EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Verbose() EmFor@0: if( CensusPlus_PerCharInfo["Verbose"] == true ) then EmFor@0: CensusPlus_Msg( "Verbose Mode : OFF" ); EmFor@0: CensusPlus_PerCharInfo["Verbose"] = false; EmFor@0: else EmFor@0: CensusPlus_Msg( "Verbose Mode : ON" ); EmFor@0: CensusPlus_PerCharInfo["Verbose"] = true; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus Auto Census set flag EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_SetAutoCensus( flag ) EmFor@0: if( flag == 1 ) then EmFor@0: CensusPlus_Database["Info"]["AutoCensus"] = true; EmFor@0: else EmFor@0: CensusPlus_Database["Info"]["AutoCensus"] = false; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Minimize the window EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_OnClickMinimize() EmFor@0: if( CensusPlus:IsVisible() ) then EmFor@0: -- MiniCensusPlus:Show(); EmFor@0: CensusPlus:Hide(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Minimize the window EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_OnClickMaximize() EmFor@0: if( MiniCensusPlus:IsVisible() ) then EmFor@0: MiniCensusPlus:Hide(); EmFor@0: CensusPlus:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Take or pause a census depending on current status EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Take_OnClick() EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: CensusPlus_TogglePause(); EmFor@0: else EmFor@0: CensusPlus_StartCensus(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: --rm EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- Take or pause a census depending on current status EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_TakeGuild_OnClick() EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: CensusPlus_TogglePause(); EmFor@0: else EmFor@0: CensusPlus_StartGuildCensus(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Display a tooltip for the take button EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@6: function CensusPlus_Take_OnEnter( this ) EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: if (g_CensusPlusManuallyPaused) then EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: else EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_PAUSECENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: else EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_TAKECENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: --rm EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- Display a tooltip for the take guild button EmFor@0: ----------------------------------------------------------------------------------- EmFor@6: function CensusPlus_TakeGuild_OnEnter( this ) EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: if (g_CensusPlusManuallyPaused) then EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: else EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_PAUSECENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: else EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(CENSUSPlus_TAKEGUILDCENSUS, 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Pause the current census EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_TogglePause() EmFor@0: if (g_IsCensusPlusInProgress == true) then EmFor@0: if( g_CensusPlusManuallyPaused == true ) then EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE ); EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: else EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE ); EmFor@0: g_CensusPlusManuallyPaused = true; EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Purge the database for this realm and faction EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Purge() EmFor@0: StaticPopup_Show ("CP_PURGE_CONFIRM"); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_DoPurge EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DoPurge() EmFor@0: if( CensusPlus_Database["Servers"] ~= nil ) then EmFor@0: CensusPlus_Database["Servers"] = nil; EmFor@0: end EmFor@0: CensusPlus_Database["Servers"] = {}; EmFor@0: CensusPlus_UpdateView(); EmFor@0: CensusPlus_Msg(CENSUSPlus_PURGEMSG); EmFor@0: EmFor@0: if( CensusPlus_Database["Guilds"] ~= nil ) then EmFor@0: CensusPlus_Database["Guilds"] = nil; EmFor@0: end EmFor@0: CensusPlus_Database["Guilds"] = {}; EmFor@0: EmFor@0: if( CensusPlus_Database["TimesPlus"] ~= nil ) then EmFor@0: CensusPlus_Database["TimesPlus"] = nil; EmFor@0: end EmFor@0: CensusPlus_Database["TimesPlus"] = {}; EmFor@0: EmFor@0: if( CensusPlus_Profile ~= nil ) then EmFor@0: CensusPlus_Profile = nil; EmFor@0: end EmFor@0: CensusPlus_Profile = {}; EmFor@0: EmFor@0: if( CensusPlus_BGInfo ~= nil ) then EmFor@0: CensusPlus_BGInfo = nil; EmFor@0: end EmFor@0: CensusPlus_BGInfo = {}; EmFor@0: EmFor@0: CensusPlus_Msg( "Data Purged" ); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Handler for auto close checkbox EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_AutoCloseWho(close) EmFor@0: g_WhoAutoClose = close; EmFor@0: end EmFor@0: EmFor@0: --function CensusPlus_WhoLibEvent(event, query, ...) EmFor@0: -- CensusPlus_Msg( event ) EmFor@0: --end EmFor@0: EmFor@0: --rm EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- Take a guild CensusPlus EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_StartGuildCensus() EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: -- Do not initiate a new CensusPlus while one is in progress EmFor@0: CensusPlus_Msg(CENSUSPlus_ISINPROGRESS); EmFor@0: elseif( g_CurrentlyInBG ) then EmFor@0: g_LastCensusRun = time()-600; EmFor@0: if( not g_CurrentlyInBG_Msg ) then EmFor@0: CensusPlus_Msg(CENSUSPlus_ISINBG); EmFor@0: g_CurrentlyInBG_Msg = true; EmFor@0: end EmFor@0: else EmFor@0: -- Set a timer EmFor@0: g_CensusPlus_StartTime = time(); EmFor@0: -- Initialize the job queue and counters EmFor@0: CensusPlus_Msg(CENSUSPlus_TAKINGONLINE); EmFor@0: g_NumNewCharacters = 0; EmFor@0: g_NumUpdatedCharacters = 0; EmFor@0: g_JobQueue = {}; EmFor@0: g_TempCount = nil; EmFor@0: g_TempCount = {}; EmFor@0: g_TempZoneCount = nil; EmFor@0: g_TempZoneCount = {}; EmFor@0: -- The Job List Works as LIFO; last in, first out EmFor@0: -- for Cataclysm, ... and GM's :) after all following Jobs EmFor@0: local job = CensusPlus_CreateJob( ( MAX_CHARACTER_LEVEL + 1 ) , MAX_LEVEL_DISPLAY, nil, nil, nil , CensusPlus_MYGUILD ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: -- ending with lvl MAX_CHARACTER_LEVEL EmFor@0: local counter = MAX_CHARACTER_LEVEL; EmFor@0: local LowCounter = counter; EmFor@0: local LowCharDetailLevel = 3; EmFor@0: local LevelStep = 10; EmFor@0: EmFor@0: local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , CensusPlus_MYGUILD ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = counter - 1; EmFor@0: while (counter > LowCharDetailLevel) do EmFor@0: LowCounter = counter - LevelStep + 1 ; EmFor@0: if (LowCounter <= LowCharDetailLevel) then EmFor@0: LowCounter = LowCharDetailLevel +1 ; EmFor@0: end EmFor@0: local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , CensusPlus_MYGUILD ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = LowCounter - 1 ; EmFor@0: end EmFor@0: while (counter > 0) do EmFor@0: LowCounter = counter ; EmFor@0: local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , CensusPlus_MYGUILD ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = LowCounter - 1 ; EmFor@0: end EmFor@0: ------------------ EmFor@0: -- Test inserts EmFor@0: -- local job = CensusPlus_CreateJob( 11, 12, "Troll", nil, nil , CensusPlus_MYGUILD ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: g_IsCensusPlusInProgress = true; EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: local hour, minute = GetGameTime(); EmFor@0: g_TakeHour = hour; EmFor@0: g_ResetHour = true; EmFor@0: wholib = wholib or LibStub:GetLibrary("LibWho-2.0", true); EmFor@0: -- Subvert WhoLib EmFor@0: if( wholib ) then EmFor@0: CensusPlus_Msg( "Using WhoLib" ); EmFor@0: end EmFor@0: end EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE ); EmFor@0: CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKINGGUILD.." \""..CensusPlus_MYGUILD.."\"" ); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Take a CensusPlus EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_StartCensus() EmFor@0: EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: if( g_CensusPlusManuallyPaused == true ) then EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: CensusPlusPauseButton:SetText( CENSUSPlus_PAUSE ); EmFor@0: else EmFor@0: -- Do not initiate a new CensusPlus while one is in progress EmFor@0: CensusPlus_Msg(CENSUSPlus_ISINPROGRESS); EmFor@0: end EmFor@0: elseif( g_CurrentlyInBG ) then EmFor@0: g_LastCensusRun = time()-600; EmFor@0: if( not g_CurrentlyInBG_Msg ) then EmFor@0: CensusPlus_Msg(CENSUSPlus_ISINBG); EmFor@0: g_CurrentlyInBG_Msg = true; EmFor@0: end EmFor@0: else EmFor@0: -- EmFor@0: -- Set a timer EmFor@0: -- EmFor@0: g_CensusPlus_StartTime = time(); EmFor@0: EmFor@0: -- EmFor@0: -- Initialize the job queue and counters EmFor@0: -- EmFor@0: CensusPlus_Msg(CENSUSPlus_TAKINGONLINE); EmFor@0: g_NumNewCharacters = 0; EmFor@0: g_NumUpdatedCharacters = 0; EmFor@0: g_JobQueue = {}; EmFor@0: EmFor@0: g_TempCount = nil; EmFor@0: g_TempCount = {}; EmFor@0: EmFor@0: g_TempZoneCount = nil; EmFor@0: g_TempZoneCount = {}; EmFor@0: -- EmFor@0: -- First job covers all characters by searching all levels EmFor@0: -- EmFor@0: -- The Job List Works as LIFO; last in, first out EmFor@0: -- local job = {m_MinLevel = 1, m_MaxLevel = MAX_CHARACTER_LEVEL}; EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: --rm EmFor@0: -- for Cataclysm, ... and GM's :) after all following Jobs EmFor@0: local job = CensusPlus_CreateJob( ( MAX_CHARACTER_LEVEL + 1 ) , MAX_LEVEL_DISPLAY, nil, nil, nil , nil ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: ---- ending with lvl 1-10 EmFor@0: -- local counter = 0; EmFor@0: -- for counter = 0, 6, 1 do EmFor@0: -- local job = CensusPlus_CreateJob( counter*10 + 1, counter*10+10, nil, nil, nil , nil ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: -- end EmFor@0: ---- do 71-79 before the above jobs EmFor@0: -- job = CensusPlus_CreateJob( 71, 79, nil, nil, nil , nil ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: ---- do 80-80 before the above jobs EmFor@0: -- job = CensusPlus_CreateJob( 80, 80, nil, nil, nil , nil ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: EmFor@0: -- ending with lvl MAX_CHARACTER_LEVEL EmFor@0: local counter = MAX_CHARACTER_LEVEL; EmFor@0: local LowCounter = counter; EmFor@0: local LowCharDetailLevel = 3; EmFor@0: local LevelStep = 10; EmFor@0: EmFor@0: EmFor@0: local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , nil ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = counter - 1; EmFor@0: while (counter > LowCharDetailLevel) do EmFor@0: LowCounter = counter - LevelStep + 1 ; EmFor@0: if (LowCounter <= LowCharDetailLevel) then EmFor@0: LowCounter = LowCharDetailLevel +1 ; EmFor@0: end EmFor@0: local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , nil ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = LowCounter - 1 ; EmFor@0: end EmFor@0: while (counter > 0) do EmFor@0: LowCounter = counter ; EmFor@0: local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , nil ); EmFor@0: InsertJobIntoQueue(job); EmFor@0: counter = LowCounter - 1 ; EmFor@0: end EmFor@0: ------------------ EmFor@0: EmFor@0: EmFor@0: -- for counter = 60, MAX_CHARACTER_LEVEL, 1 do EmFor@0: -- local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , nil ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: -- end EmFor@0: EmFor@0: -- Test inserts EmFor@0: -- local job = CensusPlus_CreateJob( 11, 12, "Troll", nil, nil , nil ); EmFor@0: -- InsertJobIntoQueue(job); EmFor@0: g_IsCensusPlusInProgress = true; EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: EmFor@0: local hour, minute = GetGameTime(); EmFor@0: g_TakeHour = hour; EmFor@0: g_ResetHour = true; EmFor@0: EmFor@0: wholib = wholib or LibStub:GetLibrary("LibWho-2.0", true); EmFor@0: -- EmFor@0: -- Subvert WhoLib EmFor@0: -- EmFor@0: if( wholib ) then EmFor@0: -- EmFor@0: -- Be prepared to subvert the WhoLib mechanic EmFor@0: -- EmFor@0: -- g_WhoLibSubvert = SlashCmdList["WHO"]; EmFor@0: -- SlashCmdList["WHO"] = CensusPlus_WhoHandler; EmFor@0: -- EmFor@0: -- g_WhoLibSendWhoSubvert = SendWho; EmFor@0: -- SendWho = WhoLibByALeX.hooks.SendWho; EmFor@0: -- EmFor@0: -- g_WhoLibResultSubvert = WhoLibByALeX.WHO_LIST_UPDATE; EmFor@0: -- g_WhoLibChatSubvert = WhoLibByALeX.CHAT_MSG_SYSTEM; EmFor@0: -- g_WhoLibAskWhoSubvert = WhoLibByALeX.AskWho; EmFor@0: -- EmFor@0: -- WhoLibByALeX.WHO_LIST_UPDATE = function( args ) end EmFor@0: -- WhoLibByALeX.CHAT_MSG_SYSTEM = function( args ) end EmFor@0: -- WhoLibByALeX.AskWho = function( args ) end EmFor@0: EmFor@0: CensusPlus_Msg( "Using WhoLib" ); EmFor@0: EmFor@0: EmFor@0: --wholib.RegisterCallback("CensusPlus", "WHOLIB_QUERY_RESULT", CensusPlus_WhoLibEvent) EmFor@0: EmFor@0: end EmFor@0: end EmFor@11: EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE ); EmFor@11: EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Stop a CensusPlus EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_StopCensus( ) EmFor@0: if (g_IsCensusPlusInProgress) then EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_TAKE ); EmFor@0: CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); EmFor@0: g_CensusPlusManuallyPaused = false; EmFor@0: EmFor@0: CensusPlusScanProgress:SetText( CENSUSPlus_SCAN_PROGRESS_0 ); EmFor@0: EmFor@0: g_JobQueue = {}; EmFor@0: g_JobQueue = nil; EmFor@0: g_JobQueue = {}; EmFor@0: EmFor@0: CensusPlus_DisplayResults( ); EmFor@0: EmFor@0: -- Clean up the times EmFor@0: CensusPlus_PruneTimes(); EmFor@0: EmFor@0: -- if( wholib ) then EmFor@0: -- SlashCmdList["WHO"] = g_WhoLibSubvert; EmFor@0: -- EmFor@0: -- SendWho = g_WhoLibSendWhoSubvert; EmFor@0: -- WhoLibByALeX.WHO_LIST_UPDATE = g_WhoLibResultSubvert; EmFor@0: -- WhoLibByALeX.CHAT_MSG_SYSTEM = g_WhoLibChatSubvert; EmFor@0: -- WhoLibByALeX.AskWho = g_WhoLibAskWhoSubvert; EmFor@0: EmFor@0: EmFor@0: -- CensusPlus_Msg( "Unregistering with WhoLib" ); EmFor@0: EmFor@0: --wholib.UnregisterAllCallbacks("CensusPlus") EmFor@0: -- end EmFor@0: EmFor@0: else EmFor@0: CensusPlus_Msg(CENSUSPlus_NOCENSUS); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Display Census results EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DisplayResults( ) EmFor@0: -- EmFor@0: -- We are all done, report our results EmFor@0: -- EmFor@0: g_IsCensusPlusInProgress = false; EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- Finish our timer EmFor@0: -- EmFor@0: local total_time = time() - g_CensusPlus_StartTime; EmFor@0: EmFor@0: CensusPlus_Msg(format(CENSUSPlus_FINISHED, g_NumNewCharacters, g_NumUpdatedCharacters, SecondsToTime( total_time ))); EmFor@0: ChatFrame1:AddMessage(CENSUSPlus_UPLOAD, 0.5, 1.0, 1.0); EmFor@0: EmFor@0: CensusPlus_UpdateView(); EmFor@0: g_LastCensusRun = time(); EmFor@0: EmFor@0: CensusPlusTakeButton:SetText( CENSUSPlus_TAKE ); EmFor@0: CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Create a who command text for the input job EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_CreateWhoText(job) EmFor@0: local whoText = ""; EmFor@0: local race = job.m_Race; EmFor@0: if (race ~= nil) then EmFor@0: whoText = whoText.." r-\""..race.."\""; EmFor@0: end EmFor@0: EmFor@0: local class = job.m_Class; EmFor@0: if (class ~= nil) then EmFor@0: whoText = whoText.." c-\""..class.."\""; EmFor@0: end EmFor@0: EmFor@0: local minLevel = tostring( job.m_MinLevel ); EmFor@0: if (minLevel == nil) then EmFor@0: minLevel = 1; EmFor@0: end EmFor@0: local maxLevel = job.m_MaxLevel; EmFor@0: if (maxLevel == nil) then EmFor@0: maxLevel = MAX_CHARACTER_LEVEL; EmFor@0: end EmFor@0: whoText = whoText.." ".. minLevel .."-".. maxLevel; EmFor@0: EmFor@0: local zoneLetter = job.m_zoneLetter; EmFor@0: if ( zoneLetter ~= nil) then EmFor@0: whoText = whoText.." z-"..zoneLetter; EmFor@0: end EmFor@0: EmFor@0: local letter = job.m_Letter; EmFor@0: if( letter ~= nil ) then EmFor@0: whoText = whoText.." n-"..letter; EmFor@0: end EmFor@0: --rmg EmFor@0: local guild = job.m_Guild; EmFor@0: if( guild ~= nil ) then EmFor@0: whoText = whoText.." g-\""..guild.."\""; EmFor@0: end EmFor@0: EmFor@0: return whoText; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Create a job EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_CreateJob( minLevel, maxLevel, race, class, letter, guild ) EmFor@0: local job = {}; EmFor@0: job.m_MinLevel = minLevel; EmFor@0: job.m_MaxLevel = maxLevel; EmFor@0: job.m_Race = race; EmFor@0: job.m_Class = class; EmFor@0: job.m_Letter = letter; EmFor@0: job.m_Guild = guild; EmFor@0: EmFor@0: CensusPlus_DumpJob( job ); EmFor@0: EmFor@0: return job; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Debug function do dump a job EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DumpJob( job ) EmFor@0: local whoText = ""; EmFor@0: local race = job.m_Race; EmFor@0: if (race ~= nil) then EmFor@0: whoText = whoText.." R: "..race; EmFor@0: end EmFor@0: EmFor@0: local class = job.m_Class; EmFor@0: if (class ~= nil) then EmFor@0: whoText = whoText.." C: "..class; EmFor@0: end EmFor@0: EmFor@0: local minLevel = job.m_MinLevel; EmFor@0: if (minLevel ~= nil) then EmFor@0: whoText = whoText.." min: ".. minLevel; EmFor@0: end EmFor@0: EmFor@0: local maxLevel = job.m_MaxLevel; EmFor@0: if (maxLevel ~= nil) then EmFor@0: whoText = whoText.." max: ".. maxLevel; EmFor@0: end EmFor@0: EmFor@0: local zoneLetter = job.m_zoneLetter; EmFor@0: if ( zoneLetter ~= nil) then EmFor@0: whoText = whoText.." Z: "..zoneLetter; EmFor@0: end EmFor@0: EmFor@0: local letter = job.m_Letter; EmFor@0: if( letter ~= nil ) then EmFor@0: whoText = whoText.." N: "..letter; EmFor@0: end EmFor@0: --rmg EmFor@0: local guild = job.m_Guild; EmFor@0: if( guild ~= nil ) then EmFor@0: whoText = whoText.." G: \""..guild.."\""; EmFor@0: end EmFor@0: EmFor@0: --CensusPlus_Msg( "JOB DUMP: " .. whoText ); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Called on events EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_OnEvent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) EmFor@0: EmFor@0: if( arg1 == nil ) then EmFor@0: arg1 = "nil" EmFor@0: end EmFor@0: if( arg2 == nil ) then EmFor@0: arg2 = "nil" EmFor@0: end EmFor@0: if( arg3 == nil ) then EmFor@0: arg3 = "nil" EmFor@0: end EmFor@0: if( arg4 == nil ) then EmFor@0: arg4 = "nil" EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- If we have not been initialized, do nothing EmFor@0: -- EmFor@0: if (g_CensusPlusInitialized == false) then EmFor@0: return EmFor@0: end EmFor@0: EmFor@0: -- CensusPlus_Msg( "Message =>" .. event ); EmFor@0: EmFor@0: -- EmFor@0: -- WHO_LIST_UPDATE EmFor@0: -- EmFor@0: if( event == "TRAINER_SHOW" or event == "MERCHANT_SHOW" or event == "TRADE_SHOW" or event == "GUILD_REGISTRAR_SHOW" EmFor@0: or event == "AUCTION_HOUSE_SHOW" or event == "BANKFRAME_OPENED" or event == "QUEST_DETAIL" ) then EmFor@0: if( g_IsCensusPlusInProgress ) then EmFor@0: g_CensusPlusPaused = true; EmFor@0: end EmFor@0: elseif( event == "TRAINER_CLOSED" or event == "MERCHANT_CLOSED" or event == "TRADE_CLOSED" or event == "GUILD_REGISTRAR_CLOSED" EmFor@0: or event == "AUCTION_HOUSE_CLOSED" or event == "BANKFRAME_CLOSED" or event == "QUEST_FINISHED" ) then EmFor@0: if( g_IsCensusPlusInProgress ) then EmFor@0: g_CensusPlusPaused = false; EmFor@0: end EmFor@0: elseif (event == "GUILD_ROSTER_SHOW") then EmFor@0: -- EmFor@0: -- Process Guild info EmFor@0: -- EmFor@0: --CensusPlus_Msg( " SHOW GUILD " ); EmFor@0: CensusPlus_ProcessGuildResults(); EmFor@0: EmFor@0: elseif (event == "GUILD_ROSTER_UPDATE") then EmFor@0: -- EmFor@0: -- Process Guild info EmFor@0: -- EmFor@0: --CensusPlus_Msg( " UPDATE GUILD " ); EmFor@0: if(not CP_updatingGuild ) then EmFor@0: CP_updatingGuild = 1; EmFor@0: CensusPlus_ProcessGuildResults(); EmFor@0: CP_updatingGuild = nil; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: elseif ( event == "VARIABLES_LOADED" ) then EmFor@0: -- EmFor@0: -- Initialize our variables EmFor@0: -- EmFor@0: CensusPlus_InitializeVariables(); EmFor@0: elseif( event == "ZONE_CHANGED_NEW_AREA" ) then EmFor@0: -- EmFor@0: -- We need to check to see if we entered a battleground EmFor@0: -- EmFor@0: CensusPlus_CheckForBattleground(); EmFor@0: elseif( event == "UPDATE_BATTLEFIELD_STATUS" ) then EmFor@0: CensusPlus_UpdateBattleGroundInfo(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- ProcessTarget -- called when UNIT_FOCUS event is fired EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ProcessTarget( unit ) EmFor@0: -- have to totally disable this due to X-server bg's EmFor@0: if( true ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: if ( UnitIsPlayer(unit) == nil or (not UnitIsPlayer(unit)) or unit == "player" or unit == nil ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: local sightingData = CensusPlus_CollectSightingData( unit ); EmFor@0: if( sightingData == nil or sightingData.faction == nil ) then EmFor@0: return EmFor@0: end EmFor@0: EmFor@0: if (sightingData ~= nil and (sightingData.faction == "Alliance" or sightingData.faction == "Horde")) then EmFor@0: EmFor@0: -- EmFor@0: -- Do a quick check to see if this is an MC'd person EmFor@0: -- EmFor@0: if( sightingData.faction ~= g_FactionCheck[sightingData.race] ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: if( sightingData.guild == nil ) then EmFor@0: sightingData.guild = ""; EmFor@0: end EmFor@0: -- EmFor@0: -- Get the portion of the database for this server EmFor@0: -- EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: local realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: if (realmDatabase == nil) then EmFor@0: CensusPlus_Database["Servers"][realmName] = {}; EmFor@0: realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this faction EmFor@0: -- EmFor@0: local factionDatabase = realmDatabase[sightingData.faction]; EmFor@0: if (factionDatabase == nil) then EmFor@0: realmDatabase[sightingData.faction] = {}; EmFor@0: factionDatabase = realmDatabase[sightingData.faction]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get racial database EmFor@0: -- EmFor@0: local raceDatabase = factionDatabase[sightingData.race]; EmFor@0: if (raceDatabase == nil) then EmFor@0: factionDatabase[sightingData.race] = {}; EmFor@0: raceDatabase = factionDatabase[sightingData.race]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get class database EmFor@0: -- EmFor@0: local classDatabase = raceDatabase[sightingData.class]; EmFor@0: if (classDatabase == nil) then EmFor@0: raceDatabase[sightingData.class] = {}; EmFor@0: classDatabase = raceDatabase[sightingData.class]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get this player's entry EmFor@0: -- EmFor@0: local entry = classDatabase[sightingData.name]; EmFor@0: if (entry == nil) then EmFor@0: classDatabase[sightingData.name] = {}; EmFor@0: entry = classDatabase[sightingData.name]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Update the information EmFor@0: -- EmFor@0: entry[1] = sightingData.level; EmFor@0: entry[2] = sightingData.guild; EmFor@0: entry[3] = CensusPlus_DetermineServerDate() .. ""; EmFor@0: EmFor@0: entry[7] = CensusPlus_DetermineServerDate() .. ""; EmFor@0: EmFor@0: -- EmFor@0: -- Update their rank info EmFor@0: -- EmFor@0: rankNumber = UnitPVPRank(unit); EmFor@0: if( rankNumber ~= 0 ) then EmFor@0: -- rankName= GetPVPRankInfo( rankNumber ) EmFor@0: entry[8] = rankNumber; -- slot 8 will be current rank EmFor@0: else EmFor@0: entry[8] = 0; -- slot 8 will be current rank EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Trigger an update on the inspect honor frame to get honor information EmFor@0: -- EmFor@0: if ( UnitIsPlayer( unit ) and sightingData.level >= 30 EmFor@0: and CheckInteractDistance( unit, 1) EmFor@0: and not UnitIsUnit("player", unit) and unit == "target" EmFor@0: and g_CensusPlusLastTarget == nil EmFor@0: and g_CensusPlusLastTargetName == nil EmFor@0: and CensusPlus_IsInspectLoaded() ) then EmFor@0: NotifyInspect(unit); EmFor@0: InspectFrame.unit = unit; EmFor@0: if ( not HasInspectHonorData() ) then EmFor@0: g_CensusPlusLastTarget = entry; EmFor@0: g_CensusPlusLastTargetName = sightingData.name; EmFor@0: RequestInspectHonorData(); EmFor@0: else EmFor@0: InspectHonorFrame_Update(); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Gather targeting data EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_CollectSightingData(unit) EmFor@0: if ( UnitIsPlayer(unit) and UnitName(unit) ~= "Unknown Entity" ) then EmFor@0: return { EmFor@0: name=UnitName(unit), EmFor@0: level=UnitLevel(unit), EmFor@0: sex=UnitSex(unit), EmFor@0: race=UnitRace(unit), EmFor@0: class=UnitClass(unit), EmFor@0: guild=GetGuildInfo(unit), EmFor@0: faction=UnitFactionGroup(unit) EmFor@0: }; EmFor@0: else EmFor@0: return nil; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Initialize our primary save variables -- called when VARIABLES_LOADED event is fired EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_InitializeVariables() EmFor@0: EmFor@0: if( CensusPlus_Database["Servers"] == nil ) then EmFor@0: CensusPlus_Database["Servers"] = {}; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Times"] ~= nil ) then EmFor@0: CensusPlus_Database["Times"] = nil; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["TimesPlus"] == nil ) then EmFor@0: CensusPlus_Database["TimesPlus"] = {}; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_BGInfo == nil ) then EmFor@0: CensusPlus_BGInfo = {}; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Make sure info is last so it will be first in the output so we can grab the version number EmFor@0: -- EmFor@0: if( CensusPlus_Database["Info"] == nil ) then EmFor@0: CensusPlus_Database["Info"] = {}; EmFor@0: end EmFor@0: CensusPlus_Database["Info"]["Version"] = CensusPlus_VERSION; EmFor@0: CensusPlus_Database["Info"]["ClientLocale"] = GetLocale(); EmFor@0: if( CensusPlus_Database["Info"]["ClientLocale"] == "enUS" and GetCVar("realmList") == "eu.logon.worldofwarcraft.com" ) then EmFor@0: CensusPlus_Database["Info"]["ClientLocale"] = "enGB"; EmFor@0: end EmFor@0: if( CensusPlus_Database["Info"]["LoginServer"] ~= nil ) then EmFor@0: -- already present, make sure it equals, and if EmFor@0: -- not, force a purge EmFor@0: if( CensusPlus_Database["Info"]["LoginServer"] ~= GetCVar("realmList") ) then EmFor@0: -- EmFor@0: -- We have to nuke the data in the case that someone is playing on both EmFor@0: -- US and EU servers EmFor@0: -- EmFor@0: CensusPlus_DoPurge() EmFor@0: end EmFor@0: end EmFor@0: CensusPlus_Database["Info"]["LoginServer"] = GetCVar("realmList"); EmFor@0: EmFor@0: local firstVersionRun = CensusPlus_Database["Info"][g_InterfaceVersion]; EmFor@0: local localeSetting = CensusPlus_Database["Info"]["Locale"]; EmFor@0: if( localeSetting == "??" ) then EmFor@0: -- We had problems previously.. we must purge =( EmFor@0: CensusPlus_DoPurge(); EmFor@0: localeSetting = nil; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Have a new way to detect locale, yay! EmFor@0: -- EmFor@0: if( CensusPlus_Database["Info"]["ClientLocale"] == "enUS" ) then EmFor@0: CensusPlus_VerifyLocale( "US" ); EmFor@0: CensusPlus_Database["Info"]["Locale"] = "US"; EmFor@0: elseif( CensusPlus_Database["Info"]["ClientLocale"] == "enGB" or EmFor@0: CensusPlus_Database["Info"]["ClientLocale"] == "frFR" or EmFor@0: CensusPlus_Database["Info"]["ClientLocale"] == "deDE" or EmFor@0: CensusPlus_Database["Info"]["ClientLocale"] == "esES" ) then EmFor@0: CensusPlus_VerifyLocale( "EU" ); EmFor@0: CensusPlus_Database["Info"]["Locale"] = "EU"; EmFor@0: else EmFor@0: CensusPlus_VerifyLocale( "??" ); EmFor@0: CensusPlus_Database["Info"]["Locale"] = "??"; EmFor@0: end EmFor@0: EmFor@0: if( firstVersionRun == nil and g_InterfaceVersion == 21000 ) then EmFor@0: -- EmFor@0: -- Clean out all character entries that are irregular EmFor@0: -- EmFor@0: CensusPlus_CleanChars(); EmFor@0: CensusPlus_Database["Info"][g_InterfaceVersion] = true; EmFor@0: end EmFor@0: EmFor@0: local locale = CensusPlus_Database["Info"]["Locale"]; EmFor@0: CensusPlus_SelectLocale( CensusPlus_Database["Info"]["Locale"], true ); EmFor@0: EmFor@0: local miniStart = CensusPlus_Database["Info"]["MiniStart"]; EmFor@0: if( miniStart == nil ) then EmFor@0: miniStart = 0; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["AutoCensus"] == nil ) then EmFor@0: CensusPlus_Database["Info"]["AutoCensus"] = false; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["AutoCensusTimer"] == nil ) then EmFor@0: CensusPlus_Database["Info"]["AutoCensusTimer"] = 1800; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["CensusButtonPosition"] == nil ) then EmFor@0: CensusPlus_Database["Info"]["CensusButtonPosition"] = 370; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["CensusButtonShown"] == nil ) then EmFor@0: CensusPlus_Database["Info"]["CensusButtonShown"] = 1; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["CensusButtonShown"] == 1 ) then EmFor@0: CensusButtonFrame:Show(); EmFor@0: else EmFor@0: CensusButtonFrame:Hide(); EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["UseLogBars"] == nil ) then EmFor@0: CensusPlus_Database["Info"]["UseLogBars"] = 1; EmFor@0: end EmFor@0: CP_OptionUseLogarithmicBars:SetChecked( CensusPlus_Database["Info"]["UseLogBars"] ); EmFor@0: EmFor@0: CensusPlus_AutoStart(miniStart); EmFor@0: EmFor@0: if( miniStart ) and (not Khaos) then EmFor@0: CensusPlus_Msg(" V"..CensusPlus_VERSION..CENSUSPlus_MSG1); EmFor@0: end EmFor@0: EmFor@0: g_VariablesLoaded = true; EmFor@0: EmFor@0: CensusPlus_CheckTZ(); EmFor@0: EmFor@0: InitConstantTables(); EmFor@0: EmFor@0: CP_OptionAutoShowMinimapButton:SetChecked(CensusPlus_Database["Info"]["CensusButtonShown"]); EmFor@0: -- CP_SliderButtonPos:SetValue(CensusPlus_Database["Info"]["CensusButtonPosition"]); EmFor@0: EmFor@0: if( CensusPlus_PerCharInfo["PlayFinishSound"] == nil ) then EmFor@0: CensusPlus_PerCharInfo["PlayFinishSound"] = true; EmFor@0: end EmFor@0: EmFor@0: CP_OptionPlaySoundOnCompleteButton:SetChecked( CensusPlus_PerCharInfo["PlayFinishSound"] ); EmFor@0: EmFor@0: if( CensusPlus_PerCharInfo["Verbose"] == nil ) then EmFor@0: CensusPlus_PerCharInfo["Verbose"] = false; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- If we are in a guild, attempt to gather the guild roster data EmFor@0: -- EmFor@0: if (IsInGuild()) then EmFor@0: GuildRoster(); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Prune times if we have too many EmFor@0: -- EmFor@0: CensusPlus_PruneTimes(); EmFor@0: EmFor@0: -- EmFor@0: -- Prune BG info if we have too many EmFor@0: -- EmFor@0: CensusPlus_PruneBGInfo(); EmFor@0: EmFor@0: -- EmFor@0: -- Check for WhoLib since it does not play nice with C+ EmFor@0: -- EmFor@0: CensusPlus_CheckForWhoLib(); EmFor@0: CensusPlus_CheckForPrat(); EmFor@0: EmFor@0: CensusPlus_Unhandled = nil; EmFor@0: CensusPlus_Unhandled = {}; EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_CheckForWhoLib() EmFor@0: if( WhoLibByALeX and WhoLibByALeX.AskWho ) then EmFor@0: g_WhoLibLoaded = true; EmFor@0: CensusPlus_Msg( "ACE WhoLib detected - WhoLib does not play nice with other mods and as such, some WhoLib functionality must be disabled while a Census scan is in progress." ); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_CheckForPrat() EmFor@0: if( Prat ) then EmFor@0: g_PratLoaded = true; EmFor@0: CensusPlus_Msg( "Prat detected. CensusPlus will attempt to capture the 3 or less /who results that are displayed in chat, but may be unsuccessful." ); EmFor@0: end EmFor@0: end EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Call on the update event EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_OnUpdate() EmFor@0: if( g_VariablesLoaded and g_IsCensusPlusInProgress == false and CensusPlus_Database["Info"]["AutoCensus"] == true and g_LastCensusRun < time() - CensusPlus_Database["Info"]["AutoCensusTimer"] ) then EmFor@0: CensusPlus_Take_OnClick(); EmFor@0: end EmFor@0: EmFor@0: if (g_IsCensusPlusInProgress == true and g_CensusPlusPaused == false and g_CensusPlusManuallyPaused == false ) then EmFor@0: EmFor@0: -- EmFor@0: -- update our progress EmFor@0: -- EmFor@0: local numJobs = table.getn(g_JobQueue); EmFor@0: if( numJobs > 0 ) then EmFor@0: CensusPlusScanProgress:SetText(format(CENSUSPlus_SCAN_PROGRESS, numJobs, CensusPlus_CreateWhoText( g_JobQueue[numJobs] ) )); EmFor@0: end EmFor@0: EmFor@0: if( g_ReturnedZero == true ) then EmFor@0: g_ReturnedZero = false; EmFor@0: -- EmFor@0: -- Determine if there is any more work to do EmFor@0: -- EmFor@0: if (numJobs > 0) then EmFor@0: -- EmFor@0: -- Remove the top job from the queue and send it EmFor@0: -- EmFor@0: local job = g_JobQueue[numJobs]; EmFor@0: table.remove(g_JobQueue); EmFor@0: local whoText = CensusPlus_CreateWhoText(job); EmFor@0: EmFor@0: -- EmFor@0: -- Zap our current job EmFor@0: -- EmFor@0: g_CurrentJob = nil; EmFor@0: EmFor@0: g_CurrentJob = job; EmFor@0: g_WaitingForWhoUpdate = true; EmFor@0: EmFor@0: CensusPlus_SendWho(whoText); EmFor@0: g_WhoAttempts = 0; EmFor@0: else EmFor@0: -- EmFor@0: -- We are all done, hide the friends frame and report our results EmFor@0: -- EmFor@0: if( CensusPlus_PerCharInfo["PlayFinishSound"] ) then EmFor@0: PlaySoundFile("Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg") EmFor@0: end EmFor@0: EmFor@0: CensusPlus_DoTimeCounts(); EmFor@0: CensusPlus_DisplayResults(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: local now = GetTime(); EmFor@0: local delta = now - g_LastOnUpdateTime; EmFor@0: if (not g_WaitingForWhoUpdate or delta > CensusPlus_UPDATEDELAY) then EmFor@0: g_LastOnUpdateTime = now; EmFor@0: if (g_WaitingForWhoUpdate == true ) then EmFor@0: EmFor@0: -- EmFor@0: -- First check to see if we are waiting for an override EmFor@0: -- EmFor@0: if( g_WaitingForOverrideUpdate == true ) then EmFor@0: CensusPlus_SendWho( g_CensusWhoOverrideMsg ); EmFor@0: else EmFor@0: -- EmFor@0: -- Resend /who command EmFor@0: -- EmFor@0: g_WhoAttempts = g_WhoAttempts + 1; EmFor@0: local whoText = CensusPlus_CreateWhoText(g_CurrentJob); EmFor@0: if( CensusPlus_PerCharInfo["Verbose"] == true ) then EmFor@0: CensusPlus_Msg(CENSUSPlus_WAITING); EmFor@0: end EmFor@0: if( g_WhoAttempts < 2 ) then EmFor@0: CensusPlus_SendWho(whoText); EmFor@0: else EmFor@0: g_WaitingForWhoUpdate = false; EmFor@0: end EmFor@0: end EmFor@0: else EmFor@0: EmFor@0: -- EmFor@0: -- Check to see if we have an override waiting EmFor@0: -- EmFor@0: if( g_CensusWhoOverrideMsg ~= nil ) then EmFor@0: CensusPlus_SendWho( g_CensusWhoOverrideMsg ); EmFor@0: g_WaitingForOverrideUpdate = true; EmFor@0: g_WaitingForWhoUpdate = true; EmFor@0: else EmFor@0: -- EmFor@0: -- Determine if there is any more work to do EmFor@0: -- EmFor@0: local numJobs = table.getn(g_JobQueue); EmFor@0: if (numJobs > 0) then EmFor@0: -- EmFor@0: -- Remove the top job from the queue and send it EmFor@0: -- EmFor@0: local job = g_JobQueue[numJobs]; EmFor@0: table.remove(g_JobQueue); EmFor@0: local whoText = CensusPlus_CreateWhoText(job); EmFor@0: g_CurrentJob = nil; EmFor@0: g_CurrentJob = job; EmFor@0: g_WaitingForWhoUpdate = true; EmFor@0: CensusPlus_SendWho(whoText); EmFor@0: g_WaitingForWhoUpdate = true; EmFor@0: g_WhoAttempts = 0; EmFor@0: else EmFor@0: -- EmFor@0: -- We are all done, hide the friends frame and report our results EmFor@0: -- EmFor@0: if( CensusPlus_PerCharInfo["PlayFinishSound"] ) then EmFor@0: PlaySoundFile("Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg") EmFor@0: end EmFor@0: EmFor@0: CensusPlus_DoTimeCounts(); EmFor@0: CensusPlus_DisplayResults(); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Take final tally EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DoTimeCounts() EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: -- Zero out the times EmFor@0: g_TimeDatabase[CENSUSPlus_DRUID] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_HUNTER] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_MAGE] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_PRIEST] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_ROGUE] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WARLOCK] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WARRIOR] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_SHAMAN] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_PALADIN] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_WarsongGulch] = 0; EmFor@0: g_TimeDatabase[CENSUSPlus_AlteracValley]= 0; EmFor@0: g_TimeDatabase[CENSUSPlus_ArathiBasin] = 0; EmFor@0: EmFor@0: g_NumUpdatedCharacters = 0; EmFor@0: EmFor@0: for charName, charClass in pairs(g_TempCount) do EmFor@0: if (CENSUSPlusFemale[charClass] ~= nil) then EmFor@0: charClass = CENSUSPlusFemale[charClass]; EmFor@0: end EmFor@0: g_TimeDatabase[charClass] = g_TimeDatabase[charClass] + 1; EmFor@0: g_NumUpdatedCharacters = g_NumUpdatedCharacters + 1; EmFor@0: end EmFor@0: EmFor@0: -- Collect some zone info EmFor@0: for charName, charZone in pairs(g_TempZoneCount) do EmFor@0: if( charZone == CENSUSPlus_WarsongGulch or charZone == CENSUSPlus_AlteracValley or charZone == CENSUSPlus_ArathiBasin ) then EmFor@0: g_TimeDatabase[charZone] = g_TimeDatabase[charZone] + 1; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: if( CensusPlus_Database["TimesPlus"][realmName] == nil ) then EmFor@0: CensusPlus_Database["TimesPlus"][realmName]= {}; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")] == nil ) then EmFor@0: CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")] = {}; EmFor@0: end EmFor@0: EmFor@0: local hour, minute = GetGameTime(); EmFor@0: -- CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")]["" .. hour .. ""] = g_TimeDatabase; EmFor@0: CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")][CensusPlus_DetermineServerDate() .. "&" .. hour .. ":" .. minute .. ":00"] = EmFor@0: g_TimeDatabase[CENSUSPlus_DRUID] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_HUNTER] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_MAGE] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_PRIEST] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_ROGUE] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_WARLOCK] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_WARRIOR] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_SHAMAN] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_PALADIN] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_WarsongGulch] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_AlteracValley] .. "&" .. EmFor@0: g_TimeDatabase[CENSUSPlus_ArathiBasin]; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Add the contents of the guild results to the database EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ProcessGuildResults() EmFor@0: EmFor@0: if( g_VariablesLoaded == false ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["Locale"] == nil ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- Grab temp var EmFor@0: -- EmFor@0: local showOfflineTemp = GetGuildRosterShowOffline(); EmFor@0: SetGuildRosterShowOffline(1); EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- Walk through the guild info EmFor@0: -- EmFor@0: local numGuildMembers = GetNumGuildMembers(); EmFor@0: -- CensusPlus_Msg("Processing "..numGuildMembers.." guild members."); EmFor@0: EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: CensusPlus_Database["Guilds"] = nil; EmFor@0: if( CensusPlus_Database["Guilds"] == nil ) then EmFor@0: CensusPlus_Database["Guilds"] = {}; EmFor@0: end EmFor@0: EmFor@0: if (CensusPlus_Database["Guilds"][realmName] == nil) then EmFor@0: CensusPlus_Database["Guilds"][realmName] = {}; EmFor@0: end EmFor@0: EmFor@0: local guildRealmDatabase = CensusPlus_Database["Guilds"][realmName]; EmFor@0: if (guildRealmDatabase == nil) then EmFor@0: CensusPlus_Database["Guilds"][realmName] = {}; EmFor@0: guildRealmDatabase = CensusPlus_Database["Guilds"][realmName]; EmFor@0: end EmFor@0: EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: if( factionGroup == nil ) then EmFor@0: CensusPlus_Database["Guilds"] = nil; EmFor@0: SetGuildRosterShowOffline(showOfflineTemp); EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: local factionDatabase = guildRealmDatabase[factionGroup]; EmFor@0: if (factionDatabase == nil) then EmFor@0: guildRealmDatabase[factionGroup] = {}; EmFor@0: factionDatabase = guildRealmDatabase[factionGroup]; EmFor@0: end EmFor@0: EmFor@0: CensusPlus_Database["Guilds"][realmName][factionGroup] = nil; EmFor@0: CensusPlus_Database["Guilds"][realmName][factionGroup] = {}; EmFor@0: EmFor@0: factionDatabase = CensusPlus_Database["Guilds"][realmName][factionGroup]; EmFor@0: EmFor@0: local Ginfo = GetGuildInfo("player"); EmFor@0: if( Ginfo == nil ) then EmFor@0: CensusPlus_Database["Guilds"] = nil; EmFor@0: SetGuildRosterShowOffline(showOfflineTemp); EmFor@0: return; EmFor@0: end EmFor@0: local guildDatabase = factionDatabase[Ginfo]; EmFor@0: if (guildDatabase == nil) then EmFor@0: factionDatabase[Ginfo] = {}; EmFor@0: guildDatabase = factionDatabase[Ginfo]; EmFor@0: end EmFor@0: EmFor@0: local info = guildDatabase["GuildInfo"]; EmFor@0: if (info == nil) then EmFor@0: guildDatabase["GuildInfo"] = {}; EmFor@0: info = guildDatabase["GuildInfo"]; EmFor@0: end EmFor@0: EmFor@0: info["Update"] = date( "%m-%d-%Y", time()) .. ""; EmFor@0: info["ShowOnline"] = 1; -- Variable comes from FriendsFrame EmFor@0: EmFor@0: guildDatabase["Members"] = nil; EmFor@0: guildDatabase["Members"] = {}; EmFor@0: EmFor@0: local members = guildDatabase["Members"]; EmFor@0: EmFor@0: for index = 1, numGuildMembers, 1 do EmFor@0: local name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(index); EmFor@0: EmFor@0: if( members[name] == nil ) then EmFor@0: members[name] = {}; EmFor@0: end EmFor@0: EmFor@0: -- CensusPlus_Msg( "Name =>" .. name ); EmFor@0: -- CensusPlus_Msg( "rank =>" .. rank ); EmFor@0: -- CensusPlus_Msg( "rankIndex =>" .. rankIndex ); EmFor@0: -- CensusPlus_Msg( "level =>" .. level ); EmFor@0: -- CensusPlus_Msg( "class =>" .. class ); EmFor@0: members[name]["Rank"] = rank; EmFor@0: members[name]["RankIndex"] = rankIndex; EmFor@0: members[name]["Level"]= level; EmFor@0: members[name]["Class"]= class; EmFor@0: -- members[name]["Zone"]= zone; EmFor@0: -- members[name]["Note"]= CensusPlus_SafeSet( note ); EmFor@0: -- members[name]["OfficerNote"]= CensusPlus_SafeSet( officernote ); EmFor@0: -- members[name]["Online"]= online; EmFor@0: -- members[name]["Status"]= CensusPlus_SafeSet( status ); EmFor@0: end EmFor@0: EmFor@0: SetGuildRosterShowOffline(showOfflineTemp); EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_SafeCheck( param ) EmFor@0: if( param == nil ) then EmFor@0: return "nil"; EmFor@0: else EmFor@0: return param; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Add the contents of the who results to the database EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ProcessWhoResults() EmFor@0: EmFor@0: -- EmFor@0: -- If we are in a BG then stop a census EmFor@0: -- EmFor@0: if( g_CurrentlyInBG and g_IsCensusPlusInProgress ) then EmFor@0: g_LastCensusRun = time()-600; EmFor@0: CensusPlus_Msg(CENSUSPlus_ISINBG); EmFor@0: CensusPlus_StopCensus( ); EmFor@0: end EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this server EmFor@0: -- EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: local realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: if (realmDatabase == nil) then EmFor@0: CensusPlus_Database["Servers"][realmName] = {}; EmFor@0: realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this faction EmFor@0: -- EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: if( factionGroup == nil ) then EmFor@0: return EmFor@0: end EmFor@0: EmFor@0: local factionDatabase = realmDatabase[factionGroup]; EmFor@0: if (factionDatabase == nil) then EmFor@0: realmDatabase[factionGroup] = {}; EmFor@0: factionDatabase = realmDatabase[factionGroup]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Walk through all the who results EmFor@0: -- EmFor@0: local numWhoResults = GetNumWhoResults(); EmFor@0: if( CensusPlus_PerCharInfo["Verbose"] == true ) then EmFor@0: CensusPlus_Msg(format(CENSUSPlus_PROCESSING, numWhoResults)); EmFor@0: end EmFor@0: for i = 1, numWhoResults, 1 do EmFor@0: -- EmFor@0: -- Get who result entry EmFor@0: -- EmFor@0: local name, guild, level, race, class, zone, group = GetWhoInfo(i); EmFor@0: EmFor@0: if (CENSUSPlusFemale[race] ~= nil) then EmFor@0: race = CENSUSPlusFemale[race]; EmFor@0: end EmFor@0: EmFor@0: if (CENSUSPlusFemale[class] ~= nil) then EmFor@0: class = CENSUSPlusFemale[class]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Test the name for possible color coding EmFor@0: -- EmFor@0: -- for example |cffff0000Rollie|r EmFor@0: local karma_check = string.find( name, "|cff" ); EmFor@0: if( karma_check ~= nil ) then EmFor@0: name = string.sub( name, 11, -3 ); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Further check for problematic chars EmFor@0: -- EmFor@0: local pattern = "[0-9\| -]"; EmFor@0: if( string.find( name, pattern ) ~= nil ) then EmFor@0: if( not g_ProblematicMessageShown ) then EmFor@0: CensusPlus_Msg( "This name is problematic => " .. name .. ", name skipped. This message will only be shown once." ); EmFor@0: g_ProblematicMessageShown = true; EmFor@0: end EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- Get racial database EmFor@0: -- EmFor@0: local raceDatabase = factionDatabase[race]; EmFor@0: if (raceDatabase == nil) then EmFor@0: factionDatabase[race] = {}; EmFor@0: raceDatabase = factionDatabase[race]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get class database EmFor@0: -- EmFor@0: local classDatabase = raceDatabase[class]; EmFor@0: if (classDatabase == nil) then EmFor@0: raceDatabase[class] = {}; EmFor@0: classDatabase = raceDatabase[class]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get this player's entry EmFor@0: -- EmFor@0: local entry = classDatabase[name]; EmFor@0: if (entry == nil) then EmFor@0: classDatabase[name] = {}; EmFor@0: entry = classDatabase[name]; EmFor@0: g_NumNewCharacters = g_NumNewCharacters + 1; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Update the information EmFor@0: -- EmFor@0: entry[1] = level; EmFor@0: entry[2] = guild; EmFor@0: -- local hour, minute = GetGameTime(); EmFor@0: entry[3] = CensusPlus_DetermineServerDate() .. ""; EmFor@0: EmFor@0: g_TempCount[name] = class; EmFor@0: g_TempZoneCount[name] = zone; EmFor@0: EmFor@0: end EmFor@0: -- CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Process a single entry EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function WR_ProcessSingleEntry( name, level, race, class, guild, zone ) EmFor@0: EmFor@0: CensusPlus_Msg2( "Processing " .. name ); EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: if (CENSUSPlusFemale[race] ~= nil) then EmFor@0: race = CENSUSPlusFemale[race]; EmFor@0: end EmFor@0: EmFor@0: if (CENSUSPlusFemale[class] ~= nil) then EmFor@0: class = CENSUSPlusFemale[class]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this server EmFor@0: -- EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: local realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: if (realmDatabase == nil) then EmFor@0: CensusPlus_Database["Servers"][realmName] = {}; EmFor@0: realmDatabase = CensusPlus_Database["Servers"][realmName]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this faction EmFor@0: -- EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: if( factionGroup == nil ) then EmFor@0: return EmFor@0: end EmFor@0: EmFor@0: local factionDatabase = realmDatabase[factionGroup]; EmFor@0: if (factionDatabase == nil) then EmFor@0: realmDatabase[factionGroup] = {}; EmFor@0: factionDatabase = realmDatabase[factionGroup]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Remove the trailing ] that I can't remove through patterns EmFor@0: -- EmFor@0: -- local oldname = name; EmFor@0: -- name = string.sub( oldname, 1, string.len(oldname) - 3 ); EmFor@0: EmFor@0: level = tonumber( level ); EmFor@0: EmFor@0: -- EmFor@0: -- Test the name for possible color coding EmFor@0: -- EmFor@0: -- for example |cffff0000Rollie|r EmFor@0: local karma_check = string.find( name, "|cff" ); EmFor@0: if( karma_check ~= nil ) then EmFor@0: name = string.sub( name, 11, -3 ); EmFor@0: end EmFor@0: EmFor@0: local pattern = "[0-9\| :]"; EmFor@0: if( string.find( name, pattern ) ~= nil ) then EmFor@0: if( not g_ProblematicMessageShown ) then EmFor@0: CensusPlus_Msg( "This name is problematic => " .. name .. ", name skipped. This message will only be shown once." ); EmFor@0: end EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Do a race check just to be sure this is working EmFor@0: -- EmFor@0: if( g_FactionCheck[race] == nil ) then EmFor@0: CensusPlus_Msg( "Found an unknown race (" .. race .. "), please tell Rollie at WarcraftRealms.com" ); EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get racial database EmFor@0: -- EmFor@0: local raceDatabase = factionDatabase[race]; EmFor@0: if (raceDatabase == nil) then EmFor@0: factionDatabase[race] = {}; EmFor@0: raceDatabase = factionDatabase[race]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get class database EmFor@0: -- EmFor@0: local classDatabase = raceDatabase[class]; EmFor@0: if (classDatabase == nil) then EmFor@0: raceDatabase[class] = {}; EmFor@0: classDatabase = raceDatabase[class]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get this player's entry EmFor@0: -- EmFor@0: local entry = classDatabase[name]; EmFor@0: if (entry == nil) then EmFor@0: classDatabase[name] = {}; EmFor@0: entry = classDatabase[name]; EmFor@0: g_NumNewCharacters = g_NumNewCharacters + 1; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Update the information EmFor@0: -- EmFor@0: entry[1] = level; EmFor@0: entry[2] = guild; EmFor@0: -- local hour, minute = GetGameTime(); EmFor@0: entry[3] = CensusPlus_DetermineServerDate() .. ""; EmFor@0: EmFor@0: g_TempCount[name] = class; EmFor@0: g_TempZoneCount[name] = zone; EmFor@0: EmFor@0: -- CensusPlus_Msg2( "Processed " .. name ); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Find a guild in the CensusPlus_Guilds array by name EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local function FindGuildByName(name) EmFor@0: local i; EmFor@0: local size = table.getn(CensusPlus_Guilds); EmFor@0: for i = 1, size, 1 do EmFor@0: local entry = CensusPlus_Guilds[i]; EmFor@0: if (entry.m_Name == name) then EmFor@0: return i; EmFor@0: end EmFor@0: end EmFor@0: return nil; EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Add up the total character XP and count EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local g_AccumulateGuildTotals = true; EmFor@0: local function TotalsAccumulator(name, level, guild) EmFor@0: -- EmFor@0: -- Add character to our player list EmFor@0: -- EmFor@0: CensusPlus_AddPlayerToList( name, level, guild ); EmFor@0: EmFor@0: if( g_TotalCharacterXPPerLevel[level] ) then EmFor@0: InitConstantTables(); EmFor@0: end EmFor@0: EmFor@0: local totalCharacterXP = g_TotalCharacterXPPerLevel[level]; EmFor@0: if( totalCharacterXP == nil ) then EmFor@0: totalCharacterXP = 0; EmFor@0: end EmFor@0: if( g_TotalCharacterXP == nil ) then EmFor@0: g_TotalCharacterXP = 0; EmFor@0: end EmFor@0: g_TotalCharacterXP = g_TotalCharacterXP + totalCharacterXP; EmFor@0: g_TotalCount = g_TotalCount + 1; EmFor@0: if (g_AccumulateGuildTotals and (guild ~= nil)) then EmFor@0: local index = FindGuildByName(guild); EmFor@0: if (index == nil) then EmFor@0: local size = table.getn(CensusPlus_Guilds); EmFor@0: index = size + 1; EmFor@0: CensusPlus_Guilds[index] = {m_Name = guild, m_TotalCharacterXP = 0, m_Count = 0}; EmFor@0: end EmFor@0: local entry = CensusPlus_Guilds[index]; EmFor@0: entry.m_TotalCharacterXP = entry.m_TotalCharacterXP + totalCharacterXP; EmFor@0: entry.m_Count = entry.m_Count + 1; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Predicate function which can be used to compare two guilds for sorting EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local function GuildPredicate(lhs, rhs) EmFor@0: -- EmFor@0: -- nil references are always less than EmFor@0: -- EmFor@0: if (lhs == nil) then EmFor@0: if (rhs == nil) then EmFor@0: return false; EmFor@0: else EmFor@0: return true; EmFor@0: end EmFor@0: elseif (rhs == nil) then EmFor@0: return false; EmFor@0: end EmFor@0: -- EmFor@0: -- Sort by total XP first EmFor@0: -- EmFor@0: if (rhs.m_TotalCharacterXP < lhs.m_TotalCharacterXP) then EmFor@0: return true; EmFor@0: elseif (lhs.m_TotalCharacterXP < rhs.m_TotalCharacterXP) then EmFor@0: return false; EmFor@0: end EmFor@0: -- EmFor@0: -- Sort by name EmFor@0: -- EmFor@0: if (lhs.m_Name < rhs.m_Name) then EmFor@0: return true; EmFor@0: elseif (rhs.m_Name < lhs.m_Name) then EmFor@0: return false; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- identical EmFor@0: -- EmFor@0: return false; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Another accumulator for adding up XP and counts EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: local g_AccumulatorCount = 0; EmFor@0: local g_AccumulatorXPTotal = 0; EmFor@0: local function CensusPlus_Accumulator(name, level, guild) EmFor@0: if( g_TotalCharacterXPPerLevel[level] == nil ) then EmFor@0: InitConstantTables(); EmFor@0: end EmFor@0: local totalCharacterXP = g_TotalCharacterXPPerLevel[level]; EmFor@0: if( totalCharacterXP == nil or g_TotalCharacterXPPerLevel[level] == nil ) then EmFor@0: return; EmFor@0: end EmFor@0: g_AccumulatorXPTotal = g_AccumulatorXPTotal + totalCharacterXP; EmFor@0: g_AccumulatorCount = g_AccumulatorCount + 1; EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Reset the above accumulator EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ResetAccumulator() EmFor@0: g_AccumulatorCount = 0; EmFor@0: g_AccumulatorXPTotal = 0; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Search the character database using the search criteria and update display EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_UpdateView() EmFor@0: EmFor@0: -- EmFor@0: -- No need to do anything if the window is not open EmFor@0: -- EmFor@0: if( not CensusPlus:IsVisible() ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get realm and faction EmFor@0: -- EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: if( realmName == nil ) then EmFor@0: return; EmFor@0: end EmFor@0: CensusPlusRealmName:SetText(format(CENSUSPlus_REALMNAME, realmName)); EmFor@0: EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: if( factionGroup == nil ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@13: --rm EmFor@13: CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); EmFor@13: EmFor@0: CensusPlusFactionName:SetText(format(CENSUSPlus_FACTION, factionGroup)); EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["Locale"] ~= nil ) then EmFor@0: CensusPlusLocaleName:SetText(format(CENSUSPlus_LOCALE, CensusPlus_Database["Info"]["Locale"])); EmFor@0: end EmFor@0: EmFor@0: local guildKey = nil; EmFor@0: local raceKey = nil; EmFor@0: local classKey = nil; EmFor@0: local levelKey = nil; EmFor@0: g_TotalCharacterXP = 0; EmFor@0: g_TotalCount = 0; EmFor@0: EmFor@0: -- EmFor@0: -- Has the user selected a guild? EmFor@0: -- EmFor@0: if (g_GuildSelected ~= nil ) then EmFor@0: guildKey = g_GuildSelected; EmFor@0: end EmFor@0: if (g_RaceSelected > 0) then EmFor@0: local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); EmFor@0: raceKey = thisFactionRaces[g_RaceSelected]; EmFor@0: end EmFor@0: if (g_ClassSelected > 0) then EmFor@0: local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup); EmFor@0: classKey = thisFactionClasses[g_ClassSelected]; EmFor@0: end EmFor@0: if (g_LevelSelected > 0 or g_LevelSelected < 0) then EmFor@0: levelKey = g_LevelSelected; EmFor@0: end EmFor@0: EmFor@0: debugprofilestart(); EmFor@0: EmFor@0: -- EmFor@0: -- Has the user added any search criteria? EmFor@0: -- EmFor@0: if ((guildKey ~= nil) or (raceKey ~= nil) or (classKey ~= nil) or (levelKey ~= nil)) then EmFor@0: -- EmFor@0: -- Get totals for this criteria EmFor@0: -- EmFor@0: CensusPlus_Guilds = {}; EmFor@0: g_AccumulateGuildTotals = true; EmFor@0: CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, classKey, guildKey, levelKey, TotalsAccumulator); EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: else EmFor@0: -- EmFor@0: -- Get the overall totals and find guild information EmFor@0: -- EmFor@0: CensusPlus_Guilds = {}; EmFor@0: g_AccumulateGuildTotals = true; EmFor@0: CensusPlus_ForAllCharacters(realmName, factionGroup, nil, nil, nil, nil, TotalsAccumulator); EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: local size = table.getn(CensusPlus_Guilds); EmFor@0: if (size) then EmFor@0: table.sort(CensusPlus_Guilds, GuildPredicate); EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Time to sort guilds " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: local levelSearch = nil; EmFor@0: if (levelKey ~= nil) then EmFor@0: levelSearch = " ("..CENSUSPlus_LEVEL..": "; EmFor@0: local level = levelKey; EmFor@0: if (levelKey < 0) then EmFor@0: levelSearch = levelSearch.."!"; EmFor@0: level = 0 - levelKey; EmFor@0: end EmFor@0: levelSearch = levelSearch..level..")"; EmFor@0: end EmFor@0: EmFor@0: local totalCharactersText = nil; EmFor@0: if (levelSearch ~= nil) then EmFor@0: totalCharactersText = format(CENSUSPlus_TOTALCHAR, g_TotalCount)..levelSearch; EmFor@0: else EmFor@0: totalCharactersText = format(CENSUSPlus_TOTALCHAR, g_TotalCount); EmFor@0: end EmFor@0: CensusPlusTotalCharacters:SetText(totalCharactersText); EmFor@0: CensusPlusTotalCharacterXP:SetText(format(CENSUSPlus_TOTALCHARXP, g_TotalCharacterXP)); EmFor@0: CensusPlus_UpdateGuildButtons(); EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Update Guilds " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Accumulate totals for each race EmFor@0: -- EmFor@0: local maxCount = 0; EmFor@0: local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); EmFor@0: local numRaces = table.getn(thisFactionRaces); EmFor@0: for i = 1, numRaces, 1 do EmFor@0: local race = thisFactionRaces[i]; EmFor@0: CensusPlus_ResetAccumulator(); EmFor@0: if ((raceKey == nil) or (raceKey == race)) then EmFor@0: CensusPlus_ForAllCharacters(realmName, factionGroup, race, classKey, guildKey, levelKey, CensusPlus_Accumulator); EmFor@0: end EmFor@0: if (g_AccumulatorCount > maxCount) then EmFor@0: maxCount = g_AccumulatorCount; EmFor@0: end EmFor@0: g_RaceCount[i] = g_AccumulatorCount; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Update race bars EmFor@0: -- EmFor@0: for i = 1, numRaces, 1 do EmFor@0: local race = thisFactionRaces[i]; EmFor@0: local buttonName = "CensusPlusRaceBar"..i; EmFor@13: EmFor@0: local button = getglobal(buttonName); EmFor@0: local thisCount = g_RaceCount[i]; EmFor@0: if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then EmFor@0: local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) ); EmFor@0: if (height < 2 or height == nil ) then height = 2; end EmFor@0: button:SetHeight(height); EmFor@0: button:Show(); EmFor@0: else EmFor@0: button:Hide(); EmFor@0: end EmFor@0: local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[race]; EmFor@13: EmFor@13: EmFor@0: local legendName = "CensusPlusRaceLegend"..i; EmFor@0: local legend = getglobal(legendName); EmFor@0: legend:SetNormalTexture(normalTextureName); EmFor@0: if (g_RaceSelected == i) then EmFor@0: legend:LockHighlight(); EmFor@0: else EmFor@0: legend:UnlockHighlight(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Update Races " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Accumulate totals for each class EmFor@0: -- EmFor@0: local maxCount = 0; EmFor@0: local thisFactionClasss = CensusPlus_GetFactionClasses(factionGroup); EmFor@0: local numClasses = table.getn(thisFactionClasss); EmFor@0: for i = 1, numClasses, 1 do EmFor@0: local class = thisFactionClasss[i]; EmFor@0: CensusPlus_ResetAccumulator(); EmFor@0: if ((classKey == nil) or (classKey == class)) then EmFor@0: CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, class, guildKey, levelKey, CensusPlus_Accumulator); EmFor@0: end EmFor@0: if (g_AccumulatorCount > maxCount) then EmFor@0: maxCount = g_AccumulatorCount; EmFor@0: end EmFor@0: g_ClassCount[i] = g_AccumulatorCount; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Update class bars EmFor@0: -- EmFor@0: for i = 1, numClasses, 1 do EmFor@0: local class = thisFactionClasss[i]; EmFor@0: EmFor@0: local buttonName = "CensusPlusClassBar"..i; EmFor@0: local button = getglobal(buttonName); EmFor@0: local thisCount = g_ClassCount[i]; EmFor@0: if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then EmFor@0: local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) ); EmFor@0: if (height < 2 or height == nil ) then height = 2; end EmFor@0: button:SetHeight(height); EmFor@0: button:Show(); EmFor@0: else EmFor@0: button:Hide(); EmFor@0: end EmFor@0: EmFor@0: local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[class]; EmFor@0: local legendName = "CensusPlusClassLegend"..i; EmFor@0: local legend = getglobal(legendName); EmFor@0: legend:SetNormalTexture(normalTextureName); EmFor@0: if (g_ClassSelected == i) then EmFor@0: legend:LockHighlight(); EmFor@0: else EmFor@0: legend:UnlockHighlight(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Update Classes " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Accumulate totals for each level EmFor@0: -- EmFor@0: local maxCount = 0; EmFor@0: for i = 1, MAX_CHARACTER_LEVEL, 1 do EmFor@0: if ((levelKey == nil) or (levelKey == i) or (levelKey < 0 and levelKey + i ~= 0)) then EmFor@0: CensusPlus_ResetAccumulator(); EmFor@0: CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, classKey, guildKey, i, CensusPlus_Accumulator); EmFor@0: if (g_AccumulatorCount > maxCount) then EmFor@0: maxCount = g_AccumulatorCount; EmFor@0: end EmFor@0: g_LevelCount[i] = g_AccumulatorCount; EmFor@0: else EmFor@0: g_LevelCount[i] = 0; EmFor@0: end EmFor@0: end EmFor@0: local logMaxCount = math.log( maxCount / 3 + 1 ); EmFor@0: EmFor@0: -- EmFor@0: -- To make the data easier to use, we need to massage it a bit for levels EmFor@0: -- EmFor@0: EmFor@0: EmFor@0: -- EmFor@0: -- Update level bars EmFor@0: -- EmFor@0: for i = 1, MAX_CHARACTER_LEVEL, 1 do EmFor@0: local buttonName = "CensusPlusLevelBar"..i; EmFor@0: local buttonEmptyName = "CensusPlusLevelBarEmpty"..i; EmFor@0: local button = getglobal(buttonName); EmFor@0: local emptyButton = getglobal(buttonEmptyName); EmFor@0: local thisCount = g_LevelCount[i]; EmFor@0: if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then EmFor@0: local height = floor(( math.log(thisCount / 3 + 1) * CensusPlus_MAXBARHEIGHT / logMaxCount) ); EmFor@0: if( CensusPlus_Database["Info"]["UseLogBars"] == 0 ) then EmFor@0: height = floor(( CensusPlus_MAXBARHEIGHT * (thisCount) / maxCount) ); EmFor@0: end EmFor@0: EmFor@0: if (height < 2 or height == nil ) then height = 2; end EmFor@0: button:SetHeight(height); EmFor@0: button:Show(); EmFor@0: if (emptyButton ~= nil) then EmFor@0: emptyButton:Hide(); EmFor@0: end EmFor@0: else EmFor@0: button:Hide(); EmFor@0: if (emptyButton ~= nil) then EmFor@0: emptyButton:SetHeight(CensusPlus_MAXBARHEIGHT); EmFor@0: emptyButton:Show(); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: if( CensusPlus_EnableProfiling ) then EmFor@0: CensusPlus_Msg( "PROFILE: Update Levels " .. debugprofilestop() / 1000000000 ); EmFor@0: debugprofilestart(); EmFor@0: end EmFor@0: EmFor@0: if( CP_PlayerListWindow:IsVisible() ) then EmFor@0: CensusPlus_PlayerListOnShow(); EmFor@0: end EmFor@0: EmFor@0: debugprofilestop(); EmFor@0: EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Walk the character database and call the callback function for every entry that matches the search criteria EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_ForAllCharacters(realmKey, factionKey, raceKey, classKey, guildKey, levelKey, callback) EmFor@0: for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do EmFor@0: if ((realmKey == nil) or (realmKey == realmName)) then EmFor@0: for factionName, factionDatabase in pairs(realmDatabase) do EmFor@0: if ((factionKey == nil) or (factionKey == factionName)) then EmFor@0: for raceName, raceDatabase in pairs(factionDatabase) do EmFor@0: if ((raceKey == nil) or (raceKey == raceName)) then EmFor@0: for className, classDatabase in pairs(raceDatabase) do EmFor@0: if ((classKey == nil) or (classKey == className)) then EmFor@0: for characterName, character in pairs(classDatabase) do EmFor@0: local characterGuild = character[2]; EmFor@0: if ((guildKey == nil) or (guildKey == characterGuild)) then EmFor@0: local characterLevel = character[1]; EmFor@0: if( characterLevel == nil ) then EmFor@0: characterLevel = 0; EmFor@0: end EmFor@0: if ((levelKey == nil) or (levelKey == characterLevel) or (levelKey < 0 and levelKey + characterLevel ~= 0)) then EmFor@0: callback(characterName, characterLevel, characterGuild, raceName, className, character[3] ); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Race legend clicked EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnClickRace( this ) EmFor@0: local id = this:GetID(); EmFor@0: if (id == g_RaceSelected) then EmFor@0: g_RaceSelected = 0; EmFor@0: else EmFor@0: g_RaceSelected = id; EmFor@0: end EmFor@0: CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Class legend clicked EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnClickClass( this ) EmFor@0: local id = this:GetID(); EmFor@0: if (id == g_ClassSelected) then EmFor@0: g_ClassSelected = 0; EmFor@0: else EmFor@0: g_ClassSelected = id; EmFor@0: end EmFor@0: CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Level bar loaded EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnLoadLevel( self ) EmFor@13: self:RegisterForClicks("LeftButtonUp","RightButtonUp"); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Level bar clicked EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnClickLevel(this, button) EmFor@0: local id = this:GetID(); EmFor@0: if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then EmFor@0: g_LevelSelected = 0; EmFor@0: elseif (button == "RightButton") then EmFor@0: g_LevelSelected = 0 - id; EmFor@0: else EmFor@0: g_LevelSelected = id; EmFor@0: end EmFor@0: CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Race tooltip EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnEnterRace( this ) EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup); EmFor@0: local id = this:GetID(); EmFor@0: local raceName = thisFactionRaces[id]; EmFor@0: local count = g_RaceCount[id]; EmFor@0: if (count ~= nil) then EmFor@0: local percent = floor((count / g_TotalCount) * 100); EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(raceName.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Class tooltip EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnEnterClass( self ) EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup); EmFor@13: local id = self:GetID(); EmFor@0: local className = thisFactionClasses[id]; EmFor@0: local count = g_ClassCount[id]; EmFor@0: if (count ~= nil) then EmFor@0: local percent = floor((count / g_TotalCount) * 100); EmFor@13: GameTooltip:SetOwner(self, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Level tooltip EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_OnEnterLevel( this ) EmFor@0: local id = this:GetID(); EmFor@0: local count = g_LevelCount[id]; EmFor@0: if (count ~= nil) then EmFor@13: local percent = floor((count / g_TotalCount) * 100); EmFor@0: GameTooltip:SetOwner(this, "ANCHOR_RIGHT"); EmFor@0: GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0); EmFor@0: GameTooltip:Show(); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Clicked a guild button EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@6: function CensusPlus_GuildButton_OnClick( this ) EmFor@0: local id = this:GetID(); EmFor@0: local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame); EmFor@0: local newSelection = id + offset; EmFor@0: local guildKey = CensusPlus_Guilds[newSelection].m_Name; EmFor@0: if (g_GuildSelected ~= guildKey) then EmFor@0: g_GuildSelected = guildKey; EmFor@0: else EmFor@0: g_GuildSelected = nil; EmFor@0: end EmFor@0: CensusPlus_UpdateView(); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Update the guild button contents EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_UpdateGuildButtons() EmFor@0: -- EmFor@0: -- Determine where the scroll bar is EmFor@0: -- EmFor@0: local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame); EmFor@0: -- EmFor@0: -- Walk through all the rows in the frame EmFor@0: -- EmFor@0: local size = table.getn(CensusPlus_Guilds); EmFor@0: local i = 1; EmFor@0: while (i <= CensusPlus_NUMGUILDBUTTONS) do EmFor@0: -- EmFor@0: -- Get the index to the ad displayed in this row EmFor@0: -- EmFor@0: local iGuild = i + offset; EmFor@0: -- EmFor@0: -- Get the button on this row EmFor@0: -- EmFor@0: local button = getglobal("CensusPlusGuildButton"..i); EmFor@0: -- EmFor@0: -- Is there a valid guild on this row? EmFor@0: -- EmFor@0: if (iGuild <= size) then EmFor@0: local guild = CensusPlus_Guilds[iGuild]; EmFor@0: -- EmFor@0: -- Update the button text EmFor@0: -- EmFor@0: button:Show(); EmFor@0: local textField = "CensusPlusGuildButton"..i.."Text"; EmFor@0: if (guild.m_Name == "") then EmFor@0: getglobal(textField):SetText(CENSUSPlus_UNGUILDED); EmFor@0: else EmFor@0: getglobal(textField):SetText(guild.m_Name); EmFor@0: end EmFor@0: -- EmFor@0: -- If this is the guild, highlight it EmFor@0: -- EmFor@0: local guildName = CensusPlus_Guilds[iGuild].m_Name EmFor@0: if (g_GuildSelected == guildName) then EmFor@0: button:LockHighlight(); EmFor@0: else EmFor@0: button:UnlockHighlight(); EmFor@0: end EmFor@0: else EmFor@0: -- EmFor@0: -- Hide the button EmFor@0: -- EmFor@0: button:Hide(); EmFor@0: end EmFor@0: -- EmFor@0: -- Next row EmFor@0: -- EmFor@0: i = i + 1; EmFor@0: end EmFor@0: -- EmFor@0: -- Update the scroll bar EmFor@0: -- EmFor@0: FauxScrollFrame_Update(CensusPlusGuildScrollFrame, size, CensusPlus_NUMGUILDBUTTONS, CensusPlus_GUILDBUTTONSIZEY); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Census_AutoStartOnLoad EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function Census_AutoStartOnLoad( ) EmFor@0: CP_OptionAutoStartButton:SetChecked(g_MiniOnStart); EmFor@0: if( g_MiniOnStart == 1 ) then EmFor@0: MiniCensusPlus:Show(); EmFor@0: else EmFor@0: MiniCensusPlus:Hide(); EmFor@0: end EmFor@0: MiniCensusPlus:Hide(); EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_AutoStart - Set the auto-start option EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_AutoStart( check ) EmFor@0: g_MiniOnStart = check; EmFor@0: CensusPlus_Database["Info"]["MiniStart"] = g_MiniOnStart; EmFor@0: Census_AutoStartOnLoad(); EmFor@0: end EmFor@0: EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_VerifyLocale - Set the locale (US or EU) EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_VerifyLocale( locale ) EmFor@0: if( CensusPlus_Database["Info"]["Locale"] ~= locale ) then EmFor@0: -- EmFor@0: -- Purge EmFor@0: -- EmFor@0: CensusPlus_DoPurge() EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_SelectLocale - Set the locale (US or EU) EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_SelectLocale( locale, auto ) EmFor@0: EmFor@0: if( not auto ) then EmFor@0: CensusPlus_Msg( "You have set your locale to " .. locale .. " from " .. g_CensusPlusLocale ); EmFor@0: end EmFor@0: EmFor@0: g_CensusPlusLocale = locale; EmFor@0: if( g_CensusPlusLocale == "EU" ) then EmFor@0: g_CensusPlusLocale = g_CensusPlusLocale .. "-"; EmFor@0: else EmFor@0: g_CensusPlusLocale = ""; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["Locale"] ~= locale ) then EmFor@0: if( not ( CensusPlus_Database["Info"]["Locale"] == nil and locale == "US" ) ) then EmFor@0: CensusPlus_Msg( "Locale differs from previous setting, purging database." ); EmFor@0: CensusPlus_DoPurge(); EmFor@0: CensusPlus_Database["Info"]["Locale"] = locale; EmFor@0: end EmFor@0: end EmFor@0: CensusPlus_Database["Info"]["Locale"] = locale; EmFor@0: EmFor@0: textLine = getglobal("CensusPlusText"); EmFor@0: textLine:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale ); EmFor@0: EmFor@0: if(( CENSUSPlus_DWARF == "Nain" or CENSUSPlus_DWARF == "Zwerg" ) and GetLocale() == "usEN") then EmFor@0: CensusPlus_Msg( "You appear to have a US Census version, yet your localization is set to French or German." ); EmFor@0: CensusPlus_Msg( "Please do not upload stats to WarcraftRealms until this has been resolved." ); EmFor@0: CensusPlus_Msg( "If this is incorrect, please let Rollie know at www.WarcraftRealms.com about your situation so he can make corrections." ); EmFor@0: end EmFor@0: EmFor@0: CP_EU_US_Version:Hide(); EmFor@0: EmFor@0: end EmFor@0: EmFor@0: ---------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Walk the character database prune all characters entries that are older than 30 days EmFor@0: -- EmFor@0: --------------------------------------------------------------------------------- EmFor@0: function CensusPlus_PruneData( nDays, sServer ) EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: local thisRealmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: EmFor@0: if( sServer == 1 ) then EmFor@0: nDays = 0; EmFor@0: end EmFor@0: EmFor@0: local pruneTime = 24 * 60 * 60 * nDays; EmFor@0: EmFor@0: for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do EmFor@0: if ((realmKey == nil) or (realmKey == realmName)) then EmFor@0: for factionName, factionDatabase in pairs(realmDatabase) do EmFor@0: if ((factionKey == nil) or (factionKey == factionName)) then EmFor@0: for raceName, raceDatabase in pairs(factionDatabase) do EmFor@0: if ((raceKey == nil) or (raceKey == raceName)) then EmFor@0: for className, classDatabase in pairs(raceDatabase) do EmFor@0: if ((classKey == nil) or (classKey == className)) then EmFor@0: for characterName, character in pairs(classDatabase) do EmFor@0: if( characterName ~= nil ) then EmFor@0: if( sServer == 1 ) then EmFor@0: if( realmName ~= thisRealmName ) then EmFor@0: CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName ); EmFor@0: end EmFor@0: else EmFor@0: local lastSeen = character[3]; -- 2005-05-02 EmFor@0: EmFor@0: local tYear, tMonth, tDay; EmFor@0: tYear = string.sub( lastSeen, 1, 4 ); EmFor@0: tMonth = string.sub( lastSeen, 6, 7 ); EmFor@0: tDay = string.sub( lastSeen, 9 ); EmFor@0: EmFor@0: local lastSeenTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} ); EmFor@0: EmFor@0: if( time() - lastSeenTime > pruneTime ) then EmFor@0: CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName ); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: CensusPlus_PruneTimes(); EmFor@0: CensusPlus_UpdateView(); EmFor@0: CensusPlus_PruneTheData(); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Prune the accumulation EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_AccumulatePruneData( realm, faction, race, class, name ) EmFor@0: local pruneData = {}; EmFor@0: pruneData.realm = realm; EmFor@0: pruneData.faction = faction; EmFor@0: pruneData.race = race; EmFor@0: pruneData.class = class; EmFor@0: pruneData.name = name; EmFor@0: EmFor@0: table.insert(g_AccumulatedPruneData, pruneData); EmFor@0: end EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Prune the accumulation EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_PruneTheData() EmFor@0: local num = table.getn(g_AccumulatedPruneData); EmFor@0: CensusPlus_Msg( format(CENSUSPlus_PRUNEINFO, num ) ); EmFor@0: while( num > 0 )do EmFor@0: -- EmFor@0: -- Remove the top job from the queue and send it EmFor@0: -- EmFor@0: local pruneData = g_AccumulatedPruneData[num]; EmFor@0: EmFor@0: CensusPlus_Database["Servers"][pruneData.realm][pruneData.faction][pruneData.race][pruneData.class][pruneData.name] = {}; EmFor@0: CensusPlus_Database["Servers"][pruneData.realm][pruneData.faction][pruneData.race][pruneData.class][pruneData.name] = nil; EmFor@0: EmFor@0: table.remove(g_AccumulatedPruneData); EmFor@0: num = table.getn(g_AccumulatedPruneData); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Prune time entries EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_PruneTimes() EmFor@0: local pruneDays = 60*60*24*21; -- num seconds EmFor@0: EmFor@0: local accumTimesData = {}; EmFor@0: for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do EmFor@0: if (realmName ~= nil ) then EmFor@0: for factionName, factionDatabase in pairs(realmDatabase) do EmFor@0: if ( factionName ~= nil) then EmFor@0: for moment, count in pairs( factionDatabase ) do EmFor@0: -- Moment is in format of YYYY-MM-DD&HH:MM EmFor@0: local test = string.sub( moment, 1, 2 ); EmFor@0: local tYear, tMonth, tDay; EmFor@0: tYear = string.sub( moment, 1, 4 ); EmFor@0: tMonth = string.sub( moment, 6, 7 ); EmFor@0: tDay = string.sub( moment, 9, 10 ); EmFor@0: local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} ); EmFor@0: EmFor@0: if( time() - momentTime > pruneDays ) then EmFor@0: -- cull entry EmFor@0: local pruneData = {}; EmFor@0: pruneData.realm = realmName; EmFor@0: pruneData.faction = factionName; EmFor@0: pruneData.entry = moment; EmFor@0: table.insert(accumTimesData, pruneData); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: local num = table.getn(accumTimesData); EmFor@0: while( num > 0 )do EmFor@0: local pruneData = accumTimesData[num]; EmFor@0: EmFor@0: CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = {}; EmFor@0: CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = nil; EmFor@0: EmFor@0: table.remove(accumTimesData); EmFor@0: num = table.getn(accumTimesData); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: function CensusPlus_CheckForBattleground() EmFor@0: EmFor@0: EmFor@0: -- CensusPlus_Msg( "Checking for BG" ); EmFor@0: g_CurrentlyInBG_Msg = false; EmFor@0: EmFor@0: local battlefieldTime = GetBattlefieldInstanceRunTime(); EmFor@0: if( battlefieldTime > 0 ) then EmFor@0: -- EmFor@0: -- We are in a battleground so cancel the current take EmFor@0: -- EmFor@0: g_CurrentlyInBG = true; EmFor@0: else EmFor@0: if( GetBattlefieldStatInfo(1) ~= nil ) then EmFor@0: g_CurrentlyInBG = true; EmFor@0: else EmFor@0: g_CurrentlyInBG = false; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_IsInspectLoaded() EmFor@0: if (IsAddOnLoaded("Blizzard_InspectUI")) then EmFor@0: --ChatFrame1:AddMessage("Inspect Loaded"); EmFor@0: return true; EmFor@0: end EmFor@0: EmFor@0: if (CensusPlus_Database["Info"]["LoadInspect"] ~= nil and CensusPlus_Database["Info"]["LoadInspect"] == true) then EmFor@0: --ChatFrame1:AddMessage("Loading Inspect Frame"); EmFor@0: LoadAddOn("Blizzard_InspectUI"); EmFor@0: end EmFor@0: EmFor@0: --ChatFrame1:AddMessage("Inspect Not Loaded"); EmFor@0: return false; EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_IsTalentLoaded() EmFor@0: if (IsAddOnLoaded("Blizzard_TalentUI")) then EmFor@0: --ChatFrame1:AddMessage("Talent Loaded"); EmFor@0: return true; EmFor@0: end EmFor@0: EmFor@0: if (CensusPlus_Database["Info"]["LoadTalent"] ~= nil and CensusPlus_Database["Info"]["LoadTalent"] == true) then EmFor@0: --ChatFrame1:AddMessage("Loading Talent Frame"); EmFor@0: LoadAddOn("Blizzard_TalentUI"); EmFor@0: end EmFor@0: EmFor@0: --ChatFrame1:AddMessage("Talent Not Loaded"); EmFor@0: return false; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: EmFor@0: function showAllUnitBuffs(sUnitname) EmFor@0: local iIterator = 1 EmFor@0: DEFAULT_CHAT_FRAME:AddMessage(format("[%s] Buffs", sUnitname)) EmFor@0: while (UnitBuff(sUnitname, iIterator)) do EmFor@0: DEFAULT_CHAT_FRAME:AddMessage(UnitBuff(sUnitname, iIterator), 1, 1, 0) EmFor@0: iIterator = iIterator + 1 EmFor@0: end EmFor@0: DEFAULT_CHAT_FRAME:AddMessage("---", 1, 1, 0) EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_GetUTCDateTimeStr() EmFor@0: return date( "!%Y-%m-%d %H:%M", time() ); EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- CensusPlus_DetermineServerDate EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_DetermineServerDate() EmFor@0: EmFor@0: CensusPlus_CheckTZ(); EmFor@0: EmFor@0: local strDate; EmFor@0: local TZOffset = g_CensusPlusTZOffset; EmFor@0: EmFor@0: -- EmFor@0: -- Timezone offsets should fall into distinct numbers for now EmFor@0: -- And now that we know if they are playing on US or EU servers EmFor@0: -- we can be even better estimates EmFor@0: -- EmFor@0: EmFor@0: -- EmFor@0: -- For US servers, the offset should be either -9 to -5 or 16/19 depending on DST for NA times EmFor@0: -- and for oceana it is +11/-13 EmFor@0: -- EU servers are either +1 or 0 or -23 depending on DST EmFor@0: -- EmFor@0: EmFor@0: if( CensusPlus_Database["Info"]["Locale"] == "US" ) then EmFor@0: if( TZOffset > 12 ) then EmFor@0: -- NA server times but wrong day EmFor@0: TZOffset = TZOffset - 24; EmFor@0: elseif( TZOffset < -11 ) then EmFor@0: -- Oceana times but wrong day EmFor@0: TZOffset = 24 - TZOffset; EmFor@0: end EmFor@0: else EmFor@0: if( TZOffset == -23 ) then EmFor@0: TZOffset = 1; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: -- Now, take the TZOffset and modify our time to give us server date EmFor@0: strDate = date( "!%Y-%m-%d", time() + (TZOffset * 3600 ) ); EmFor@0: EmFor@0: -- local strDate2 = date( "%Y-%m-%d : %H:%M", time() ); EmFor@0: -- CensusPlus_Msg("Server date = " .. strDate .. " for TZOffset : " .. TZOffset .. " curr local: " .. strDate2 ); EmFor@0: EmFor@0: return strDate; EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- Check time zone EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_CheckTZ() EmFor@0: EmFor@0: local UTCTimeHour = date( "!%H", time() ); EmFor@0: local LocTimeHour = date( "%H", time() ); EmFor@0: local hour, minute = GetGameTime(); EmFor@0: EmFor@0: local locDiff = LocTimeHour - UTCTimeHour; EmFor@0: local servDiff = hour - UTCTimeHour; EmFor@0: g_CensusPlusTZOffset = servDiff; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: function CensusPlus_UpdateBattleGroundInfo() EmFor@0: local status, mapName, instanceID, lowestLevel, highestLevel; EmFor@0: local numberQueues = 0; EmFor@0: local waitTime, timeInQueue; EmFor@0: local map = {}; EmFor@0: EmFor@0: if( g_CensusPlusLocale == "N/A" ) then EmFor@0: return; EmFor@0: end EmFor@0: EmFor@0: for i=1, MAX_BATTLEFIELD_QUEUES do EmFor@0: map = {}; EmFor@0: status, mapName, instanceID, lowestLevel, highestLevel = GetBattlefieldStatus(i); EmFor@0: EmFor@0: if ( status ~= "none" ) then EmFor@0: numberQueues = numberQueues+1; EmFor@0: EmFor@0: if ( status == "queued" ) then EmFor@0: -- Update queue info EmFor@0: waitTime = GetBattlefieldEstimatedWaitTime(i)/1000; EmFor@0: timeInQueue = GetBattlefieldTimeWaited(i)/1000; EmFor@0: EmFor@0: map[0] = waitTime; EmFor@0: map[1] = timeInQueue; EmFor@0: map[2] = mapName; EmFor@0: map[3] = "Inactive"; EmFor@0: EmFor@0: -- CensusPlus_Msg( "INSERT " .. mapName .. " : " .. map[2] .. " to " .. i ); EmFor@0: CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i] = map; EmFor@0: EmFor@0: elseif ( status == "confirm" ) then EmFor@0: -- In the battleground EmFor@0: -- Check to see if we know we've already entered, and if so, add info to EmFor@0: -- our database EmFor@0: map = CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i]; EmFor@0: EmFor@0: -- CensusPlus_Msg( "ACTIVE " .. mapName ); EmFor@0: -- CensusPlus_Msg( map[2] ); EmFor@0: if( map ~= nil and map[3] == "Inactive" ) then EmFor@0: map[3] = "Active"; EmFor@0: EmFor@0: CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i] = map; EmFor@0: EmFor@0: -- Make an entry in our database EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this server EmFor@0: -- EmFor@0: local realmName = g_CensusPlusLocale .. GetCVar("realmName"); EmFor@0: if (CensusPlus_BGInfo[realmName] == nil) then EmFor@0: CensusPlus_BGInfo[realmName] = {}; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Get the portion of the database for this faction EmFor@0: -- EmFor@0: local factionGroup = UnitFactionGroup("player"); EmFor@0: if( factionGroup ~= nil ) then EmFor@0: if (CensusPlus_BGInfo[realmName][factionGroup] == nil) then EmFor@0: CensusPlus_BGInfo[realmName][factionGroup] = {}; EmFor@0: end EmFor@0: EmFor@0: local playerLevel = UnitLevel( "player" ); EmFor@0: if( playerLevel ~= nil ) then EmFor@0: if (CensusPlus_BGInfo[realmName][factionGroup][playerLevel] == nil) then EmFor@0: CensusPlus_BGInfo[realmName][factionGroup][playerLevel] = {}; EmFor@0: end EmFor@0: EmFor@0: local hour, minute = GetGameTime(); EmFor@0: CensusPlus_BGInfo[realmName][factionGroup][playerLevel][CensusPlus_DetermineServerDate() .. "&" .. hour .. ":" .. minute .. ":00"] = EmFor@0: map[2] .. "&" .. map[0] .. "&" .. map[1] .. "&" .. lowestLevel .. "&" .. highestLevel; EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_PruneBGInfo() EmFor@0: local pruneDays = 60*60*24*21; -- num seconds EmFor@0: EmFor@0: local accumData = {}; EmFor@0: for realmName, realmDatabase in pairs(CensusPlus_BGInfo) do EmFor@0: if (realmName ~= nil and table.getn( realmDatabase ) > 0 ) then EmFor@0: for factionName, factionDatabase in pairs(realmDatabase) do EmFor@0: if ( factionName ~= nil and table.getn( factionDatabase ) > 0 ) then EmFor@0: for level, levelDatabase in pairs( factionDatabase ) do EmFor@0: if( level ~= nil and table.getn( levelDatabase ) > 0 ) then EmFor@0: for moment, data in pairs( levelDatabase ) do EmFor@0: -- Moment is in format of YYYY-MM-DD&HH:MM EmFor@0: local test = string.sub( moment, 1, 2 ); EmFor@0: local tYear, tMonth, tDay; EmFor@0: tYear = string.sub( moment, 1, 4 ); EmFor@0: tMonth = string.sub( moment, 6, 7 ); EmFor@0: tDay = string.sub( moment, 9, 10 ); EmFor@0: local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} ); EmFor@0: EmFor@0: if( time() - momentTime > pruneDays ) then EmFor@0: -- cull entry EmFor@0: local pruneData = {}; EmFor@0: pruneData.realm = realmName; EmFor@0: pruneData.faction = factionName; EmFor@0: pruneData.level = level; EmFor@0: pruneData.entry = moment; EmFor@0: table.insert(accumData, pruneData); EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: local num = table.getn(accumData); EmFor@0: while( num > 0 )do EmFor@0: local pruneData = accumData[num]; EmFor@0: EmFor@0: CensusPlus_BGInfo[pruneData.realm][pruneData.faction][pruneData.level][pruneData.entry] = {}; EmFor@0: CensusPlus_BGInfo[pruneData.realm][pruneData.faction][pruneData.level][pruneData.entry] = nil; EmFor@0: EmFor@0: table.remove(accumData); EmFor@0: num = table.getn(accumData); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: -- EmFor@0: -- My Test function EmFor@0: -- EmFor@0: ----------------------------------------------------------------------------------- EmFor@0: function CensusPlus_Test( val ) EmFor@0: EmFor@0: EmFor@0: -- local file = "Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg"; EmFor@0: -- CensusPlus_Msg( "Play sound " .. file ); EmFor@0: -- PlaySoundFile( file ); EmFor@0: EmFor@0: local test = {}; EmFor@0: test[1] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Tauren Warrior - Hellfire Peninsula"; EmFor@0: test[2] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Tauren Warrior - Hellfire Peninsula"; EmFor@0: test[3] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[4] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[5] = "|Hplayer:Frostbiite|h[Frostbiite]|h: Level 61 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[6] = "|Hplayer:Dynanite|h[Dynanite]|h: Level 60 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[7] = "|Hplayer:Physco|h[Physco]|h: Level 61 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[8] = "|Hplayer:Gordoom|h[Gordoom]|h: Level 60 Troll Death Knight - Hellfire Peninsula"; EmFor@0: test[9] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Death Knight - Nagrand"; EmFor@0: test[10] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Death Knight - Nagrand"; EmFor@0: test[11] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Death Knight - Nagrand"; EmFor@0: test[12] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Death Knight - Nagrand"; EmFor@0: test[13] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Paladin - Nagrand"; EmFor@0: test[14] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Paladin - Nagrand"; EmFor@0: test[15] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Paladin - Nagrand"; EmFor@0: test[16] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Paladin - Nagrand"; EmFor@0: EmFor@0: EmFor@0: for index, case in pairs(test) do EmFor@0: CensusPlus_Msg( "Checking : " .. case ); EmFor@0: local t = CensusPlus_GatherSingleReturn( case ); EmFor@0: if( t ~= nil ) then EmFor@0: CensusPlus_Msg( index .. " Name : " .. t["NAME"] EmFor@0: .. " L: " .. t["LEVEL"] EmFor@0: .. " R: " .. t["RACE"] EmFor@0: .. " C: " .. t["CLASS"] EmFor@0: .. " G: " .. t["GUILD"] EmFor@0: .. " Z: " .. t["ZONE"] ); EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: EmFor@0: --[[ EmFor@0: local pattern = "[0-9\| ]"; EmFor@0: EmFor@0: local name = "11:58]|r |Hplayer:Azide|h[Azide"; EmFor@0: if( string.find( name, pattern ) ~= nil ) then EmFor@0: CensusPlus_Msg( "This name is problematic => " .. name ); EmFor@0: end EmFor@0: EmFor@0: name = "Rollie"; EmFor@0: if( string.find( name, pattern ) ~= nil ) then EmFor@0: CensusPlus_Msg( "This name is problematic => " .. name ); EmFor@0: else EmFor@0: CensusPlus_Msg( "This name is NOT problematic => " .. name ); EmFor@0: end EmFor@0: ]]-- EmFor@0: EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_GatherSingleReturn( line ) EmFor@0: local t = {}; EmFor@0: local s, e, name, level_text, level, rcg, zone, junk; EmFor@0: local RCG = {}; EmFor@0: local presults = {}; EmFor@0: local RCG_Pattern = "(.+) <(.+)>"; EmFor@0: local possibles = {}; EmFor@0: possibles[1] = "(" .. CENSUSPlus_NIGHTELF .. ")" .. " ([%a%s]+)"; EmFor@0: possibles[2] = "(" .. CENSUSPlus_BLOODELF .. ")" .. " ([%a%s]+)"; EmFor@0: possibles[3] = "(%a+) " .. "(" .. CENSUSPlus_DEATHKNIGHT .. ")"; EmFor@0: possibles[4] = "(%a+) (%a+)"; EmFor@0: EmFor@0: --CensusPlus_Msg2( " CHECKING " .. line ); EmFor@0: EmFor@0: if( g_PratLoaded ) then EmFor@0: s, e, junk, junk, junk, name, junk, junk, level_text, level, rcg, zone = string.find(line, CENSUS_SINGLE_MATCH_PATTERN_PRAT ); EmFor@0: else EmFor@0: s, e, junk, junk, name, level_text, level, rcg, zone = string.find(line, CENSUS_SINGLE_MATCH_PATTERN); EmFor@0: end EmFor@0: if( name ~= nil ) then EmFor@0: -- EmFor@0: -- Now let's break out our race, class & guild EmFor@0: -- EmFor@0: local race_class = rcg; EmFor@0: t["GUILD"] = ''; EmFor@0: t["NAME"] = name; EmFor@0: t["LEVEL"] = level; EmFor@0: t["ZONE"] = zone; EmFor@0: s, e, RCG[0], RCG[1] = string.find(rcg, RCG_Pattern); EmFor@0: if( RCG[0] ~= nil ) then EmFor@0: race_class = RCG[0]; EmFor@0: t["GUILD"] = RCG[1]; EmFor@0: end EmFor@0: EmFor@0: -- EmFor@0: -- Now we need to figure out race/class EmFor@0: -- EmFor@0: for pi, poss in pairs(possibles) do EmFor@0: s, e, presults[0], presults[1] = string.find(race_class, poss); EmFor@0: if( presults[0] ~= nil ) then EmFor@0: -- CensusPlus_Msg( pi .. " 0: " .. presults[0] .. " 1: " .. presults[1]); EmFor@0: t["RACE"] = presults[0]; EmFor@0: t["CLASS"] = presults[1]; EmFor@0: break; EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: -- CensusPlus_Msg2( " IN Fn Name : " .. t["NAME"] .. " L: " .. t["LEVEL"] .. " R: " .. t["RACE"] .. " C: " .. t["CLASS"].. " G: " .. t["GUILD"] .. " Z: " .. t["ZONE"] ); EmFor@0: end EmFor@0: EmFor@0: return t; EmFor@0: end EmFor@0: EmFor@0: EmFor@0: function CensusPlus_SetItemRef(link, text, button) EmFor@0: -- EmFor@0: -- We only care about if they are sending a who, otherwise send on through EmFor@0: -- EmFor@0: if ( g_IsCensusPlusInProgress and strsub(link, 1, 6) == "player" ) then EmFor@0: if ( strsub(link, 1, 6) == "player" ) then EmFor@0: local namelink = strsub(link, 8); EmFor@0: local name, lineid = strsplit(":", namelink); EmFor@0: if ( name and (strlen(name) > 0) ) then EmFor@0: name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3"); EmFor@0: name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2"); EmFor@0: if ( IsShiftKeyDown() ) then EmFor@6: if ( not ChatFrame1EditBox:IsVisible() ) then EmFor@0: -- EmFor@0: -- This is the part we need to snag EmFor@0: -- EmFor@0: EmFor@0: -- EmFor@0: -- Queue up the command to run next EmFor@0: -- EmFor@0: g_CensusWhoOverrideMsg = "n-"..name; EmFor@0: CensusPlus_Msg( CENSUSPlus_OVERRIDE ); EmFor@0: EmFor@0: -- CensusPlus_SendWho("n-"..name); EmFor@0: return; EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: g_SetItemRef_Override( link, text, button ); EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_CleanChars() EmFor@0: EmFor@0: local pattern = "[0-9\| -]"; EmFor@0: local count = 0; EmFor@0: EmFor@0: for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do EmFor@0: if ((realmKey == nil) or (realmKey == realmName)) then EmFor@0: for factionName, factionDatabase in pairs(realmDatabase) do EmFor@0: if ((factionKey == nil) or (factionKey == factionName)) then EmFor@0: for raceName, raceDatabase in pairs(factionDatabase) do EmFor@0: if ((raceKey == nil) or (raceKey == raceName)) then EmFor@0: for className, classDatabase in pairs(raceDatabase) do EmFor@0: if ((classKey == nil) or (classKey == className)) then EmFor@0: for characterName, character in pairs(classDatabase) do EmFor@0: if( characterName ~= nil ) then EmFor@0: if( string.find( characterName, pattern ) ~= nil ) then EmFor@0: CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName ); EmFor@0: count = count + 1; EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: end EmFor@0: EmFor@0: CensusPlus_PruneTheData(); EmFor@0: CensusPlus_Msg( "Found " .. count .. " entries to remove" ); EmFor@0: end EmFor@0: EmFor@0: function CensusPlus_SendWho( msg ) EmFor@0: EmFor@0: if( CensusPlus_PerCharInfo["Verbose"] == true ) then EmFor@0: CensusPlus_Msg(format(CENSUSPlus_SENDING, msg)); EmFor@0: end EmFor@0: EmFor@0: if wholib then EmFor@0: wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent }) EmFor@0: else EmFor@0: SendWho( msg ); EmFor@0: end EmFor@0: end EmFor@6: function CensusPlus_Options_OnMouseUp(self,...) EmFor@13: CensusPlus_Msg('Mouse up'); EmFor@13: if ( self.isMoving ) then EmFor@13: self:StopMovingOrSizing(); EmFor@13: self.isMoving = false; EmFor@13: end EmFor@6: end EmFor@6: function CensusPlus_Options_OnMouseDown(self,arg1,arg2,arg3,...) EmFor@13: if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then EmFor@13: self:StartMoving(); EmFor@13: self.isMoving = true; EmFor@13: end EmFor@6: end EmFor@6: function CensusPlus_Mini_OnMouseDown( self, arg1 ) EmFor@13: if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then EmFor@13: self:StartMoving(); EmFor@13: self.isMoving = true; EmFor@13: end EmFor@6: end EmFor@6: function CensusPlus_Census_OnMouseDown( self, arg1 ) EmFor@13: if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then EmFor@13: self:StartMoving(); EmFor@13: self.isMoving = true; EmFor@13: end EmFor@11: end