annotate CensusPlus.lua @ 12:9ca9973996c8

ignore tool files
author EmFor
date Sun, 14 Aug 2011 12:17:18 +0200
parents 663f782bd903
children 77d2c7423ed5
rev   line source
EmFor@0 1 --[[
EmFor@0 2 CensusPlus for World of Warcraft(tm).
EmFor@0 3
EmFor@0 4 Copyright 2005 - 2007 Cooper Sellers and WarcraftRealms.com
EmFor@0 5
EmFor@0 6 License:
EmFor@0 7 This program is free software; you can redistribute it and/or
EmFor@0 8 modify it under the terms of the GNU General Public License
EmFor@0 9 as published by the Free Software Foundation; either version 2
EmFor@0 10 of the License, or (at your option) any later version.
EmFor@0 11
EmFor@0 12 This program is distributed in the hope that it will be useful,
EmFor@0 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
EmFor@0 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
EmFor@0 15 GNU General Public License for more details.
EmFor@0 16
EmFor@0 17 You should have received a copy of the GNU General Public License
EmFor@0 18 along with this program(see GLP.txt); if not, write to the Free Software
EmFor@0 19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
EmFor@0 20 ]]
EmFor@0 21
EmFor@0 22
EmFor@0 23 ------------------------------------------------------------------------------------
EmFor@0 24 --
EmFor@0 25 -- CensusPlus
EmFor@0 26 -- A WoW UI customization by Cooper Sellers
EmFor@0 27 --
EmFor@0 28 --
EmFor@0 29 ------------------------------------------------------------------------------------
EmFor@0 30
EmFor@0 31 ----------------------------------------------------------------------------------
EmFor@0 32 --
EmFor@0 33 -- EURO vs US localization problem workaround for common server names
EmFor@0 34 --
EmFor@0 35 ---------------------------------------------------------------------------------
EmFor@6 36 local g_InterfaceVersion = 40000;
EmFor@0 37 g_CensusPlusLocale = "N/A"; -- Must read either US or EU
EmFor@0 38 g_CensusPlusTZOffset = -999;
EmFor@0 39 local g_LocaleSet = false;
EmFor@0 40 local g_TZWarningSent = false;
EmFor@0 41
EmFor@0 42
EmFor@0 43 ----------------------------------------------------------------------------------
EmFor@0 44 --
EmFor@0 45 -- Constants
EmFor@0 46 --rm
EmFor@6 47 -- Special guild to search
EmFor@6 48 --local CensusPlus_MYGUILD = "The Last Journey";
EmFor@6 49 local CensusPlus_MYGUILD = "Worgengrauen";
EmFor@0 50 ---------------------------------------------------------------------------------
EmFor@11 51 local CensusPlus_VERSION = "5.0.2"; -- version
EmFor@0 52 local CensusPlus_MAXBARHEIGHT = 128; -- Length of blue bars
EmFor@0 53 local CensusPlus_NUMGUILDBUTTONS = 10; -- How many guild buttons are on the UI?
EmFor@6 54 local MAX_CHARACTER_LEVEL = 85; -- Maximum level a PC can attain
EmFor@0 55 --rm
EmFor@0 56 local MAX_LEVEL_DISPLAY = 255; -- Maximum level a PC can attain
EmFor@11 57 local MAX_WHO_RESULTS = 49; -- Maximum number of who results the server will return
EmFor@0 58 CensusPlus_GUILDBUTTONSIZEY = 16;
EmFor@0 59 local CensusPlus_UPDATEDELAY = 5; -- Delay time between /who messages
EmFor@0 60 local CP_MAX_TIMES = 50;
EmFor@0 61
EmFor@0 62 local g_ServerPrefix = ""; -- US VERSION!!
EmFor@0 63 --local g_ServerPrefix = "EU-"; -- EU VERSION!!
EmFor@0 64
EmFor@0 65 local wholib
EmFor@0 66 ----------------------------------------------------------------------------------
EmFor@0 67 --
EmFor@0 68 -- Print a string to the chat frame
EmFor@0 69 -- msg - message to print
EmFor@0 70 --
EmFor@0 71 ---------------------------------------------------------------------------------
EmFor@0 72 function CensusPlus_Msg(msg)
EmFor@0 73 if( msg == nil ) then
EmFor@0 74 msg = " NIL ";
EmFor@0 75 end
EmFor@0 76 ChatFrame1:AddMessage("Census+: "..msg, 1.0, 1.0, 0.5);
EmFor@0 77 end
EmFor@0 78
EmFor@0 79 function CensusPlus_WhoMsg(msg)
EmFor@0 80 if( msg == nil ) then
EmFor@0 81 msg = " NIL ";
EmFor@0 82 end
EmFor@0 83 ChatFrame1:AddMessage("Census+ Who: "..msg, 0.8, 0.8, 0.1);
EmFor@0 84 end
EmFor@0 85
EmFor@0 86 local function CensusPlus_Msg2( msg )
EmFor@0 87 if( msg == nil ) then
EmFor@0 88 msg = " NIL ";
EmFor@0 89 end
EmFor@0 90 ChatFrame2:AddMessage("Census+: "..msg, 0.5, 1.0, 1.0);
EmFor@0 91 end
EmFor@0 92
EmFor@0 93 ----------------------------------------------------------------------------------
EmFor@0 94 --
EmFor@0 95 -- Global scope variables
EmFor@0 96 --
EmFor@0 97 ---------------------------------------------------------------------------------
EmFor@0 98 CensusPlus_Database = {}; -- Database of all CensusPlus results
EmFor@0 99 CensusPlus_BGInfo = {}; -- Battleground info
EmFor@0 100 CensusPlus_PerCharInfo = {}; -- Per character settings
EmFor@0 101 CensusPlus_Unhandled = {};
EmFor@0 102 local g_TrackUnhandled = false;
EmFor@0 103
EmFor@0 104 ----------------------------------------------------------------------------------
EmFor@0 105 --
EmFor@0 106 -- File scope variables
EmFor@0 107 --
EmFor@0 108 ---------------------------------------------------------------------------------
EmFor@0 109 local g_CensusPlusInitialized; -- Is CensusPlus initialized?
EmFor@0 110 local g_JobQueue = {}; -- The queue of pending jobs
EmFor@0 111 local g_CurrentJob = {}; -- Current job being executed
EmFor@0 112 g_IsCensusPlusInProgress = false; -- Is a CensusPlus in progress?
EmFor@0 113 g_CensusPlusPaused = false; -- Is CensusPlus in progress paused?
EmFor@0 114 g_CensusPlusManuallyPaused = false; -- Is CensusPlus in progress manually paused?
EmFor@0 115 local g_WhoAutoClose = 0; -- AutoClose who window?
EmFor@0 116
EmFor@0 117 local g_NumNewCharacters = 0; -- How many new characters found this CensusPlus
EmFor@0 118 local g_NumUpdatedCharacters = 0; -- How many characters were updated during this CensusPlus
EmFor@0 119
EmFor@0 120 local g_MobXPByLevel = {}; -- XP earned for killing
EmFor@0 121 local g_CharacterXPByLevel = {}; -- XP required to advance through the given level
EmFor@0 122 local g_TotalCharacterXPPerLevel = {}; -- Total XP required to attain the given level
EmFor@0 123
EmFor@0 124 CensusPlus_Guilds = {}; -- All known guild
EmFor@0 125
EmFor@0 126 local g_TotalCharacterXP = 0; -- Total character XP for currently selected search
EmFor@0 127 local g_TotalCount = 0; -- Total number of characters which meet search criteria
EmFor@0 128 local g_RaceCount = {}; -- Totals for each race given search criteria
EmFor@0 129 local g_ClassCount = {}; -- Totals for each class given search criteria
EmFor@0 130 local g_LevelCount = {}; -- Totals for each level given search criteria
EmFor@0 131 local g_TempCount = {};
EmFor@0 132 local g_TempZoneCount = {};
EmFor@0 133
EmFor@0 134 g_GuildSelected = nil; -- Search criteria: Currently selected guild, 0 indicates none
EmFor@0 135 g_RaceSelected = 0; -- Search criteria: Currently selected race, 0 indicates none
EmFor@0 136 g_ClassSelected = 0; -- Search criteria: Currently selected class, 0 indicates none
EmFor@0 137 g_LevelSelected = 0;
EmFor@0 138
EmFor@0 139 local g_LastOnUpdateTime = 0; -- Last time OnUpdate was called
EmFor@0 140 local g_WaitingForWhoUpdate = false; -- Are we waiting for a who update event?
EmFor@0 141
EmFor@0 142 local g_WhoAttempts = 0; -- Counter for detecting stuck who results
EmFor@0 143 local g_MiniOnStart = 1; -- Flag to have the mini-censusP displayed on startup
EmFor@0 144
EmFor@0 145 local g_CompleteCensusStarted = false; -- Flag for counter
EmFor@0 146 local g_TakeHour = 0; -- Our timing hour
EmFor@0 147 local g_TimeDatabase = {}; -- Time database
EmFor@0 148 local g_ResetHour = true; -- Rest hour
EmFor@0 149 local g_VariablesLoaded = false; -- flag to tell us if vars are loaded
EmFor@0 150 local g_FirstRun = true;
EmFor@0 151 local g_LastCensusRun = time() - 1500; -- timer used if auto census is turned on
EmFor@0 152
EmFor@0 153 local g_Pre_FriendsFrameOnHideOverride = nil; -- override for friend's frame to stop the close window sound
EmFor@0 154 local g_Pre_FriendsFrameOnShowOverride = nil; -- override for friend's frame to stop the close window sound
EmFor@0 155 local g_Pre_WhoList_UpdateOverride = nil; -- override for friend's frame to stop the close window sound
EmFor@0 156 local g_Pre_WhoHandler = nil; -- override for submiting a who
EmFor@0 157 local CP_Pre_OnEvent = nil;
EmFor@0 158 local g_Pre_FriendsFrame_Update = nil;
EmFor@0 159 local g_SetItemRef_Override = nil;
EmFor@0 160 local CP_updatingGuild = nil;
EmFor@0 161 g_CensusPlusLastTarget = nil;
EmFor@0 162 g_CensusPlusLastTargetName = nil;
EmFor@0 163 local g_CurrentlyInBG = false;
EmFor@0 164 local g_CurrentlyInBG_Msg = false;
EmFor@0 165 local g_InternalSearchName = nil;
EmFor@0 166 local g_InternalSearchLevel = nil;
EmFor@0 167 local g_InternalSearchCount = 0;
EmFor@0 168 CensusPlus_EnableProfiling = false;
EmFor@0 169 local g_CensusPlus_StartTime = 0;
EmFor@0 170 local g_CensusWhoOverrideMsg = nil;
EmFor@0 171 local g_WaitingForOverrideUpdate = false;
EmFor@0 172 local g_ProblematicMessageShown = false;
EmFor@0 173 local g_WhoLibLoaded = false;
EmFor@0 174 local g_PratLoaded = false;
EmFor@0 175 local g_WhoLibSubvert = nil;
EmFor@0 176 local g_WhoLibSendWhoSubvert = nil;
EmFor@0 177 local g_whoLibResultSubvert = nil;
EmFor@0 178 local g_WhoLibChatSubvert = nil;
EmFor@0 179 local g_WhoLibAskWhoSubvert = nil;
EmFor@0 180
EmFor@0 181 -- Battleground info
EmFor@0 182 CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES = {};
EmFor@0 183
EmFor@0 184 local g_AccumulatedPruneData = {};
EmFor@0 185
EmFor@0 186 g_RaceClassList = { }; -- Used to pick the right icon
EmFor@0 187 g_RaceClassList[CENSUSPlus_DRUID] = 10;
EmFor@0 188 g_RaceClassList[CENSUSPlus_HUNTER] = 11;
EmFor@0 189 g_RaceClassList[CENSUSPlus_MAGE] = 12;
EmFor@0 190 g_RaceClassList[CENSUSPlus_PRIEST] = 13;
EmFor@0 191 g_RaceClassList[CENSUSPlus_ROGUE] = 14;
EmFor@0 192 g_RaceClassList[CENSUSPlus_WARLOCK] = 15;
EmFor@0 193 g_RaceClassList[CENSUSPlus_WARRIOR] = 16;
EmFor@0 194 g_RaceClassList[CENSUSPlus_SHAMAN] = 17;
EmFor@0 195 g_RaceClassList[CENSUSPlus_PALADIN] = 18;
EmFor@0 196 g_RaceClassList[CENSUSPlus_DEATHKNIGHT] = 30;
EmFor@0 197
EmFor@0 198 g_RaceClassList[CENSUSPlus_DWARF] = 20;
EmFor@0 199 g_RaceClassList[CENSUSPlus_GNOME] = 21;
EmFor@0 200 g_RaceClassList[CENSUSPlus_HUMAN] = 22;
EmFor@0 201 g_RaceClassList[CENSUSPlus_NIGHTELF] = 23;
EmFor@0 202 g_RaceClassList[CENSUSPlus_ORC] = 24;
EmFor@0 203 g_RaceClassList[CENSUSPlus_TAUREN] = 25;
EmFor@0 204 g_RaceClassList[CENSUSPlus_TROLL] = 26;
EmFor@0 205 g_RaceClassList[CENSUSPlus_UNDEAD] = 27;
EmFor@0 206 g_RaceClassList[CENSUSPlus_DRAENEI] = 28;
EmFor@0 207 g_RaceClassList[CENSUSPlus_BLOODELF] = 29;
EmFor@11 208 g_RaceClassList[CENSUSPlus_WORGEN] = 32;
EmFor@11 209 g_RaceClassList[CENSUSPlus_GOBLIN] = 31;
EmFor@11 210
EmFor@0 211
EmFor@0 212 g_TimeDatabase[CENSUSPlus_DRUID] = 0;
EmFor@0 213 g_TimeDatabase[CENSUSPlus_HUNTER] = 0;
EmFor@0 214 g_TimeDatabase[CENSUSPlus_MAGE] = 0;
EmFor@0 215 g_TimeDatabase[CENSUSPlus_PRIEST] = 0;
EmFor@0 216 g_TimeDatabase[CENSUSPlus_ROGUE] = 0;
EmFor@0 217 g_TimeDatabase[CENSUSPlus_WARLOCK] = 0;
EmFor@0 218 g_TimeDatabase[CENSUSPlus_WARRIOR] = 0;
EmFor@0 219 g_TimeDatabase[CENSUSPlus_SHAMAN] = 0;
EmFor@0 220 g_TimeDatabase[CENSUSPlus_PALADIN] = 0;
EmFor@0 221 g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] = 0;
EmFor@0 222 g_TimeDatabase[CENSUSPlus_WarsongGulch] = 0;
EmFor@0 223 g_TimeDatabase[CENSUSPlus_AlteracValley] = 0;
EmFor@0 224 g_TimeDatabase[CENSUSPlus_ArathiBasin] = 0;
EmFor@0 225
EmFor@0 226 -- These two DO NOT need to be localized
EmFor@0 227 local CENSUSPlus_HORDE = "Horde";
EmFor@0 228 local CENSUSPlus_ALLIANCE = "Alliance";
EmFor@0 229
EmFor@0 230
EmFor@0 231 local g_FactionCheck = {};
EmFor@0 232 g_FactionCheck[CENSUSPlus_ORC] = CENSUSPlus_HORDE;
EmFor@0 233 g_FactionCheck[CENSUSPlus_TAUREN] = CENSUSPlus_HORDE;
EmFor@0 234 g_FactionCheck[CENSUSPlus_TROLL] = CENSUSPlus_HORDE;
EmFor@0 235 g_FactionCheck[CENSUSPlus_UNDEAD] = CENSUSPlus_HORDE;
EmFor@0 236 g_FactionCheck[CENSUSPlus_BLOODELF] = CENSUSPlus_HORDE;
EmFor@6 237 g_FactionCheck[CENSUSPlus_GOBLIN] = CENSUSPlus_HORDE;
EmFor@0 238
EmFor@0 239 g_FactionCheck[CENSUSPlus_DWARF] = CENSUSPlus_ALLIANCE;
EmFor@0 240 g_FactionCheck[CENSUSPlus_GNOME] = CENSUSPlus_ALLIANCE;
EmFor@0 241 g_FactionCheck[CENSUSPlus_HUMAN] = CENSUSPlus_ALLIANCE;
EmFor@0 242 g_FactionCheck[CENSUSPlus_NIGHTELF] = CENSUSPlus_ALLIANCE;
EmFor@0 243 g_FactionCheck[CENSUSPlus_DRAENEI] = CENSUSPlus_ALLIANCE;
EmFor@6 244 g_FactionCheck[CENSUSPlus_WORGEN] = CENSUSPlus_ALLIANCE;
EmFor@0 245 local g_ReturnedZero = false;
EmFor@0 246
EmFor@0 247 do
EmFor@0 248 -- HACK
EmFor@0 249 --[[
EmFor@0 250 seeing as Blizzard improperly coded GuildControlPopupFrame_OnEvent to mess up when GUILD_ROSTER_EVENT is dispatched,
EmFor@0 251 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 252 Thanks to ckknight of wowace for this
EmFor@0 253 ]]
EmFor@6 254 -- GuildControlPopupFrame:SetScript("OnEvent", nil)
EmFor@0 255 end
EmFor@0 256
EmFor@0 257
EmFor@0 258 ----------------------------------------------------------------------------------
EmFor@0 259 --
EmFor@0 260 -- Set up confirmation boxes
EmFor@0 261 --
EmFor@0 262 ---------------------------------------------------------------------------------
EmFor@0 263 StaticPopupDialogs["CP_PURGE_CONFIRM"] = {
EmFor@0 264 text = CENSUSPlus_PURGE_LOCAL_CONFIRM,
EmFor@0 265 button1 = CENSUSPlus_YES,
EmFor@0 266 button2 = CENSUSPlus_NO,
EmFor@0 267 OnAccept = function()
EmFor@0 268 CensusPlus_DoPurge();
EmFor@0 269 end,
EmFor@0 270 sound = "levelup2",
EmFor@0 271 timeout = 0,
EmFor@0 272 whileDead = 1,
EmFor@0 273 hideOnEscape = 1,
EmFor@0 274 showAlert = 1
EmFor@0 275 };
EmFor@0 276
EmFor@0 277 ----------------------------------------------------------------------------------
EmFor@0 278 --
EmFor@0 279 -- Set up Continue after override box
EmFor@0 280 --
EmFor@0 281 ---------------------------------------------------------------------------------
EmFor@0 282 StaticPopupDialogs["CP_CONTINUE_CENSUS"] = {
EmFor@0 283 text = CENSUSPlus_OVERRIDE_COMPLET_PAUSED,
EmFor@0 284 button1 = CENSUSPlus_CONTINUE,
EmFor@0 285 OnAccept = function()
EmFor@0 286 g_CensusPlusManuallyPaused = false;
EmFor@0 287 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE );
EmFor@0 288 end,
EmFor@0 289 sound = "levelup2",
EmFor@0 290 timeout = 0,
EmFor@0 291 whileDead = 1,
EmFor@0 292 hideOnEscape = 1,
EmFor@0 293 showAlert = 1
EmFor@0 294 };
EmFor@0 295
EmFor@0 296 ----------------------------------------------------------------------------------
EmFor@0 297 --
EmFor@0 298 -- Chat msg hook
EmFor@0 299 --
EmFor@0 300 ---------------------------------------------------------------------------------
EmFor@0 301 local function CP_HookAddMessage(frame)
EmFor@0 302 local AddMessage = frame.AddMessage;
EmFor@0 303 -- Create a closure to cleanly hook the AddMessage routine.
EmFor@0 304 frame.AddMessage =
EmFor@0 305 function (this, msg, r, g, b, id)
EmFor@0 306 if( ( g_TrackUnhandled or g_IsCensusPlusInProgress ) and msg ) then
EmFor@0 307 local s, e;
EmFor@0 308 local results = { };
EmFor@0 309 local whoMsg = false;
EmFor@0 310 --CensusPlus_Msg2( "Something : " .. msg );
EmFor@0 311
EmFor@0 312 --
EmFor@0 313 -- We don't need to process results from chat, we can get it straight from the who window (DUHH!)
EmFor@0 314 -- So, we just need to see if we have a match, and suppress the output if so
EmFor@0 315 --
EmFor@0 316
EmFor@0 317 -- results = CensusPlus_GatherSingleReturn( msg );
EmFor@0 318 -- if( results["NAME"] ~= nil ) then
EmFor@0 319 results = { };
EmFor@0 320 s, e = strmatch(msg, CENSUS_SINGLE_MATCH_PATTERN);
EmFor@0 321 if( s ~= nil ) then
EmFor@0 322 -- CensusPlus_Msg2( " Name : " .. results["NAME"] .. " L: " .. results["LEVEL"] .. " R: " .. results["RACE"] .. " C: " .. results["CLASS"].. " G: " .. results["GUILD"].. " Z: " .. results["ZONE"] );
EmFor@0 323 whoMsg = true;
EmFor@0 324 -- WR_ProcessSingleEntry( results["NAME"], results["LEVEL"], results["RACE"], results["CLASS"], results["GUILD"], results["ZONE"] );
EmFor@0 325 else
EmFor@0 326 if( g_TrackUnhandled ) then
EmFor@0 327 CensusPlus_Unhandled[msg] = 1;
EmFor@0 328 end
EmFor@0 329 end
EmFor@0 330
EmFor@0 331 results = { };
EmFor@0 332 s, e = strmatch(msg, WHO_NUM_RESULTS);
EmFor@0 333 if( s ~= nil ) then
EmFor@0 334 -- 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 335 whoMsg = true;
EmFor@0 336
EmFor@0 337 local result;
EmFor@0 338 s, e, result = string.find( msg, "(%d+).*" );
EmFor@0 339 if( result == "0" ) then
EmFor@0 340 g_ReteurnedZero = true;
EmFor@0 341 end
EmFor@0 342
EmFor@0 343 CensusPlus_ProcessWhoResults();
EmFor@0 344 end
EmFor@0 345
EmFor@0 346
EmFor@0 347 if( whoMsg ) then
EmFor@0 348 --
EmFor@0 349 -- Also bail out of an override if in place
EmFor@0 350 --
EmFor@0 351 if( g_CensusWhoOverrideMsg ~= nil and g_WaitingForOverrideUpdate == true ) then
EmFor@0 352 --
EmFor@0 353 -- Allow the who to act normally
EmFor@0 354 --
EmFor@0 355 g_CensusWhoOverrideMsg = nil;
EmFor@0 356 g_WaitingForOverrideUpdate = false;
EmFor@0 357 CensusPlus_Msg( CENSUSPlus_OVERRIDE_COMPLETE );
EmFor@0 358 return AddMessage(this, msg, r, g, b, id)
EmFor@0 359 elseif( CensusPlus_PerCharInfo["Verbose"] ~= true and
EmFor@0 360 not g_CensusPlusPaused and
EmFor@0 361 not g_CensusPlusManuallyPaused ) then
EmFor@0 362 return;
EmFor@0 363
EmFor@0 364 end
EmFor@0 365
EmFor@0 366 g_WaitingForWhoUpdate = false;
EmFor@0 367 end
EmFor@0 368
EmFor@0 369 return AddMessage(this, msg, r, g, b, id)
EmFor@0 370 else
EmFor@0 371 return AddMessage(this, msg, r, g, b, id)
EmFor@0 372 end
EmFor@0 373 end
EmFor@0 374 end
EmFor@0 375
EmFor@0 376
EmFor@0 377
EmFor@0 378 -----------------------------------------------------------------------------------
EmFor@0 379 --
EmFor@0 380 -- Insert a job at the end of the job queue
EmFor@0 381 --
EmFor@0 382 -----------------------------------------------------------------------------------
EmFor@0 383 local function InsertJobIntoQueue(job)
EmFor@0 384 --CensusPlus_DumpJob( job );
EmFor@0 385 table.insert(g_JobQueue, job);
EmFor@0 386 end
EmFor@0 387
EmFor@0 388 -----------------------------------------------------------------------------------
EmFor@0 389 --
EmFor@0 390 -- Initialize the tables of constants for XP calculations
EmFor@0 391 --
EmFor@0 392 -----------------------------------------------------------------------------------
EmFor@0 393 local function InitConstantTables()
EmFor@0 394 --
EmFor@0 395 -- XP earned for killing
EmFor@0 396 --
EmFor@0 397 --rm
EmFor@0 398 for i = 1, MAX_LEVEL_DISPLAY, 1 do
EmFor@0 399 g_MobXPByLevel[i] = i;
EmFor@0 400 end
EmFor@0 401
EmFor@0 402 --
EmFor@0 403 -- XP required to advance through the given level
EmFor@0 404 --
EmFor@0 405 for i = 1, MAX_LEVEL_DISPLAY, 1 do
EmFor@0 406 g_CharacterXPByLevel[i] = ((8 * i * g_MobXPByLevel[i]) / 100) * 100;
EmFor@0 407 end
EmFor@0 408
EmFor@0 409 --
EmFor@0 410 -- Total XP required to attain the given level
EmFor@0 411 --
EmFor@0 412 local totalCharacterXP = 0;
EmFor@0 413 for i = 1, MAX_LEVEL_DISPLAY, 1 do
EmFor@0 414 -- g_TotalCharacterXPPerLevel[i] = totalCharacterXP;
EmFor@0 415 --totalCharacterXP = totalCharacterXP + g_CharacterXPByLevel[i];
EmFor@0 416 val = (i*5)/MAX_LEVEL_DISPLAY;
EmFor@0 417 g_TotalCharacterXPPerLevel[i] = math.exp(val);
EmFor@0 418 end
EmFor@0 419
EmFor@0 420 end
EmFor@0 421
EmFor@0 422 -----------------------------------------------------------------------------------
EmFor@0 423 --
EmFor@0 424 -- Return a table of races for the input faction
EmFor@0 425 --
EmFor@0 426 -----------------------------------------------------------------------------------
EmFor@0 427 function CensusPlus_GetFactionRaces(faction)
EmFor@0 428 local ret = {};
EmFor@0 429 if (faction == CENSUSPlus_HORDE) then
EmFor@6 430 ret = {CENSUSPlus_ORC, CENSUSPlus_TAUREN, CENSUSPlus_TROLL, CENSUSPlus_UNDEAD, CENSUSPlus_BLOODELF, CENSUSPlus_GOBLIN};
EmFor@0 431 elseif (faction == CENSUSPlus_ALLIANCE) then
EmFor@6 432 ret = {CENSUSPlus_DWARF, CENSUSPlus_GNOME, CENSUSPlus_HUMAN, CENSUSPlus_NIGHTELF, CENSUSPlus_DRAENEI, CENSUSPlus_WORGEN};
EmFor@0 433 end
EmFor@0 434 return ret;
EmFor@0 435 end
EmFor@0 436
EmFor@0 437 -----------------------------------------------------------------------------------
EmFor@0 438 --
EmFor@0 439 -- Return a table of classes for the input faction
EmFor@0 440 --
EmFor@0 441 -----------------------------------------------------------------------------------
EmFor@0 442 function CensusPlus_GetFactionClasses(faction)
EmFor@0 443 local ret = {};
EmFor@0 444 if (faction == CENSUSPlus_HORDE) then
EmFor@0 445 ret = {CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT};
EmFor@0 446 elseif (faction == CENSUSPlus_ALLIANCE) then
EmFor@0 447 ret = {CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT};
EmFor@0 448 end
EmFor@0 449 return ret;
EmFor@0 450 end
EmFor@0 451
EmFor@0 452 -----------------------------------------------------------------------------------
EmFor@0 453 --
EmFor@0 454 -- Return a table of classes for the input race
EmFor@0 455 --
EmFor@0 456 -----------------------------------------------------------------------------------
EmFor@0 457 local function GetRaceClasses(race)
EmFor@0 458 local ret = {};
EmFor@0 459 if (race == CENSUSPlus_ORC) then
EmFor@6 460 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
EmFor@0 461 elseif (race == CENSUSPlus_TAUREN) then
EmFor@6 462 ret = {CENSUSPlus_PALADIN, CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_SHAMAN, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
EmFor@0 463 elseif (race == CENSUSPlus_TROLL) then
EmFor@6 464 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
EmFor@0 465 elseif (race == CENSUSPlus_UNDEAD) then
EmFor@6 466 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
EmFor@0 467 elseif (race == CENSUSPlus_DWARF) then
EmFor@6 468 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_DEATHKNIGHT};
EmFor@0 469 elseif (race == CENSUSPlus_GNOME) then
EmFor@6 470 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_ROGUE, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
EmFor@0 471 elseif (race == CENSUSPlus_HUMAN) then
EmFor@6 472 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_PALADIN, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
EmFor@0 473 elseif (race == CENSUSPlus_NIGHTELF) then
EmFor@6 474 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_DRUID, CENSUSPlus_DEATHKNIGHT};
EmFor@0 475 elseif (race == CENSUSPlus_BLOODELF) then
EmFor@6 476 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_ROGUE, CENSUSPlus_PRIEST, CENSUSPlus_MAGE, CENSUSPlus_WARLOCK, CENSUSPlus_DEATHKNIGHT};
EmFor@0 477 elseif (race == CENSUSPlus_DRAENEI) then
EmFor@0 478 ret = {CENSUSPlus_WARRIOR, CENSUSPlus_PALADIN, CENSUSPlus_HUNTER, CENSUSPlus_PRIEST, CENSUSPlus_SHAMAN, CENSUSPlus_MAGE, CENSUSPlus_DEATHKNIGHT};
EmFor@6 479 elseif (race == CENSUSPlus_WORGEN) then
EmFor@6 480 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_DRUID, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
EmFor@6 481 elseif (race == CENSUSPlus_GOBLIN) then
EmFor@6 482 ret = {CENSUSPlus_DEATHKNIGHT, CENSUSPlus_HUNTER, CENSUSPlus_MAGE, CENSUSPlus_PRIEST, CENSUSPlus_ROGUE, CENSUSPlus_SHAMAN, CENSUSPlus_WARLOCK, CENSUSPlus_WARRIOR};
EmFor@0 483 end
EmFor@0 484 return ret;
EmFor@0 485 end
EmFor@0 486
EmFor@0 487 -----------------------------------------------------------------------------------
EmFor@0 488 --
EmFor@0 489 -- Return common letters found in zone names
EmFor@0 490 --
EmFor@0 491 -----------------------------------------------------------------------------------
EmFor@0 492 local function GetZoneLetters()
EmFor@0 493 return {"t", "d", "g", "f", "h", "b", "x", "gulch", "valley", "basin" };
EmFor@0 494 end
EmFor@0 495
EmFor@0 496 -----------------------------------------------------------------------------------
EmFor@0 497 --
EmFor@0 498 -- Return common letters found in names, may override this for other languages
EmFor@0 499 -- Worst case scenario is to do it for every letter in the alphabet
EmFor@0 500 --
EmFor@0 501 -----------------------------------------------------------------------------------
EmFor@0 502 local function GetNameLetters()
EmFor@11 503 -- return { "a", "b", "c", "d", "e", "f", "g", "i", "o", "p", "r", "s", "t", "u", "y" };
EmFor@0 504 --rm
EmFor@0 505 -- 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 506 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 507 end
EmFor@0 508
EmFor@0 509 ---------------------------------------------------------------------------------
EmFor@0 510 --
EmFor@0 511 -- Register with Cosmos UI
EmFor@0 512 --
EmFor@0 513 ---------------------------------------------------------------------------------
EmFor@0 514 local function CensusPlus_RegisterCosmos()
EmFor@0 515 --
EmFor@0 516 -- If Cosmos is installed, add a button to the Cosmos page to activate CensusPlus
EmFor@0 517 --
EmFor@0 518 if ( EarthFeature_AddButton ) then
EmFor@0 519 EarthFeature_AddButton(
EmFor@0 520 {
EmFor@0 521 id = "CensusPlus";
EmFor@0 522 name = CENSUSPlus_BUTTON_TEXT;
EmFor@0 523 subtext = CENSUSPlus_BUTTON_SUBTEXT;
EmFor@0 524 tooltip = CENSUSPlus_BUTTON_TIP;
EmFor@0 525 icon = "Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_Icon";
EmFor@0 526 callback = CensusPlus_Toggle;
EmFor@0 527 }
EmFor@0 528 );
EmFor@0 529 elseif ( Cosmos_RegisterButton ) then
EmFor@0 530 Cosmos_RegisterButton(CENSUSPlus_BUTTON_TEXT, CENSUSPlus_BUTTON_SUBTEXT, CENSUSPlus_BUTTON_TIP, "Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_Icon", CensusPlus_Toggle);
EmFor@0 531 end
EmFor@0 532 end
EmFor@0 533
EmFor@0 534
EmFor@0 535 ----------------------------------------------------------------------------------
EmFor@0 536 --
EmFor@0 537 -- Called when the main window is shown
EmFor@0 538 --
EmFor@0 539 ---------------------------------------------------------------------------------
EmFor@0 540 function CensusPlus_OnShow()
EmFor@0 541 -- Initialize if this is the first OnShow event
EmFor@0 542 if (g_CensusPlusInitialized == false) then
EmFor@0 543 g_CensusPlusInitialized = true;
EmFor@0 544 end
EmFor@0 545 CensusPlus_UpdateView();
EmFor@0 546 end
EmFor@0 547
EmFor@0 548 ----------------------------------------------------------------------------------
EmFor@0 549 --
EmFor@0 550 -- Toggle hidden status
EmFor@0 551 --
EmFor@0 552 ---------------------------------------------------------------------------------
EmFor@0 553 function CensusPlus_Toggle()
EmFor@0 554 if ( CensusPlus:IsVisible() ) then
EmFor@0 555 CensusPlus:Hide();
EmFor@0 556 else
EmFor@0 557 CensusPlus:Show();
EmFor@0 558 end
EmFor@0 559 end
EmFor@0 560
EmFor@0 561 ----------------------------------------------------------------------------------
EmFor@0 562 --
EmFor@0 563 -- Toggle options pane
EmFor@0 564 --
EmFor@0 565 ---------------------------------------------------------------------------------
EmFor@0 566 function CensusPlus_ToggleOptions()
EmFor@0 567 if ( CP_OptionsWindow:IsVisible() ) then
EmFor@0 568 CP_OptionsWindow:Hide();
EmFor@0 569 else
EmFor@0 570 CP_OptionsWindow:Show();
EmFor@0 571 end
EmFor@0 572 end
EmFor@0 573
EmFor@0 574 -----------------------------------------------------------------------------------
EmFor@0 575 --
EmFor@0 576 -- Called once on load
EmFor@0 577 --
EmFor@0 578 -----------------------------------------------------------------------------------
EmFor@6 579 function CensusPlus_OnLoad( this )
EmFor@0 580 --
EmFor@0 581 -- Update the version number
EmFor@0 582 --
EmFor@0 583 CensusPlusText:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale );
EmFor@0 584 CensusPlusText2:SetText( CENSUSPlus_UPLOAD );
EmFor@0 585
EmFor@0 586 --
EmFor@0 587 -- Init constant tables
EmFor@0 588 --
EmFor@0 589 InitConstantTables();
EmFor@0 590
EmFor@0 591 --
EmFor@0 592 -- Register with Cosmos, if it is installed
EmFor@0 593 --
EmFor@0 594 CensusPlus_RegisterCosmos();
EmFor@0 595
EmFor@0 596 --
EmFor@0 597 -- Register for events
EmFor@0 598 --
EmFor@0 599 this:RegisterEvent("VARIABLES_LOADED");
EmFor@0 600 -- this:RegisterEvent("WHO_LIST_UPDATE");
EmFor@0 601
EmFor@0 602
EmFor@0 603 this:RegisterEvent("CHAT_MSG_SYSTEM");
EmFor@0 604
EmFor@0 605
EmFor@0 606 this:RegisterEvent("ZONE_CHANGED_NEW_AREA");
EmFor@0 607
EmFor@0 608 --
EmFor@0 609 -- Register a slash command
EmFor@0 610 --
EmFor@0 611 SLASH_CensusPlusCMD1 = "/CensusPlus";
EmFor@0 612 SLASH_CensusPlusCMD2 = "/Census+";
EmFor@0 613 SLASH_CensusPlusCMD3 = "/Census";
EmFor@0 614 SlashCmdList["CensusPlusCMD"] = CensusPlus_Command;
EmFor@0 615
EmFor@0 616 SLASH_CensusPlusVerbose1 = "/censusverbose";
EmFor@0 617 SlashCmdList["CensusPlusVerbose"] = CensusPlus_Verbose;
EmFor@0 618
EmFor@0 619 --
EmFor@0 620 -- Set the auto close to true
EmFor@0 621 --
EmFor@0 622 CensusPlus_AutoCloseWho( 1 );
EmFor@0 623 --AutoClose:SetChecked( 1 );
EmFor@0 624
EmFor@0 625 -- g_Pre_FriendsFrameOnHideOverride = FriendsFrame_OnHide;
EmFor@0 626 -- FriendsFrame_OnHide = CensusPlus_FriendsFrame_OnHide;
EmFor@0 627
EmFor@0 628 -- g_Pre_FriendsFrameOnShowOverride = FriendsFrame_OnShow;
EmFor@0 629 -- FriendsFrame_OnShow = CensusPlus_FriendsFrame_OnShow;
EmFor@0 630
EmFor@0 631 -- g_Pre_WhoList_UpdateOverride = WhoList_Update;
EmFor@0 632 -- WhoList_Update = CensusPlus_WhoList_Update;
EmFor@0 633
EmFor@0 634 -- g_Pre_FriendsFrame_Update = FriendsFrame_Update;
EmFor@0 635 -- FriendsFrame_Update = CensusPlus_FriendsFrame_Update;
EmFor@0 636
EmFor@0 637 g_SetItemRef_Override = SetItemRef;
EmFor@0 638 SetItemRef = CensusPlus_SetItemRef;
EmFor@0 639
EmFor@0 640 CP_Pre_OnEvent = FriendsFrame_OnEvent;
EmFor@0 641 FriendsFrame_OnEvent = CensusPlus_FriendsFrame_OnEvent;
EmFor@0 642
EmFor@0 643 g_Pre_WhoHandler = SlashCmdList["WHO"];
EmFor@0 644 SlashCmdList["WHO"] = CensusPlus_WhoHandler;
EmFor@0 645
EmFor@0 646 CensusPlus_CheckForBattleground();
EmFor@0 647
EmFor@0 648 -- Hook the default chat frame's AddMessage method.
EmFor@0 649 CP_HookAddMessage(ChatFrame1);
EmFor@0 650
EmFor@0 651 --
EmFor@0 652 -- Set up an empty frame to do updates
EmFor@0 653 --
EmFor@0 654 local updateFrame = CreateFrame("Frame");
EmFor@0 655 updateFrame:SetScript("OnUpdate", CensusPlus_OnUpdate);
EmFor@0 656 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" );
EmFor@0 657 end
EmFor@0 658
EmFor@6 659 function CensusPlus_FriendsFrame_OnEvent(self, event, ...)
EmFor@0 660
EmFor@0 661 -- CensusPlus_Msg( "CP_FF_OE Message =>" .. event );
EmFor@0 662
EmFor@0 663 if(wholib == nil and
EmFor@0 664 event == "WHO_LIST_UPDATE" and g_IsCensusPlusInProgress and g_WaitingForWhoUpdate ) then
EmFor@0 665 --
EmFor@0 666 -- First check for an override
EmFor@0 667 --
EmFor@0 668 if( g_CensusWhoOverrideMsg ~= nil and g_WaitingForOverrideUpdate == true ) then
EmFor@0 669 --
EmFor@0 670 -- Allow the who to act normally
EmFor@0 671 --
EmFor@0 672 g_CensusWhoOverrideMsg = nil;
EmFor@0 673 g_WaitingForOverrideUpdate = false;
EmFor@0 674 CensusPlus_Msg( CENSUSPlus_OVERRIDE_COMPLETE_BUT_PAUSED );
EmFor@0 675 -- g_Pre_WhoList_UpdateOverride();
EmFor@0 676
EmFor@0 677
EmFor@0 678 g_WaitingForWhoUpdate = false;
EmFor@0 679 CP_Pre_OnEvent(...);
EmFor@0 680 --
EmFor@0 681 -- If we opened the who window, do a manual pause and open a dialog
EmFor@0 682 --
EmFor@0 683 g_CensusPlusManuallyPaused = true;
EmFor@0 684 CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE );
EmFor@0 685
EmFor@0 686 StaticPopup_Show ("CP_CONTINUE_CENSUS");
EmFor@0 687
EmFor@0 688 elseif ( g_IsCensusPlusInProgress ) then
EmFor@0 689 --
EmFor@0 690 -- Only process who results if a CensusPlus is in progress
EmFor@0 691 --
EmFor@0 692
EmFor@0 693 CP_ProcessWhoEvent()
EmFor@0 694
EmFor@0 695
EmFor@0 696 else
EmFor@0 697 --
EmFor@0 698 -- This is just a random /who done by the player
EmFor@0 699 --
EmFor@0 700 CensusPlus_ProcessWhoResults();
EmFor@0 701 end
EmFor@0 702 --
EmFor@0 703 -- We got the who update
EmFor@0 704 --
EmFor@0 705 g_WaitingForWhoUpdate = false;
EmFor@0 706
EmFor@0 707 return;
EmFor@0 708
EmFor@0 709 end
EmFor@0 710
EmFor@6 711 CP_Pre_OnEvent(self, event, ...);
EmFor@0 712
EmFor@0 713 end
EmFor@0 714
EmFor@0 715 function CP_ProcessWhoEvent(query, ...)
EmFor@0 716 local numWhoResults = GetNumWhoResults();
EmFor@0 717 if( numWhoResults == 0 ) then
EmFor@0 718 return;
EmFor@0 719 end
EmFor@0 720
EmFor@0 721 CensusPlus_ProcessWhoResults();
EmFor@0 722 if (numWhoResults > MAX_WHO_RESULTS) then
EmFor@0 723 --
EmFor@0 724 -- Who list is overflowed, split the query to make the return smaller
EmFor@0 725 --
EmFor@0 726 local minLevel = g_CurrentJob.m_MinLevel;
EmFor@0 727 local maxLevel = g_CurrentJob.m_MaxLevel;
EmFor@0 728 local race = g_CurrentJob.m_Race;
EmFor@0 729 local class = g_CurrentJob.m_Class;
EmFor@0 730 local zoneLetter = g_CurrentJob.m_zoneLetter;
EmFor@0 731 local letter = g_CurrentJob.m_Letter;
EmFor@0 732 --rmg
EmFor@0 733 local guild = g_CurrentJob.m_Guild;
EmFor@0 734
EmFor@0 735 if (minLevel ~= maxLevel) then
EmFor@0 736
EmFor@0 737 --
EmFor@0 738 -- The level range is greater than a single level, so split it in half and submit the two jobs
EmFor@0 739 --
EmFor@0 740 local pivot = floor((minLevel + maxLevel) / 2);
EmFor@0 741 local jobLower = CensusPlus_CreateJob( minLevel, pivot, nil, nil, nil , guild );
EmFor@0 742 InsertJobIntoQueue(jobLower);
EmFor@0 743 local jobUpper = CensusPlus_CreateJob( pivot + 1, maxLevel, nil, nil, nil , guild );
EmFor@0 744 InsertJobIntoQueue(jobUpper);
EmFor@0 745 else
EmFor@0 746 --
EmFor@0 747 -- We cannot split the level range any more
EmFor@0 748 --
EmFor@0 749 local factionGroup = UnitFactionGroup("player");
EmFor@0 750 local level = minLevel;
EmFor@0 751 if (race == nil) then
EmFor@0 752 --
EmFor@0 753 -- This job does not specify race, so split it that way, making four new jobs
EmFor@0 754 --
EmFor@0 755 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
EmFor@0 756 local numRaces = table.getn(thisFactionRaces);
EmFor@0 757 for i = 1, numRaces, 1 do
EmFor@0 758 local job = CensusPlus_CreateJob( level, level, thisFactionRaces[i], nil, nil , guild );
EmFor@0 759 InsertJobIntoQueue(job);
EmFor@0 760 end
EmFor@0 761 else
EmFor@0 762 if (class == nil) then
EmFor@0 763 --
EmFor@0 764 -- This job does not specify class, so split it that way, making more jobs
EmFor@0 765 --
EmFor@0 766 local thisRaceClasses = GetRaceClasses(race);
EmFor@0 767 local numClasses = table.getn(thisRaceClasses);
EmFor@0 768 for i = 1, numClasses, 1 do
EmFor@0 769 local job = CensusPlus_CreateJob( level, level, race, thisRaceClasses[i], nil , guild );
EmFor@0 770 InsertJobIntoQueue(job);
EmFor@0 771 end
EmFor@0 772 else
EmFor@0 773 if( letter == nil ) then
EmFor@0 774 -- There are too many characters with a single level, class and race
EmFor@0 775 -- The work around we are going to pursue is to check by name for a,e,i,o,r,s,t,u
EmFor@0 776 local letters = GetNameLetters();
EmFor@0 777 for i=1, table.getn( letters ), 1 do
EmFor@0 778 local job = CensusPlus_CreateJob( level, level, race, class, letters[i] , guild );
EmFor@0 779 InsertJobIntoQueue(job);
EmFor@0 780 end
EmFor@0 781 else
EmFor@0 782 -- There are too many characters with a single level, class, race and letter, give up
EmFor@0 783 local whoText = CensusPlus_CreateWhoText(g_CurrentJob);
EmFor@0 784 CensusPlus_Msg(format(CENSUSPlus_TOOMANY, whoText));
EmFor@0 785 end
EmFor@0 786 end
EmFor@0 787 end
EmFor@0 788 end
EmFor@0 789 end
EmFor@0 790
EmFor@0 791 local whoText = CensusPlus_CreateWhoText(g_CurrentJob);
EmFor@0 792
EmFor@0 793 if whoText == query then
EmFor@0 794 g_WaitingForWhoUpdate = false
EmFor@0 795 end
EmFor@0 796 end
EmFor@0 797
EmFor@0 798 -----------------------------------------------------------------------------------
EmFor@0 799 --
EmFor@0 800 -- Load Handler for options box
EmFor@0 801 --
EmFor@0 802 -----------------------------------------------------------------------------------
EmFor@0 803 function CP_OptionsOnShow()
EmFor@0 804 CP_OptionAutoClose:SetChecked(g_WhoAutoClose);
EmFor@0 805 CP_OptionAutoStartButton:SetChecked(g_MiniOnStart);
EmFor@0 806 CP_OptionVerboseButton:SetChecked(CensusPlus_PerCharInfo["Verbose"]);
EmFor@0 807 CP_OptionAutoCensusButton:SetChecked( CensusPlus_Database["Info"]["AutoCensus"] );
EmFor@0 808 -- CP_OptionProcessCharProfileButton:SetChecked( CensusPlus_DoThisCharacter );
EmFor@0 809 end
EmFor@0 810
EmFor@0 811 -----------------------------------------------------------------------------------
EmFor@0 812 --
EmFor@0 813 -- CensusPlus Friends Frame override to stop the window close sound
EmFor@0 814 --
EmFor@0 815 -----------------------------------------------------------------------------------
EmFor@0 816 function CensusPlus_FriendsFrame_OnHide()
EmFor@0 817 g_Pre_FriendsFrameOnHideOverride();
EmFor@0 818 end
EmFor@0 819
EmFor@0 820 -----------------------------------------------------------------------------------
EmFor@0 821 --
EmFor@0 822 -- CensusPlus Friends Frame override to stop the window close sound
EmFor@0 823 --
EmFor@0 824 -----------------------------------------------------------------------------------
EmFor@0 825 function CensusPlus_FriendsFrame_OnShow()
EmFor@0 826 g_Pre_FriendsFrameOnShowOverride();
EmFor@0 827 end
EmFor@0 828
EmFor@0 829 -----------------------------------------------------------------------------------
EmFor@0 830 --
EmFor@0 831 -- CensusPlus_WhoList_Update
EmFor@0 832 --
EmFor@0 833 -----------------------------------------------------------------------------------
EmFor@0 834 function CensusPlus_WhoList_Update()
EmFor@0 835 --InCombatLockdown() == false
EmFor@0 836 if( g_IsCensusPlusInProgress == true and g_WhoAutoClose ) then
EmFor@0 837 local numWhos, totalCount = GetNumWhoResults();
EmFor@0 838 local name, guild, level, race, class, zone, group;
EmFor@0 839 local button;
EmFor@0 840 local columnTable;
EmFor@0 841 local whoOffset = FauxScrollFrame_GetOffset(WhoListScrollFrame);
EmFor@0 842 local whoIndex;
EmFor@0 843 local showScrollBar = nil;
EmFor@0 844 if ( numWhos > WHOS_TO_DISPLAY ) then
EmFor@0 845 showScrollBar = 1;
EmFor@0 846 end
EmFor@0 847 local displayedText = "";
EmFor@0 848 if ( totalCount > MAX_WHOS_FROM_SERVER ) then
EmFor@0 849 displayedText = format(WHO_FRAME_SHOWN_TEMPLATE, MAX_WHOS_FROM_SERVER);
EmFor@0 850 end
EmFor@0 851 WhoFrameTotals:SetText(format(GetText("WHO_FRAME_TOTAL_TEMPLATE", nil, totalCount), totalCount).." "..displayedText);
EmFor@0 852 for i=1, WHOS_TO_DISPLAY, 1 do
EmFor@0 853 whoIndex = whoOffset + i;
EmFor@0 854 button = getglobal("WhoFrameButton"..i);
EmFor@0 855 button.whoIndex = whoIndex;
EmFor@0 856 name, guild, level, race, class, zone, group = GetWhoInfo(whoIndex);
EmFor@0 857 columnTable = { zone, guild, race };
EmFor@0 858 getglobal("WhoFrameButton"..i.."Name"):SetText(name);
EmFor@0 859 getglobal("WhoFrameButton"..i.."Level"):SetText(level);
EmFor@0 860 getglobal("WhoFrameButton"..i.."Class"):SetText(class);
EmFor@0 861 local variableText = getglobal("WhoFrameButton"..i.."Variable");
EmFor@0 862 variableText:SetText(columnTable[UIDropDownMenu_GetSelectedID(WhoFrameDropDown)]);
EmFor@0 863 if ( not group ) then
EmFor@0 864 group = "";
EmFor@0 865 end
EmFor@0 866 --getglobal("WhoFrameButton"..i.."Group"):SetText(getglobal(strupper(group)));
EmFor@0 867
EmFor@0 868 -- If need scrollbar resize columns
EmFor@0 869 if ( showScrollBar ) then
EmFor@0 870 variableText:SetWidth(95);
EmFor@0 871 else
EmFor@0 872 variableText:SetWidth(110);
EmFor@0 873 end
EmFor@0 874
EmFor@0 875 -- Highlight the correct who
EmFor@0 876 if ( WhoFrame.selectedWho == whoIndex ) then
EmFor@0 877 button:LockHighlight();
EmFor@0 878 else
EmFor@0 879 button:UnlockHighlight();
EmFor@0 880 end
EmFor@0 881
EmFor@0 882 if ( whoIndex > numWhos ) then
EmFor@0 883 button:Hide();
EmFor@0 884 else
EmFor@0 885 button:Show();
EmFor@0 886 end
EmFor@0 887 end
EmFor@0 888
EmFor@0 889 if ( not WhoFrame.selectedWho ) then
EmFor@0 890 WhoFrameGroupInviteButton:Disable();
EmFor@0 891 WhoFrameAddFriendButton:Disable();
EmFor@0 892 else
EmFor@0 893 WhoFrameGroupInviteButton:Enable();
EmFor@0 894 WhoFrameAddFriendButton:Enable();
EmFor@0 895 WhoFrame.selectedName = GetWhoInfo(WhoFrame.selectedWho);
EmFor@0 896 end
EmFor@0 897
EmFor@0 898 -- If need scrollbar resize columns
EmFor@0 899 if ( showScrollBar ) then
EmFor@0 900 WhoFrameColumn_SetWidth(WhoFrameColumnHeader2, 105);
EmFor@0 901 UIDropDownMenu_SetWidth(WhoFrameDropDown, 80);
EmFor@0 902 else
EmFor@0 903 WhoFrameColumn_SetWidth(WhoFrameColumnHeader2, 120);
EmFor@0 904 UIDropDownMenu_SetWidth(WhoFrameDropDown, 95);
EmFor@0 905 end
EmFor@0 906
EmFor@0 907 -- ScrollFrame update
EmFor@0 908 FauxScrollFrame_Update(WhoListScrollFrame, numWhos, WHOS_TO_DISPLAY, FRIENDS_FRAME_WHO_HEIGHT );
EmFor@0 909
EmFor@0 910 else
EmFor@0 911 g_Pre_WhoList_UpdateOverride();
EmFor@0 912 end
EmFor@0 913 end
EmFor@0 914
EmFor@0 915
EmFor@0 916 -----------------------------------------------------------------------------------
EmFor@0 917 --
EmFor@0 918 -- CensusPlus_FriendsFrame_Update
EmFor@0 919 --
EmFor@0 920 -----------------------------------------------------------------------------------
EmFor@0 921 function CensusPlus_FriendsFrame_Update()
EmFor@0 922 if ( FriendsFrame.selectedTab == 3 and g_IsCensusPlusInProgress == true and g_WhoAutoClose ) then
EmFor@0 923 FriendsFrameTopLeft:SetTexture("Interface\\ClassTrainerFrame\\UI-ClassTrainer-TopLeft");
EmFor@0 924 FriendsFrameTopRight:SetTexture("Interface\\ClassTrainerFrame\\UI-ClassTrainer-TopRight");
EmFor@0 925 FriendsFrameBottomLeft:SetTexture("Interface\\FriendsFrame\\GuildFrame-BotLeft");
EmFor@0 926 FriendsFrameBottomRight:SetTexture("Interface\\FriendsFrame\\GuildFrame-BotRight");
EmFor@0 927 local guildName, title, rank = GetGuildInfo("player");
EmFor@0 928 if ( guildName ) then
EmFor@0 929 FriendsFrameTitleText:SetText(format(GUILD_TITLE_TEMPLATE, title, guildName));
EmFor@0 930 else
EmFor@0 931 FriendsFrameTitleText:SetText("");
EmFor@0 932 end
EmFor@0 933 --GuildStatus_Update();
EmFor@0 934 FriendsFrameTitleText:SetText(guildName);
EmFor@0 935 FriendsFrame_ShowSubFrame("GuildFrame");
EmFor@0 936 else
EmFor@0 937 g_Pre_FriendsFrame_Update();
EmFor@0 938 end
EmFor@0 939 end
EmFor@0 940
EmFor@0 941 -----------------------------------------------------------------------------------
EmFor@0 942 --
EmFor@0 943 -- CensusPlus Who Handler
EmFor@0 944 --
EmFor@0 945 -----------------------------------------------------------------------------------
EmFor@0 946 function CensusPlus_WhoHandler( msg )
EmFor@0 947 if( g_IsCensusPlusInProgress == true ) then
EmFor@0 948 CensusPlus_Msg( "Census Who Handler" );
EmFor@0 949 if ( msg == "" ) then
EmFor@0 950 msg = WhoFrame_GetDefaultWhoCommand();
EmFor@0 951 ShowWhoPanel();
EmFor@0 952 elseif ( msg == "cheat" ) then
EmFor@0 953 -- Remove the "cheat" part later!
EmFor@0 954 ShowWhoPanel();
EmFor@0 955 end
EmFor@0 956
EmFor@0 957 --
EmFor@0 958 -- Queue up the command to run next
EmFor@0 959 --
EmFor@0 960 g_CensusWhoOverrideMsg = msg;
EmFor@0 961 CensusPlus_Msg( CENSUSPlus_OVERRIDE );
EmFor@0 962 -- CensusPlus_SendWho(msg);
EmFor@0 963 else
EmFor@0 964 g_Pre_WhoHandler(msg);
EmFor@0 965 end
EmFor@0 966 end
EmFor@0 967
EmFor@0 968 -----------------------------------------------------------------------------------
EmFor@0 969 --
EmFor@0 970 -- CensusPlus command
EmFor@0 971 --
EmFor@0 972 -----------------------------------------------------------------------------------
EmFor@0 973 function CensusPlus_Command( param )
EmFor@0 974
EmFor@0 975 local i,j, command, value = string.find(param, "^([^ ]+) (.+)$");
EmFor@0 976
EmFor@0 977 -- local firsti, lasti, command, value = string.find (param, "(%w+) (%w+) (%w+)") ;
EmFor@0 978
EmFor@0 979 -- if( string.lower(param) == "locale" ) then
EmFor@0 980 -- CP_EU_US_Version:Show();
EmFor@0 981 -- else
EmFor@0 982 if( string.lower(param) == "options" ) then
EmFor@0 983 CP_OptionsWindow:Show();
EmFor@0 984 -- elseif( string.lower(param) == "tz" ) then
EmFor@0 985 -- CensusPlus_DetermineServerDate();
EmFor@0 986 elseif( command ~= nil and string.lower(command) == "prune" ) then
EmFor@0 987 if( value ~= nil ) then
EmFor@0 988 CensusPlus_PruneData( value, nil );
EmFor@0 989 else
EmFor@0 990 CensusPlus_PruneData( 30, nil );
EmFor@0 991 end
EmFor@0 992 elseif( command ~= nil and string.lower(command) == "timer" ) then
EmFor@0 993 if( value ~= nil ) then
EmFor@0 994 CensusPlus_Database["Info"]["AutoCensusTimer"] = value * 60;
EmFor@0 995 CensusPlus_Msg( "Set autocensus timer to " .. value .. " minutes" );
EmFor@0 996 else
EmFor@0 997 CensusPlus_Database["Info"]["AutoCensusTimer"] = 1800;
EmFor@0 998 CensusPlus_Msg( "Set autocensus timer to 30 minutes" );
EmFor@0 999 end
EmFor@0 1000 elseif( string.lower(param) == "serverprune" ) then
EmFor@0 1001 CensusPlus_PruneData( 0, 1 );
EmFor@0 1002 elseif( string.lower(param) == "bufftest" ) then
EmFor@0 1003 showAllUnitBuffs("player");
EmFor@0 1004 elseif( string.lower(param) == "verbose" ) then
EmFor@0 1005 CensusPlus_Verbose();
EmFor@0 1006 elseif( string.lower(param) == "take" ) then
EmFor@0 1007 CensusPlus_Take_OnClick();
EmFor@0 1008 elseif( string.lower(param) == "stop" ) then
EmFor@0 1009 CensusPlus_StopCensus();
EmFor@0 1010 elseif( string.lower(param) == "track" ) then
EmFor@0 1011 if( g_TrackUnhandled ) then
EmFor@0 1012 CensusPlus_Msg( "Tracking disabled!" );
EmFor@0 1013 g_TrackUnhandled = false;
EmFor@0 1014 else
EmFor@0 1015 CensusPlus_Msg( "TRACKING ALL CHAT!" );
EmFor@0 1016 g_TrackUnhandled = true;
EmFor@0 1017 end
EmFor@0 1018 elseif( command ~= nil and string.lower(command) == "who" ) then
EmFor@0 1019 local m,n, check, level = string.find(value, "(%w+) (%w+)");
EmFor@0 1020 if( check ~= nil ) then
EmFor@0 1021 CensusPlus_InternalWho( string.lower(check), level );
EmFor@0 1022 else
EmFor@0 1023 CensusPlus_InternalWho( string.lower(value), nil );
EmFor@0 1024 end
EmFor@0 1025 elseif( command ~= nil and string.lower(command) == "test" ) then
EmFor@0 1026 if( value ~= nil ) then
EmFor@0 1027 CensusPlus_Test( value );
EmFor@0 1028 else
EmFor@0 1029 CensusPlus_Test( 1 );
EmFor@0 1030 end
EmFor@0 1031 else
EmFor@0 1032 CensusPlus_DisplayUsage();
EmFor@0 1033 end
EmFor@0 1034 end
EmFor@0 1035
EmFor@0 1036 -----------------------------------------------------------------------------------
EmFor@0 1037 --
EmFor@0 1038 -- CensusPlus Display Usage
EmFor@0 1039 --
EmFor@0 1040 -----------------------------------------------------------------------------------
EmFor@0 1041 function CensusPlus_DisplayUsage()
EmFor@0 1042 local text;
EmFor@0 1043
EmFor@0 1044 CensusPlus:Show();
EmFor@0 1045
EmFor@0 1046 CensusPlus_Msg("Usage:\n /CensusPlus");
EmFor@0 1047 CensusPlus_Msg(" /censusPlus verbose Toggle verbose mode off/on");
EmFor@0 1048 -- CensusPlus_Msg(" /CensusPlus locale Bring up the locale selection dialog - (WARNING -- CHANGING YOUR LOCALE WILL PURGE YOUR DATABASE)");
EmFor@0 1049 CensusPlus_Msg(" /CensusPlus options Bring up the Option window");
EmFor@0 1050 CensusPlus_Msg(" /CensusPlus take Start a Census snapshot");
EmFor@0 1051 CensusPlus_Msg(" /CensusPlus stop Stop a Census snapshot");
EmFor@0 1052 CensusPlus_Msg(" /CensusPlus prune X Prune the database by removing characters not seen in X days");
EmFor@0 1053 CensusPlus_Msg(" /CensusPlus serverprune Prune the database by removing all data from servers other than the one you are currently on.");
EmFor@0 1054 CensusPlus_Msg(" /CensusPlus who XXX Will display info that matches names or guilds.");
EmFor@0 1055 CensusPlus_Msg(" /CensusPlus who unguilded ## Will list unguilded characters of that level.");
EmFor@0 1056 CensusPlus_Msg(" /CensusPlus timer X ## Will set the autocensus timer (in minutes).");
EmFor@0 1057 end
EmFor@0 1058
EmFor@0 1059 -----------------------------------------------------------------------------------
EmFor@0 1060 --
EmFor@0 1061 -- CensusPlus_InternalWho - will go through our local database and see if we have
EmFor@0 1062 -- any info on this person
EmFor@0 1063 --
EmFor@0 1064 -----------------------------------------------------------------------------------
EmFor@0 1065 function CensusPlus_InternalWho( search, level )
EmFor@0 1066
EmFor@0 1067 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 1068 return;
EmFor@0 1069 end
EmFor@0 1070
EmFor@0 1071 g_InternalSearchName = search;
EmFor@0 1072 g_InternalSearchLevel = level;
EmFor@0 1073 g_InternalSearchCount = 0;
EmFor@0 1074 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 1075 CensusPlus_ForAllCharacters( realmName, UnitFactionGroup("player"), nil, nil, nil, nil, CensusPlus_InternalWhoResult)
EmFor@0 1076
EmFor@0 1077 CensusPlus_WhoMsg( "Found " .. g_InternalSearchCount .. " players." );
EmFor@0 1078 end
EmFor@0 1079
EmFor@0 1080 function CensusPlus_InternalWhoResult(name, level, guild, race, class, lastSeen )
EmFor@0 1081 lowerName = string.lower( name );
EmFor@0 1082 level = string.lower( level );
EmFor@0 1083 lowerGuild = string.lower( CensusPlus_SafeCheck( guild ) );
EmFor@0 1084
EmFor@0 1085 if( g_InternalSearchName == "unguilded" ) then
EmFor@0 1086 if( guild == "" ) then
EmFor@0 1087 local doit = 1;
EmFor@0 1088 if( g_InternalSearchLevel ~= nil ) then
EmFor@0 1089 if( g_InternalSearchLevel ~= level ) then
EmFor@0 1090 doit = 0;
EmFor@0 1091 end
EmFor@0 1092 end
EmFor@0 1093 if( doit == 1 ) then
EmFor@0 1094 local out = name .. " : Level " .. level .. " " .. race .. " " .. " " .. class;
EmFor@0 1095 out = out .. " Last Seen: " .. lastSeen;
EmFor@0 1096 CensusPlus_WhoMsg( out );
EmFor@0 1097 g_InternalSearchCount = g_InternalSearchCount + 1;
EmFor@0 1098 end
EmFor@0 1099 end
EmFor@0 1100 elseif( string.find( lowerName, g_InternalSearchName ) or string.find( lowerGuild, g_InternalSearchName ) ) then
EmFor@0 1101 -- found someone!
EmFor@0 1102 local out = name .. " : Level " .. level .. " " .. race .. " " .. " " .. class;
EmFor@0 1103 if( guild ~= "" ) then
EmFor@0 1104 out = out .. " <" .. guild .. ">";
EmFor@0 1105 end
EmFor@0 1106 out = out .. " Last Seen: " .. lastSeen;
EmFor@0 1107 CensusPlus_WhoMsg( out );
EmFor@0 1108 g_InternalSearchCount = g_InternalSearchCount + 1;
EmFor@0 1109 end
EmFor@0 1110 end
EmFor@0 1111
EmFor@0 1112 -----------------------------------------------------------------------------------
EmFor@0 1113 --
EmFor@0 1114 -- CensusPlus Verbose option
EmFor@0 1115 --
EmFor@0 1116 -----------------------------------------------------------------------------------
EmFor@0 1117 function CensusPlus_Verbose()
EmFor@0 1118 if( CensusPlus_PerCharInfo["Verbose"] == true ) then
EmFor@0 1119 CensusPlus_Msg( "Verbose Mode : OFF" );
EmFor@0 1120 CensusPlus_PerCharInfo["Verbose"] = false;
EmFor@0 1121 else
EmFor@0 1122 CensusPlus_Msg( "Verbose Mode : ON" );
EmFor@0 1123 CensusPlus_PerCharInfo["Verbose"] = true;
EmFor@0 1124 end
EmFor@0 1125 end
EmFor@0 1126
EmFor@0 1127 -----------------------------------------------------------------------------------
EmFor@0 1128 --
EmFor@0 1129 -- CensusPlus Auto Census set flag
EmFor@0 1130 --
EmFor@0 1131 -----------------------------------------------------------------------------------
EmFor@0 1132 function CensusPlus_SetAutoCensus( flag )
EmFor@0 1133 if( flag == 1 ) then
EmFor@0 1134 CensusPlus_Database["Info"]["AutoCensus"] = true;
EmFor@0 1135 else
EmFor@0 1136 CensusPlus_Database["Info"]["AutoCensus"] = false;
EmFor@0 1137 end
EmFor@0 1138 end
EmFor@0 1139
EmFor@0 1140 -----------------------------------------------------------------------------------
EmFor@0 1141 --
EmFor@0 1142 -- Minimize the window
EmFor@0 1143 --
EmFor@0 1144 -----------------------------------------------------------------------------------
EmFor@0 1145 function CensusPlus_OnClickMinimize()
EmFor@0 1146 if( CensusPlus:IsVisible() ) then
EmFor@0 1147 -- MiniCensusPlus:Show();
EmFor@0 1148 CensusPlus:Hide();
EmFor@0 1149 end
EmFor@0 1150 end
EmFor@0 1151
EmFor@0 1152 -----------------------------------------------------------------------------------
EmFor@0 1153 --
EmFor@0 1154 -- Minimize the window
EmFor@0 1155 --
EmFor@0 1156 -----------------------------------------------------------------------------------
EmFor@0 1157 function CensusPlus_OnClickMaximize()
EmFor@0 1158 if( MiniCensusPlus:IsVisible() ) then
EmFor@0 1159 MiniCensusPlus:Hide();
EmFor@0 1160 CensusPlus:Show();
EmFor@0 1161 end
EmFor@0 1162 end
EmFor@0 1163
EmFor@0 1164 -----------------------------------------------------------------------------------
EmFor@0 1165 --
EmFor@0 1166 -- Take or pause a census depending on current status
EmFor@0 1167 --
EmFor@0 1168 -----------------------------------------------------------------------------------
EmFor@0 1169 function CensusPlus_Take_OnClick()
EmFor@0 1170 if (g_IsCensusPlusInProgress) then
EmFor@0 1171 CensusPlus_TogglePause();
EmFor@0 1172 else
EmFor@0 1173 CensusPlus_StartCensus();
EmFor@0 1174 end
EmFor@0 1175 end
EmFor@0 1176
EmFor@0 1177 --rm
EmFor@0 1178 -----------------------------------------------------------------------------------
EmFor@0 1179 -- Take or pause a census depending on current status
EmFor@0 1180 -----------------------------------------------------------------------------------
EmFor@0 1181 function CensusPlus_TakeGuild_OnClick()
EmFor@0 1182 if (g_IsCensusPlusInProgress) then
EmFor@0 1183 CensusPlus_TogglePause();
EmFor@0 1184 else
EmFor@0 1185 CensusPlus_StartGuildCensus();
EmFor@0 1186 end
EmFor@0 1187 end
EmFor@0 1188
EmFor@0 1189 -----------------------------------------------------------------------------------
EmFor@0 1190 --
EmFor@0 1191 -- Display a tooltip for the take button
EmFor@0 1192 --
EmFor@0 1193 -----------------------------------------------------------------------------------
EmFor@6 1194 function CensusPlus_Take_OnEnter( this )
EmFor@0 1195 if (g_IsCensusPlusInProgress) then
EmFor@0 1196 if (g_CensusPlusManuallyPaused) then
EmFor@0 1197 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1198 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0);
EmFor@0 1199 GameTooltip:Show();
EmFor@0 1200 else
EmFor@0 1201 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1202 GameTooltip:SetText(CENSUSPlus_PAUSECENSUS, 1.0, 1.0, 1.0);
EmFor@0 1203 GameTooltip:Show();
EmFor@0 1204 end
EmFor@0 1205 else
EmFor@0 1206 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1207 GameTooltip:SetText(CENSUSPlus_TAKECENSUS, 1.0, 1.0, 1.0);
EmFor@0 1208 GameTooltip:Show();
EmFor@0 1209 end
EmFor@0 1210 end
EmFor@0 1211
EmFor@0 1212 --rm
EmFor@0 1213 -----------------------------------------------------------------------------------
EmFor@0 1214 -- Display a tooltip for the take guild button
EmFor@0 1215 -----------------------------------------------------------------------------------
EmFor@6 1216 function CensusPlus_TakeGuild_OnEnter( this )
EmFor@0 1217 if (g_IsCensusPlusInProgress) then
EmFor@0 1218 if (g_CensusPlusManuallyPaused) then
EmFor@0 1219 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1220 GameTooltip:SetText(CENSUSPlus_UNPAUSECENSUS, 1.0, 1.0, 1.0);
EmFor@0 1221 GameTooltip:Show();
EmFor@0 1222 else
EmFor@0 1223 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1224 GameTooltip:SetText(CENSUSPlus_PAUSECENSUS, 1.0, 1.0, 1.0);
EmFor@0 1225 GameTooltip:Show();
EmFor@0 1226 end
EmFor@0 1227 else
EmFor@0 1228 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 1229 GameTooltip:SetText(CENSUSPlus_TAKEGUILDCENSUS, 1.0, 1.0, 1.0);
EmFor@0 1230 GameTooltip:Show();
EmFor@0 1231 end
EmFor@0 1232 end
EmFor@0 1233
EmFor@0 1234 -----------------------------------------------------------------------------------
EmFor@0 1235 --
EmFor@0 1236 -- Pause the current census
EmFor@0 1237 --
EmFor@0 1238 -----------------------------------------------------------------------------------
EmFor@0 1239 function CensusPlus_TogglePause()
EmFor@0 1240 if (g_IsCensusPlusInProgress == true) then
EmFor@0 1241 if( g_CensusPlusManuallyPaused == true ) then
EmFor@0 1242 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE );
EmFor@0 1243 g_CensusPlusManuallyPaused = false;
EmFor@0 1244 else
EmFor@0 1245 CensusPlusTakeButton:SetText( CENSUSPlus_UNPAUSE );
EmFor@0 1246 g_CensusPlusManuallyPaused = true;
EmFor@0 1247 end
EmFor@0 1248 end
EmFor@0 1249 end
EmFor@0 1250
EmFor@0 1251 -----------------------------------------------------------------------------------
EmFor@0 1252 --
EmFor@0 1253 -- Purge the database for this realm and faction
EmFor@0 1254 --
EmFor@0 1255 -----------------------------------------------------------------------------------
EmFor@0 1256 function CensusPlus_Purge()
EmFor@0 1257 StaticPopup_Show ("CP_PURGE_CONFIRM");
EmFor@0 1258 end
EmFor@0 1259
EmFor@0 1260 -----------------------------------------------------------------------------------
EmFor@0 1261 --
EmFor@0 1262 -- CensusPlus_DoPurge
EmFor@0 1263 --
EmFor@0 1264 -----------------------------------------------------------------------------------
EmFor@0 1265 function CensusPlus_DoPurge()
EmFor@0 1266 if( CensusPlus_Database["Servers"] ~= nil ) then
EmFor@0 1267 CensusPlus_Database["Servers"] = nil;
EmFor@0 1268 end
EmFor@0 1269 CensusPlus_Database["Servers"] = {};
EmFor@0 1270 CensusPlus_UpdateView();
EmFor@0 1271 CensusPlus_Msg(CENSUSPlus_PURGEMSG);
EmFor@0 1272
EmFor@0 1273 if( CensusPlus_Database["Guilds"] ~= nil ) then
EmFor@0 1274 CensusPlus_Database["Guilds"] = nil;
EmFor@0 1275 end
EmFor@0 1276 CensusPlus_Database["Guilds"] = {};
EmFor@0 1277
EmFor@0 1278 if( CensusPlus_Database["TimesPlus"] ~= nil ) then
EmFor@0 1279 CensusPlus_Database["TimesPlus"] = nil;
EmFor@0 1280 end
EmFor@0 1281 CensusPlus_Database["TimesPlus"] = {};
EmFor@0 1282
EmFor@0 1283 if( CensusPlus_Profile ~= nil ) then
EmFor@0 1284 CensusPlus_Profile = nil;
EmFor@0 1285 end
EmFor@0 1286 CensusPlus_Profile = {};
EmFor@0 1287
EmFor@0 1288 if( CensusPlus_BGInfo ~= nil ) then
EmFor@0 1289 CensusPlus_BGInfo = nil;
EmFor@0 1290 end
EmFor@0 1291 CensusPlus_BGInfo = {};
EmFor@0 1292
EmFor@0 1293 CensusPlus_Msg( "Data Purged" );
EmFor@0 1294 end
EmFor@0 1295
EmFor@0 1296 -----------------------------------------------------------------------------------
EmFor@0 1297 --
EmFor@0 1298 -- Handler for auto close checkbox
EmFor@0 1299 --
EmFor@0 1300 -----------------------------------------------------------------------------------
EmFor@0 1301 function CensusPlus_AutoCloseWho(close)
EmFor@0 1302 g_WhoAutoClose = close;
EmFor@0 1303 end
EmFor@0 1304
EmFor@0 1305 --function CensusPlus_WhoLibEvent(event, query, ...)
EmFor@0 1306 -- CensusPlus_Msg( event )
EmFor@0 1307 --end
EmFor@0 1308
EmFor@0 1309 --rm
EmFor@0 1310 -----------------------------------------------------------------------------------
EmFor@0 1311 -- Take a guild CensusPlus
EmFor@0 1312 -----------------------------------------------------------------------------------
EmFor@0 1313 function CensusPlus_StartGuildCensus()
EmFor@0 1314 if (g_IsCensusPlusInProgress) then
EmFor@0 1315 -- Do not initiate a new CensusPlus while one is in progress
EmFor@0 1316 CensusPlus_Msg(CENSUSPlus_ISINPROGRESS);
EmFor@0 1317 elseif( g_CurrentlyInBG ) then
EmFor@0 1318 g_LastCensusRun = time()-600;
EmFor@0 1319 if( not g_CurrentlyInBG_Msg ) then
EmFor@0 1320 CensusPlus_Msg(CENSUSPlus_ISINBG);
EmFor@0 1321 g_CurrentlyInBG_Msg = true;
EmFor@0 1322 end
EmFor@0 1323 else
EmFor@0 1324 -- Set a timer
EmFor@0 1325 g_CensusPlus_StartTime = time();
EmFor@0 1326 -- Initialize the job queue and counters
EmFor@0 1327 CensusPlus_Msg(CENSUSPlus_TAKINGONLINE);
EmFor@0 1328 g_NumNewCharacters = 0;
EmFor@0 1329 g_NumUpdatedCharacters = 0;
EmFor@0 1330 g_JobQueue = {};
EmFor@0 1331 g_TempCount = nil;
EmFor@0 1332 g_TempCount = {};
EmFor@0 1333 g_TempZoneCount = nil;
EmFor@0 1334 g_TempZoneCount = {};
EmFor@0 1335 -- The Job List Works as LIFO; last in, first out
EmFor@0 1336 -- for Cataclysm, ... and GM's :) after all following Jobs
EmFor@0 1337 local job = CensusPlus_CreateJob( ( MAX_CHARACTER_LEVEL + 1 ) , MAX_LEVEL_DISPLAY, nil, nil, nil , CensusPlus_MYGUILD );
EmFor@0 1338 InsertJobIntoQueue(job);
EmFor@0 1339 -- ending with lvl MAX_CHARACTER_LEVEL
EmFor@0 1340 local counter = MAX_CHARACTER_LEVEL;
EmFor@0 1341 local LowCounter = counter;
EmFor@0 1342 local LowCharDetailLevel = 3;
EmFor@0 1343 local LevelStep = 10;
EmFor@0 1344
EmFor@0 1345 local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , CensusPlus_MYGUILD );
EmFor@0 1346 InsertJobIntoQueue(job);
EmFor@0 1347 counter = counter - 1;
EmFor@0 1348 while (counter > LowCharDetailLevel) do
EmFor@0 1349 LowCounter = counter - LevelStep + 1 ;
EmFor@0 1350 if (LowCounter <= LowCharDetailLevel) then
EmFor@0 1351 LowCounter = LowCharDetailLevel +1 ;
EmFor@0 1352 end
EmFor@0 1353 local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , CensusPlus_MYGUILD );
EmFor@0 1354 InsertJobIntoQueue(job);
EmFor@0 1355 counter = LowCounter - 1 ;
EmFor@0 1356 end
EmFor@0 1357 while (counter > 0) do
EmFor@0 1358 LowCounter = counter ;
EmFor@0 1359 local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , CensusPlus_MYGUILD );
EmFor@0 1360 InsertJobIntoQueue(job);
EmFor@0 1361 counter = LowCounter - 1 ;
EmFor@0 1362 end
EmFor@0 1363 ------------------
EmFor@0 1364 -- Test inserts
EmFor@0 1365 -- local job = CensusPlus_CreateJob( 11, 12, "Troll", nil, nil , CensusPlus_MYGUILD );
EmFor@0 1366 -- InsertJobIntoQueue(job);
EmFor@0 1367 g_IsCensusPlusInProgress = true;
EmFor@0 1368 g_WaitingForWhoUpdate = false;
EmFor@0 1369 g_CensusPlusManuallyPaused = false;
EmFor@0 1370 local hour, minute = GetGameTime();
EmFor@0 1371 g_TakeHour = hour;
EmFor@0 1372 g_ResetHour = true;
EmFor@0 1373 wholib = wholib or LibStub:GetLibrary("LibWho-2.0", true);
EmFor@0 1374 -- Subvert WhoLib
EmFor@0 1375 if( wholib ) then
EmFor@0 1376 CensusPlus_Msg( "Using WhoLib" );
EmFor@0 1377 end
EmFor@0 1378 end
EmFor@0 1379 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE );
EmFor@0 1380 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKINGGUILD.." \""..CensusPlus_MYGUILD.."\"" );
EmFor@0 1381 end
EmFor@0 1382
EmFor@0 1383
EmFor@0 1384 -----------------------------------------------------------------------------------
EmFor@0 1385 --
EmFor@0 1386 -- Take a CensusPlus
EmFor@0 1387 --
EmFor@0 1388 -----------------------------------------------------------------------------------
EmFor@0 1389 function CensusPlus_StartCensus()
EmFor@0 1390
EmFor@0 1391 if (g_IsCensusPlusInProgress) then
EmFor@0 1392 if( g_CensusPlusManuallyPaused == true ) then
EmFor@0 1393 g_CensusPlusManuallyPaused = false;
EmFor@0 1394 CensusPlusPauseButton:SetText( CENSUSPlus_PAUSE );
EmFor@0 1395 else
EmFor@0 1396 -- Do not initiate a new CensusPlus while one is in progress
EmFor@0 1397 CensusPlus_Msg(CENSUSPlus_ISINPROGRESS);
EmFor@0 1398 end
EmFor@0 1399 elseif( g_CurrentlyInBG ) then
EmFor@0 1400 g_LastCensusRun = time()-600;
EmFor@0 1401 if( not g_CurrentlyInBG_Msg ) then
EmFor@0 1402 CensusPlus_Msg(CENSUSPlus_ISINBG);
EmFor@0 1403 g_CurrentlyInBG_Msg = true;
EmFor@0 1404 end
EmFor@0 1405 else
EmFor@0 1406 --
EmFor@0 1407 -- Set a timer
EmFor@0 1408 --
EmFor@0 1409 g_CensusPlus_StartTime = time();
EmFor@0 1410
EmFor@0 1411 --
EmFor@0 1412 -- Initialize the job queue and counters
EmFor@0 1413 --
EmFor@0 1414 CensusPlus_Msg(CENSUSPlus_TAKINGONLINE);
EmFor@0 1415 g_NumNewCharacters = 0;
EmFor@0 1416 g_NumUpdatedCharacters = 0;
EmFor@0 1417 g_JobQueue = {};
EmFor@0 1418
EmFor@0 1419 g_TempCount = nil;
EmFor@0 1420 g_TempCount = {};
EmFor@0 1421
EmFor@0 1422 g_TempZoneCount = nil;
EmFor@0 1423 g_TempZoneCount = {};
EmFor@0 1424 --
EmFor@0 1425 -- First job covers all characters by searching all levels
EmFor@0 1426 --
EmFor@0 1427 -- The Job List Works as LIFO; last in, first out
EmFor@0 1428 -- local job = {m_MinLevel = 1, m_MaxLevel = MAX_CHARACTER_LEVEL};
EmFor@0 1429 -- InsertJobIntoQueue(job);
EmFor@0 1430 --rm
EmFor@0 1431 -- for Cataclysm, ... and GM's :) after all following Jobs
EmFor@0 1432 local job = CensusPlus_CreateJob( ( MAX_CHARACTER_LEVEL + 1 ) , MAX_LEVEL_DISPLAY, nil, nil, nil , nil );
EmFor@0 1433 InsertJobIntoQueue(job);
EmFor@0 1434 ---- ending with lvl 1-10
EmFor@0 1435 -- local counter = 0;
EmFor@0 1436 -- for counter = 0, 6, 1 do
EmFor@0 1437 -- local job = CensusPlus_CreateJob( counter*10 + 1, counter*10+10, nil, nil, nil , nil );
EmFor@0 1438 -- InsertJobIntoQueue(job);
EmFor@0 1439 -- end
EmFor@0 1440 ---- do 71-79 before the above jobs
EmFor@0 1441 -- job = CensusPlus_CreateJob( 71, 79, nil, nil, nil , nil );
EmFor@0 1442 -- InsertJobIntoQueue(job);
EmFor@0 1443 ---- do 80-80 before the above jobs
EmFor@0 1444 -- job = CensusPlus_CreateJob( 80, 80, nil, nil, nil , nil );
EmFor@0 1445 -- InsertJobIntoQueue(job);
EmFor@0 1446
EmFor@0 1447 -- ending with lvl MAX_CHARACTER_LEVEL
EmFor@0 1448 local counter = MAX_CHARACTER_LEVEL;
EmFor@0 1449 local LowCounter = counter;
EmFor@0 1450 local LowCharDetailLevel = 3;
EmFor@0 1451 local LevelStep = 10;
EmFor@0 1452
EmFor@0 1453
EmFor@0 1454 local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , nil );
EmFor@0 1455 InsertJobIntoQueue(job);
EmFor@0 1456 counter = counter - 1;
EmFor@0 1457 while (counter > LowCharDetailLevel) do
EmFor@0 1458 LowCounter = counter - LevelStep + 1 ;
EmFor@0 1459 if (LowCounter <= LowCharDetailLevel) then
EmFor@0 1460 LowCounter = LowCharDetailLevel +1 ;
EmFor@0 1461 end
EmFor@0 1462 local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , nil );
EmFor@0 1463 InsertJobIntoQueue(job);
EmFor@0 1464 counter = LowCounter - 1 ;
EmFor@0 1465 end
EmFor@0 1466 while (counter > 0) do
EmFor@0 1467 LowCounter = counter ;
EmFor@0 1468 local job = CensusPlus_CreateJob( LowCounter, counter, nil, nil, nil , nil );
EmFor@0 1469 InsertJobIntoQueue(job);
EmFor@0 1470 counter = LowCounter - 1 ;
EmFor@0 1471 end
EmFor@0 1472 ------------------
EmFor@0 1473
EmFor@0 1474
EmFor@0 1475 -- for counter = 60, MAX_CHARACTER_LEVEL, 1 do
EmFor@0 1476 -- local job = CensusPlus_CreateJob( counter, counter, nil, nil, nil , nil );
EmFor@0 1477 -- InsertJobIntoQueue(job);
EmFor@0 1478 -- end
EmFor@0 1479
EmFor@0 1480 -- Test inserts
EmFor@0 1481 -- local job = CensusPlus_CreateJob( 11, 12, "Troll", nil, nil , nil );
EmFor@0 1482 -- InsertJobIntoQueue(job);
EmFor@0 1483 g_IsCensusPlusInProgress = true;
EmFor@0 1484 g_WaitingForWhoUpdate = false;
EmFor@0 1485 g_CensusPlusManuallyPaused = false;
EmFor@0 1486
EmFor@0 1487 local hour, minute = GetGameTime();
EmFor@0 1488 g_TakeHour = hour;
EmFor@0 1489 g_ResetHour = true;
EmFor@0 1490
EmFor@0 1491 wholib = wholib or LibStub:GetLibrary("LibWho-2.0", true);
EmFor@0 1492 --
EmFor@0 1493 -- Subvert WhoLib
EmFor@0 1494 --
EmFor@0 1495 if( wholib ) then
EmFor@0 1496 --
EmFor@0 1497 -- Be prepared to subvert the WhoLib mechanic
EmFor@0 1498 --
EmFor@0 1499 -- g_WhoLibSubvert = SlashCmdList["WHO"];
EmFor@0 1500 -- SlashCmdList["WHO"] = CensusPlus_WhoHandler;
EmFor@0 1501 --
EmFor@0 1502 -- g_WhoLibSendWhoSubvert = SendWho;
EmFor@0 1503 -- SendWho = WhoLibByALeX.hooks.SendWho;
EmFor@0 1504 --
EmFor@0 1505 -- g_WhoLibResultSubvert = WhoLibByALeX.WHO_LIST_UPDATE;
EmFor@0 1506 -- g_WhoLibChatSubvert = WhoLibByALeX.CHAT_MSG_SYSTEM;
EmFor@0 1507 -- g_WhoLibAskWhoSubvert = WhoLibByALeX.AskWho;
EmFor@0 1508 --
EmFor@0 1509 -- WhoLibByALeX.WHO_LIST_UPDATE = function( args ) end
EmFor@0 1510 -- WhoLibByALeX.CHAT_MSG_SYSTEM = function( args ) end
EmFor@0 1511 -- WhoLibByALeX.AskWho = function( args ) end
EmFor@0 1512
EmFor@0 1513 CensusPlus_Msg( "Using WhoLib" );
EmFor@0 1514
EmFor@0 1515
EmFor@0 1516 --wholib.RegisterCallback("CensusPlus", "WHOLIB_QUERY_RESULT", CensusPlus_WhoLibEvent)
EmFor@0 1517
EmFor@0 1518 end
EmFor@0 1519 end
EmFor@11 1520
EmFor@0 1521 CensusPlusTakeButton:SetText( CENSUSPlus_PAUSE );
EmFor@11 1522
EmFor@0 1523 end
EmFor@0 1524
EmFor@0 1525 -----------------------------------------------------------------------------------
EmFor@0 1526 --
EmFor@0 1527 -- Stop a CensusPlus
EmFor@0 1528 --
EmFor@0 1529 -----------------------------------------------------------------------------------
EmFor@0 1530 function CensusPlus_StopCensus( )
EmFor@0 1531 if (g_IsCensusPlusInProgress) then
EmFor@0 1532 CensusPlusTakeButton:SetText( CENSUSPlus_TAKE );
EmFor@0 1533 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" ); CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" );
EmFor@0 1534 g_CensusPlusManuallyPaused = false;
EmFor@0 1535
EmFor@0 1536 CensusPlusScanProgress:SetText( CENSUSPlus_SCAN_PROGRESS_0 );
EmFor@0 1537
EmFor@0 1538 g_JobQueue = {};
EmFor@0 1539 g_JobQueue = nil;
EmFor@0 1540 g_JobQueue = {};
EmFor@0 1541
EmFor@0 1542 CensusPlus_DisplayResults( );
EmFor@0 1543
EmFor@0 1544 -- Clean up the times
EmFor@0 1545 CensusPlus_PruneTimes();
EmFor@0 1546
EmFor@0 1547 -- if( wholib ) then
EmFor@0 1548 -- SlashCmdList["WHO"] = g_WhoLibSubvert;
EmFor@0 1549 --
EmFor@0 1550 -- SendWho = g_WhoLibSendWhoSubvert;
EmFor@0 1551 -- WhoLibByALeX.WHO_LIST_UPDATE = g_WhoLibResultSubvert;
EmFor@0 1552 -- WhoLibByALeX.CHAT_MSG_SYSTEM = g_WhoLibChatSubvert;
EmFor@0 1553 -- WhoLibByALeX.AskWho = g_WhoLibAskWhoSubvert;
EmFor@0 1554
EmFor@0 1555
EmFor@0 1556 -- CensusPlus_Msg( "Unregistering with WhoLib" );
EmFor@0 1557
EmFor@0 1558 --wholib.UnregisterAllCallbacks("CensusPlus")
EmFor@0 1559 -- end
EmFor@0 1560
EmFor@0 1561 else
EmFor@0 1562 CensusPlus_Msg(CENSUSPlus_NOCENSUS);
EmFor@0 1563 end
EmFor@0 1564 end
EmFor@0 1565
EmFor@0 1566 -----------------------------------------------------------------------------------
EmFor@0 1567 --
EmFor@0 1568 -- Display Census results
EmFor@0 1569 --
EmFor@0 1570 -----------------------------------------------------------------------------------
EmFor@0 1571 function CensusPlus_DisplayResults( )
EmFor@0 1572 --
EmFor@0 1573 -- We are all done, report our results
EmFor@0 1574 --
EmFor@0 1575 g_IsCensusPlusInProgress = false;
EmFor@0 1576
EmFor@0 1577
EmFor@0 1578 --
EmFor@0 1579 -- Finish our timer
EmFor@0 1580 --
EmFor@0 1581 local total_time = time() - g_CensusPlus_StartTime;
EmFor@0 1582
EmFor@0 1583 CensusPlus_Msg(format(CENSUSPlus_FINISHED, g_NumNewCharacters, g_NumUpdatedCharacters, SecondsToTime( total_time )));
EmFor@0 1584 ChatFrame1:AddMessage(CENSUSPlus_UPLOAD, 0.5, 1.0, 1.0);
EmFor@0 1585
EmFor@0 1586 CensusPlus_UpdateView();
EmFor@0 1587 g_LastCensusRun = time();
EmFor@0 1588
EmFor@0 1589 CensusPlusTakeButton:SetText( CENSUSPlus_TAKE );
EmFor@0 1590 CensusPlusTakeGuildButton:SetText( CENSUSPlus_TAKEGUILD.." \""..CensusPlus_MYGUILD.."\"" );
EmFor@0 1591 end
EmFor@0 1592
EmFor@0 1593 -----------------------------------------------------------------------------------
EmFor@0 1594 --
EmFor@0 1595 -- Create a who command text for the input job
EmFor@0 1596 --
EmFor@0 1597 -----------------------------------------------------------------------------------
EmFor@0 1598 function CensusPlus_CreateWhoText(job)
EmFor@0 1599 local whoText = "";
EmFor@0 1600 local race = job.m_Race;
EmFor@0 1601 if (race ~= nil) then
EmFor@0 1602 whoText = whoText.." r-\""..race.."\"";
EmFor@0 1603 end
EmFor@0 1604
EmFor@0 1605 local class = job.m_Class;
EmFor@0 1606 if (class ~= nil) then
EmFor@0 1607 whoText = whoText.." c-\""..class.."\"";
EmFor@0 1608 end
EmFor@0 1609
EmFor@0 1610 local minLevel = tostring( job.m_MinLevel );
EmFor@0 1611 if (minLevel == nil) then
EmFor@0 1612 minLevel = 1;
EmFor@0 1613 end
EmFor@0 1614 local maxLevel = job.m_MaxLevel;
EmFor@0 1615 if (maxLevel == nil) then
EmFor@0 1616 maxLevel = MAX_CHARACTER_LEVEL;
EmFor@0 1617 end
EmFor@0 1618 whoText = whoText.." ".. minLevel .."-".. maxLevel;
EmFor@0 1619
EmFor@0 1620 local zoneLetter = job.m_zoneLetter;
EmFor@0 1621 if ( zoneLetter ~= nil) then
EmFor@0 1622 whoText = whoText.." z-"..zoneLetter;
EmFor@0 1623 end
EmFor@0 1624
EmFor@0 1625 local letter = job.m_Letter;
EmFor@0 1626 if( letter ~= nil ) then
EmFor@0 1627 whoText = whoText.." n-"..letter;
EmFor@0 1628 end
EmFor@0 1629 --rmg
EmFor@0 1630 local guild = job.m_Guild;
EmFor@0 1631 if( guild ~= nil ) then
EmFor@0 1632 whoText = whoText.." g-\""..guild.."\"";
EmFor@0 1633 end
EmFor@0 1634
EmFor@0 1635 return whoText;
EmFor@0 1636 end
EmFor@0 1637
EmFor@0 1638 -----------------------------------------------------------------------------------
EmFor@0 1639 --
EmFor@0 1640 -- Create a job
EmFor@0 1641 --
EmFor@0 1642 -----------------------------------------------------------------------------------
EmFor@0 1643 function CensusPlus_CreateJob( minLevel, maxLevel, race, class, letter, guild )
EmFor@0 1644 local job = {};
EmFor@0 1645 job.m_MinLevel = minLevel;
EmFor@0 1646 job.m_MaxLevel = maxLevel;
EmFor@0 1647 job.m_Race = race;
EmFor@0 1648 job.m_Class = class;
EmFor@0 1649 job.m_Letter = letter;
EmFor@0 1650 job.m_Guild = guild;
EmFor@0 1651
EmFor@0 1652 CensusPlus_DumpJob( job );
EmFor@0 1653
EmFor@0 1654 return job;
EmFor@0 1655 end
EmFor@0 1656
EmFor@0 1657 -----------------------------------------------------------------------------------
EmFor@0 1658 --
EmFor@0 1659 -- Debug function do dump a job
EmFor@0 1660 --
EmFor@0 1661 -----------------------------------------------------------------------------------
EmFor@0 1662 function CensusPlus_DumpJob( job )
EmFor@0 1663 local whoText = "";
EmFor@0 1664 local race = job.m_Race;
EmFor@0 1665 if (race ~= nil) then
EmFor@0 1666 whoText = whoText.." R: "..race;
EmFor@0 1667 end
EmFor@0 1668
EmFor@0 1669 local class = job.m_Class;
EmFor@0 1670 if (class ~= nil) then
EmFor@0 1671 whoText = whoText.." C: "..class;
EmFor@0 1672 end
EmFor@0 1673
EmFor@0 1674 local minLevel = job.m_MinLevel;
EmFor@0 1675 if (minLevel ~= nil) then
EmFor@0 1676 whoText = whoText.." min: ".. minLevel;
EmFor@0 1677 end
EmFor@0 1678
EmFor@0 1679 local maxLevel = job.m_MaxLevel;
EmFor@0 1680 if (maxLevel ~= nil) then
EmFor@0 1681 whoText = whoText.." max: ".. maxLevel;
EmFor@0 1682 end
EmFor@0 1683
EmFor@0 1684 local zoneLetter = job.m_zoneLetter;
EmFor@0 1685 if ( zoneLetter ~= nil) then
EmFor@0 1686 whoText = whoText.." Z: "..zoneLetter;
EmFor@0 1687 end
EmFor@0 1688
EmFor@0 1689 local letter = job.m_Letter;
EmFor@0 1690 if( letter ~= nil ) then
EmFor@0 1691 whoText = whoText.." N: "..letter;
EmFor@0 1692 end
EmFor@0 1693 --rmg
EmFor@0 1694 local guild = job.m_Guild;
EmFor@0 1695 if( guild ~= nil ) then
EmFor@0 1696 whoText = whoText.." G: \""..guild.."\"";
EmFor@0 1697 end
EmFor@0 1698
EmFor@0 1699 --CensusPlus_Msg( "JOB DUMP: " .. whoText );
EmFor@0 1700 end
EmFor@0 1701
EmFor@0 1702 -----------------------------------------------------------------------------------
EmFor@0 1703 --
EmFor@0 1704 -- Called on events
EmFor@0 1705 --
EmFor@0 1706 -----------------------------------------------------------------------------------
EmFor@0 1707 function CensusPlus_OnEvent(event,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)
EmFor@0 1708
EmFor@0 1709 if( arg1 == nil ) then
EmFor@0 1710 arg1 = "nil"
EmFor@0 1711 end
EmFor@0 1712 if( arg2 == nil ) then
EmFor@0 1713 arg2 = "nil"
EmFor@0 1714 end
EmFor@0 1715 if( arg3 == nil ) then
EmFor@0 1716 arg3 = "nil"
EmFor@0 1717 end
EmFor@0 1718 if( arg4 == nil ) then
EmFor@0 1719 arg4 = "nil"
EmFor@0 1720 end
EmFor@0 1721
EmFor@0 1722 --
EmFor@0 1723 -- If we have not been initialized, do nothing
EmFor@0 1724 --
EmFor@0 1725 if (g_CensusPlusInitialized == false) then
EmFor@0 1726 return
EmFor@0 1727 end
EmFor@0 1728
EmFor@0 1729 -- CensusPlus_Msg( "Message =>" .. event );
EmFor@0 1730
EmFor@0 1731 --
EmFor@0 1732 -- WHO_LIST_UPDATE
EmFor@0 1733 --
EmFor@0 1734 if( event == "TRAINER_SHOW" or event == "MERCHANT_SHOW" or event == "TRADE_SHOW" or event == "GUILD_REGISTRAR_SHOW"
EmFor@0 1735 or event == "AUCTION_HOUSE_SHOW" or event == "BANKFRAME_OPENED" or event == "QUEST_DETAIL" ) then
EmFor@0 1736 if( g_IsCensusPlusInProgress ) then
EmFor@0 1737 g_CensusPlusPaused = true;
EmFor@0 1738 end
EmFor@0 1739 elseif( event == "TRAINER_CLOSED" or event == "MERCHANT_CLOSED" or event == "TRADE_CLOSED" or event == "GUILD_REGISTRAR_CLOSED"
EmFor@0 1740 or event == "AUCTION_HOUSE_CLOSED" or event == "BANKFRAME_CLOSED" or event == "QUEST_FINISHED" ) then
EmFor@0 1741 if( g_IsCensusPlusInProgress ) then
EmFor@0 1742 g_CensusPlusPaused = false;
EmFor@0 1743 end
EmFor@0 1744 elseif (event == "GUILD_ROSTER_SHOW") then
EmFor@0 1745 --
EmFor@0 1746 -- Process Guild info
EmFor@0 1747 --
EmFor@0 1748 --CensusPlus_Msg( " SHOW GUILD " );
EmFor@0 1749 CensusPlus_ProcessGuildResults();
EmFor@0 1750
EmFor@0 1751 elseif (event == "GUILD_ROSTER_UPDATE") then
EmFor@0 1752 --
EmFor@0 1753 -- Process Guild info
EmFor@0 1754 --
EmFor@0 1755 --CensusPlus_Msg( " UPDATE GUILD " );
EmFor@0 1756 if(not CP_updatingGuild ) then
EmFor@0 1757 CP_updatingGuild = 1;
EmFor@0 1758 CensusPlus_ProcessGuildResults();
EmFor@0 1759 CP_updatingGuild = nil;
EmFor@0 1760 end
EmFor@0 1761
EmFor@0 1762
EmFor@0 1763 elseif ( event == "VARIABLES_LOADED" ) then
EmFor@0 1764 --
EmFor@0 1765 -- Initialize our variables
EmFor@0 1766 --
EmFor@0 1767 CensusPlus_InitializeVariables();
EmFor@0 1768 elseif( event == "ZONE_CHANGED_NEW_AREA" ) then
EmFor@0 1769 --
EmFor@0 1770 -- We need to check to see if we entered a battleground
EmFor@0 1771 --
EmFor@0 1772 CensusPlus_CheckForBattleground();
EmFor@0 1773 elseif( event == "UPDATE_BATTLEFIELD_STATUS" ) then
EmFor@0 1774 CensusPlus_UpdateBattleGroundInfo();
EmFor@0 1775 end
EmFor@0 1776 end
EmFor@0 1777
EmFor@0 1778 -----------------------------------------------------------------------------------
EmFor@0 1779 --
EmFor@0 1780 -- ProcessTarget -- called when UNIT_FOCUS event is fired
EmFor@0 1781 --
EmFor@0 1782 -----------------------------------------------------------------------------------
EmFor@0 1783 function CensusPlus_ProcessTarget( unit )
EmFor@0 1784 -- have to totally disable this due to X-server bg's
EmFor@0 1785 if( true ) then
EmFor@0 1786 return;
EmFor@0 1787 end
EmFor@0 1788
EmFor@0 1789 if ( UnitIsPlayer(unit) == nil or (not UnitIsPlayer(unit)) or unit == "player" or unit == nil ) then
EmFor@0 1790 return;
EmFor@0 1791 end
EmFor@0 1792
EmFor@0 1793 local sightingData = CensusPlus_CollectSightingData( unit );
EmFor@0 1794 if( sightingData == nil or sightingData.faction == nil ) then
EmFor@0 1795 return
EmFor@0 1796 end
EmFor@0 1797
EmFor@0 1798 if (sightingData ~= nil and (sightingData.faction == "Alliance" or sightingData.faction == "Horde")) then
EmFor@0 1799
EmFor@0 1800 --
EmFor@0 1801 -- Do a quick check to see if this is an MC'd person
EmFor@0 1802 --
EmFor@0 1803 if( sightingData.faction ~= g_FactionCheck[sightingData.race] ) then
EmFor@0 1804 return;
EmFor@0 1805 end
EmFor@0 1806
EmFor@0 1807
EmFor@0 1808 if( sightingData.guild == nil ) then
EmFor@0 1809 sightingData.guild = "";
EmFor@0 1810 end
EmFor@0 1811 --
EmFor@0 1812 -- Get the portion of the database for this server
EmFor@0 1813 --
EmFor@0 1814 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 1815 local realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 1816 if (realmDatabase == nil) then
EmFor@0 1817 CensusPlus_Database["Servers"][realmName] = {};
EmFor@0 1818 realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 1819 end
EmFor@0 1820
EmFor@0 1821 --
EmFor@0 1822 -- Get the portion of the database for this faction
EmFor@0 1823 --
EmFor@0 1824 local factionDatabase = realmDatabase[sightingData.faction];
EmFor@0 1825 if (factionDatabase == nil) then
EmFor@0 1826 realmDatabase[sightingData.faction] = {};
EmFor@0 1827 factionDatabase = realmDatabase[sightingData.faction];
EmFor@0 1828 end
EmFor@0 1829
EmFor@0 1830 --
EmFor@0 1831 -- Get racial database
EmFor@0 1832 --
EmFor@0 1833 local raceDatabase = factionDatabase[sightingData.race];
EmFor@0 1834 if (raceDatabase == nil) then
EmFor@0 1835 factionDatabase[sightingData.race] = {};
EmFor@0 1836 raceDatabase = factionDatabase[sightingData.race];
EmFor@0 1837 end
EmFor@0 1838
EmFor@0 1839 --
EmFor@0 1840 -- Get class database
EmFor@0 1841 --
EmFor@0 1842 local classDatabase = raceDatabase[sightingData.class];
EmFor@0 1843 if (classDatabase == nil) then
EmFor@0 1844 raceDatabase[sightingData.class] = {};
EmFor@0 1845 classDatabase = raceDatabase[sightingData.class];
EmFor@0 1846 end
EmFor@0 1847
EmFor@0 1848 --
EmFor@0 1849 -- Get this player's entry
EmFor@0 1850 --
EmFor@0 1851 local entry = classDatabase[sightingData.name];
EmFor@0 1852 if (entry == nil) then
EmFor@0 1853 classDatabase[sightingData.name] = {};
EmFor@0 1854 entry = classDatabase[sightingData.name];
EmFor@0 1855 end
EmFor@0 1856
EmFor@0 1857 --
EmFor@0 1858 -- Update the information
EmFor@0 1859 --
EmFor@0 1860 entry[1] = sightingData.level;
EmFor@0 1861 entry[2] = sightingData.guild;
EmFor@0 1862 entry[3] = CensusPlus_DetermineServerDate() .. "";
EmFor@0 1863
EmFor@0 1864 entry[7] = CensusPlus_DetermineServerDate() .. "";
EmFor@0 1865
EmFor@0 1866 --
EmFor@0 1867 -- Update their rank info
EmFor@0 1868 --
EmFor@0 1869 rankNumber = UnitPVPRank(unit);
EmFor@0 1870 if( rankNumber ~= 0 ) then
EmFor@0 1871 -- rankName= GetPVPRankInfo( rankNumber )
EmFor@0 1872 entry[8] = rankNumber; -- slot 8 will be current rank
EmFor@0 1873 else
EmFor@0 1874 entry[8] = 0; -- slot 8 will be current rank
EmFor@0 1875 end
EmFor@0 1876
EmFor@0 1877 --
EmFor@0 1878 -- Trigger an update on the inspect honor frame to get honor information
EmFor@0 1879 --
EmFor@0 1880 if ( UnitIsPlayer( unit ) and sightingData.level >= 30
EmFor@0 1881 and CheckInteractDistance( unit, 1)
EmFor@0 1882 and not UnitIsUnit("player", unit) and unit == "target"
EmFor@0 1883 and g_CensusPlusLastTarget == nil
EmFor@0 1884 and g_CensusPlusLastTargetName == nil
EmFor@0 1885 and CensusPlus_IsInspectLoaded() ) then
EmFor@0 1886 NotifyInspect(unit);
EmFor@0 1887 InspectFrame.unit = unit;
EmFor@0 1888 if ( not HasInspectHonorData() ) then
EmFor@0 1889 g_CensusPlusLastTarget = entry;
EmFor@0 1890 g_CensusPlusLastTargetName = sightingData.name;
EmFor@0 1891 RequestInspectHonorData();
EmFor@0 1892 else
EmFor@0 1893 InspectHonorFrame_Update();
EmFor@0 1894 end
EmFor@0 1895 end
EmFor@0 1896 end
EmFor@0 1897 end
EmFor@0 1898
EmFor@0 1899
EmFor@0 1900 -----------------------------------------------------------------------------------
EmFor@0 1901 --
EmFor@0 1902 -- Gather targeting data
EmFor@0 1903 --
EmFor@0 1904 -----------------------------------------------------------------------------------
EmFor@0 1905 function CensusPlus_CollectSightingData(unit)
EmFor@0 1906 if ( UnitIsPlayer(unit) and UnitName(unit) ~= "Unknown Entity" ) then
EmFor@0 1907 return {
EmFor@0 1908 name=UnitName(unit),
EmFor@0 1909 level=UnitLevel(unit),
EmFor@0 1910 sex=UnitSex(unit),
EmFor@0 1911 race=UnitRace(unit),
EmFor@0 1912 class=UnitClass(unit),
EmFor@0 1913 guild=GetGuildInfo(unit),
EmFor@0 1914 faction=UnitFactionGroup(unit)
EmFor@0 1915 };
EmFor@0 1916 else
EmFor@0 1917 return nil;
EmFor@0 1918 end
EmFor@0 1919 end
EmFor@0 1920
EmFor@0 1921
EmFor@0 1922 -----------------------------------------------------------------------------------
EmFor@0 1923 --
EmFor@0 1924 -- Initialize our primary save variables -- called when VARIABLES_LOADED event is fired
EmFor@0 1925 --
EmFor@0 1926 -----------------------------------------------------------------------------------
EmFor@0 1927 function CensusPlus_InitializeVariables()
EmFor@0 1928
EmFor@0 1929 if( CensusPlus_Database["Servers"] == nil ) then
EmFor@0 1930 CensusPlus_Database["Servers"] = {};
EmFor@0 1931 end
EmFor@0 1932
EmFor@0 1933 if( CensusPlus_Database["Times"] ~= nil ) then
EmFor@0 1934 CensusPlus_Database["Times"] = nil;
EmFor@0 1935 end
EmFor@0 1936
EmFor@0 1937 if( CensusPlus_Database["TimesPlus"] == nil ) then
EmFor@0 1938 CensusPlus_Database["TimesPlus"] = {};
EmFor@0 1939 end
EmFor@0 1940
EmFor@0 1941 if( CensusPlus_BGInfo == nil ) then
EmFor@0 1942 CensusPlus_BGInfo = {};
EmFor@0 1943 end
EmFor@0 1944
EmFor@0 1945 --
EmFor@0 1946 -- Make sure info is last so it will be first in the output so we can grab the version number
EmFor@0 1947 --
EmFor@0 1948 if( CensusPlus_Database["Info"] == nil ) then
EmFor@0 1949 CensusPlus_Database["Info"] = {};
EmFor@0 1950 end
EmFor@0 1951 CensusPlus_Database["Info"]["Version"] = CensusPlus_VERSION;
EmFor@0 1952 CensusPlus_Database["Info"]["ClientLocale"] = GetLocale();
EmFor@0 1953 if( CensusPlus_Database["Info"]["ClientLocale"] == "enUS" and GetCVar("realmList") == "eu.logon.worldofwarcraft.com" ) then
EmFor@0 1954 CensusPlus_Database["Info"]["ClientLocale"] = "enGB";
EmFor@0 1955 end
EmFor@0 1956 if( CensusPlus_Database["Info"]["LoginServer"] ~= nil ) then
EmFor@0 1957 -- already present, make sure it equals, and if
EmFor@0 1958 -- not, force a purge
EmFor@0 1959 if( CensusPlus_Database["Info"]["LoginServer"] ~= GetCVar("realmList") ) then
EmFor@0 1960 --
EmFor@0 1961 -- We have to nuke the data in the case that someone is playing on both
EmFor@0 1962 -- US and EU servers
EmFor@0 1963 --
EmFor@0 1964 CensusPlus_DoPurge()
EmFor@0 1965 end
EmFor@0 1966 end
EmFor@0 1967 CensusPlus_Database["Info"]["LoginServer"] = GetCVar("realmList");
EmFor@0 1968
EmFor@0 1969 local firstVersionRun = CensusPlus_Database["Info"][g_InterfaceVersion];
EmFor@0 1970 local localeSetting = CensusPlus_Database["Info"]["Locale"];
EmFor@0 1971 if( localeSetting == "??" ) then
EmFor@0 1972 -- We had problems previously.. we must purge =(
EmFor@0 1973 CensusPlus_DoPurge();
EmFor@0 1974 localeSetting = nil;
EmFor@0 1975 end
EmFor@0 1976
EmFor@0 1977 --
EmFor@0 1978 -- Have a new way to detect locale, yay!
EmFor@0 1979 --
EmFor@0 1980 if( CensusPlus_Database["Info"]["ClientLocale"] == "enUS" ) then
EmFor@0 1981 CensusPlus_VerifyLocale( "US" );
EmFor@0 1982 CensusPlus_Database["Info"]["Locale"] = "US";
EmFor@0 1983 elseif( CensusPlus_Database["Info"]["ClientLocale"] == "enGB" or
EmFor@0 1984 CensusPlus_Database["Info"]["ClientLocale"] == "frFR" or
EmFor@0 1985 CensusPlus_Database["Info"]["ClientLocale"] == "deDE" or
EmFor@0 1986 CensusPlus_Database["Info"]["ClientLocale"] == "esES" ) then
EmFor@0 1987 CensusPlus_VerifyLocale( "EU" );
EmFor@0 1988 CensusPlus_Database["Info"]["Locale"] = "EU";
EmFor@0 1989 else
EmFor@0 1990 CensusPlus_VerifyLocale( "??" );
EmFor@0 1991 CensusPlus_Database["Info"]["Locale"] = "??";
EmFor@0 1992 end
EmFor@0 1993
EmFor@0 1994 if( firstVersionRun == nil and g_InterfaceVersion == 21000 ) then
EmFor@0 1995 --
EmFor@0 1996 -- Clean out all character entries that are irregular
EmFor@0 1997 --
EmFor@0 1998 CensusPlus_CleanChars();
EmFor@0 1999 CensusPlus_Database["Info"][g_InterfaceVersion] = true;
EmFor@0 2000 end
EmFor@0 2001
EmFor@0 2002 local locale = CensusPlus_Database["Info"]["Locale"];
EmFor@0 2003 CensusPlus_SelectLocale( CensusPlus_Database["Info"]["Locale"], true );
EmFor@0 2004
EmFor@0 2005 local miniStart = CensusPlus_Database["Info"]["MiniStart"];
EmFor@0 2006 if( miniStart == nil ) then
EmFor@0 2007 miniStart = 0;
EmFor@0 2008 end
EmFor@0 2009
EmFor@0 2010 if( CensusPlus_Database["Info"]["AutoCensus"] == nil ) then
EmFor@0 2011 CensusPlus_Database["Info"]["AutoCensus"] = false;
EmFor@0 2012 end
EmFor@0 2013
EmFor@0 2014 if( CensusPlus_Database["Info"]["AutoCensusTimer"] == nil ) then
EmFor@0 2015 CensusPlus_Database["Info"]["AutoCensusTimer"] = 1800;
EmFor@0 2016 end
EmFor@0 2017
EmFor@0 2018 if( CensusPlus_Database["Info"]["CensusButtonPosition"] == nil ) then
EmFor@0 2019 CensusPlus_Database["Info"]["CensusButtonPosition"] = 370;
EmFor@0 2020 end
EmFor@0 2021
EmFor@0 2022 if( CensusPlus_Database["Info"]["CensusButtonShown"] == nil ) then
EmFor@0 2023 CensusPlus_Database["Info"]["CensusButtonShown"] = 1;
EmFor@0 2024 end
EmFor@0 2025
EmFor@0 2026 if( CensusPlus_Database["Info"]["CensusButtonShown"] == 1 ) then
EmFor@0 2027 CensusButtonFrame:Show();
EmFor@0 2028 else
EmFor@0 2029 CensusButtonFrame:Hide();
EmFor@0 2030 end
EmFor@0 2031
EmFor@0 2032 if( CensusPlus_Database["Info"]["UseLogBars"] == nil ) then
EmFor@0 2033 CensusPlus_Database["Info"]["UseLogBars"] = 1;
EmFor@0 2034 end
EmFor@0 2035 CP_OptionUseLogarithmicBars:SetChecked( CensusPlus_Database["Info"]["UseLogBars"] );
EmFor@0 2036
EmFor@0 2037 CensusPlus_AutoStart(miniStart);
EmFor@0 2038
EmFor@0 2039 if( miniStart ) and (not Khaos) then
EmFor@0 2040 CensusPlus_Msg(" V"..CensusPlus_VERSION..CENSUSPlus_MSG1);
EmFor@0 2041 end
EmFor@0 2042
EmFor@0 2043 g_VariablesLoaded = true;
EmFor@0 2044
EmFor@0 2045 CensusPlus_CheckTZ();
EmFor@0 2046
EmFor@0 2047 InitConstantTables();
EmFor@0 2048
EmFor@0 2049 CP_OptionAutoShowMinimapButton:SetChecked(CensusPlus_Database["Info"]["CensusButtonShown"]);
EmFor@0 2050 -- CP_SliderButtonPos:SetValue(CensusPlus_Database["Info"]["CensusButtonPosition"]);
EmFor@0 2051
EmFor@0 2052 if( CensusPlus_PerCharInfo["PlayFinishSound"] == nil ) then
EmFor@0 2053 CensusPlus_PerCharInfo["PlayFinishSound"] = true;
EmFor@0 2054 end
EmFor@0 2055
EmFor@0 2056 CP_OptionPlaySoundOnCompleteButton:SetChecked( CensusPlus_PerCharInfo["PlayFinishSound"] );
EmFor@0 2057
EmFor@0 2058 if( CensusPlus_PerCharInfo["Verbose"] == nil ) then
EmFor@0 2059 CensusPlus_PerCharInfo["Verbose"] = false;
EmFor@0 2060 end
EmFor@0 2061
EmFor@0 2062
EmFor@0 2063 --
EmFor@0 2064 -- If we are in a guild, attempt to gather the guild roster data
EmFor@0 2065 --
EmFor@0 2066 if (IsInGuild()) then
EmFor@0 2067 GuildRoster();
EmFor@0 2068 end
EmFor@0 2069
EmFor@0 2070 --
EmFor@0 2071 -- Prune times if we have too many
EmFor@0 2072 --
EmFor@0 2073 CensusPlus_PruneTimes();
EmFor@0 2074
EmFor@0 2075 --
EmFor@0 2076 -- Prune BG info if we have too many
EmFor@0 2077 --
EmFor@0 2078 CensusPlus_PruneBGInfo();
EmFor@0 2079
EmFor@0 2080 --
EmFor@0 2081 -- Check for WhoLib since it does not play nice with C+
EmFor@0 2082 --
EmFor@0 2083 CensusPlus_CheckForWhoLib();
EmFor@0 2084 CensusPlus_CheckForPrat();
EmFor@0 2085
EmFor@0 2086 CensusPlus_Unhandled = nil;
EmFor@0 2087 CensusPlus_Unhandled = {};
EmFor@0 2088 end
EmFor@0 2089
EmFor@0 2090 function CensusPlus_CheckForWhoLib()
EmFor@0 2091 if( WhoLibByALeX and WhoLibByALeX.AskWho ) then
EmFor@0 2092 g_WhoLibLoaded = true;
EmFor@0 2093 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 2094 end
EmFor@0 2095 end
EmFor@0 2096
EmFor@0 2097 function CensusPlus_CheckForPrat()
EmFor@0 2098 if( Prat ) then
EmFor@0 2099 g_PratLoaded = true;
EmFor@0 2100 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 2101 end
EmFor@0 2102 end
EmFor@0 2103 -----------------------------------------------------------------------------------
EmFor@0 2104 --
EmFor@0 2105 -- Call on the update event
EmFor@0 2106 --
EmFor@0 2107 -----------------------------------------------------------------------------------
EmFor@0 2108 function CensusPlus_OnUpdate()
EmFor@0 2109 if( g_VariablesLoaded and g_IsCensusPlusInProgress == false and CensusPlus_Database["Info"]["AutoCensus"] == true and g_LastCensusRun < time() - CensusPlus_Database["Info"]["AutoCensusTimer"] ) then
EmFor@0 2110 CensusPlus_Take_OnClick();
EmFor@0 2111 end
EmFor@0 2112
EmFor@0 2113 if (g_IsCensusPlusInProgress == true and g_CensusPlusPaused == false and g_CensusPlusManuallyPaused == false ) then
EmFor@0 2114
EmFor@0 2115 --
EmFor@0 2116 -- update our progress
EmFor@0 2117 --
EmFor@0 2118 local numJobs = table.getn(g_JobQueue);
EmFor@0 2119 if( numJobs > 0 ) then
EmFor@0 2120 CensusPlusScanProgress:SetText(format(CENSUSPlus_SCAN_PROGRESS, numJobs, CensusPlus_CreateWhoText( g_JobQueue[numJobs] ) ));
EmFor@0 2121 end
EmFor@0 2122
EmFor@0 2123 if( g_ReturnedZero == true ) then
EmFor@0 2124 g_ReturnedZero = false;
EmFor@0 2125 --
EmFor@0 2126 -- Determine if there is any more work to do
EmFor@0 2127 --
EmFor@0 2128 if (numJobs > 0) then
EmFor@0 2129 --
EmFor@0 2130 -- Remove the top job from the queue and send it
EmFor@0 2131 --
EmFor@0 2132 local job = g_JobQueue[numJobs];
EmFor@0 2133 table.remove(g_JobQueue);
EmFor@0 2134 local whoText = CensusPlus_CreateWhoText(job);
EmFor@0 2135
EmFor@0 2136 --
EmFor@0 2137 -- Zap our current job
EmFor@0 2138 --
EmFor@0 2139 g_CurrentJob = nil;
EmFor@0 2140
EmFor@0 2141 g_CurrentJob = job;
EmFor@0 2142 g_WaitingForWhoUpdate = true;
EmFor@0 2143
EmFor@0 2144 CensusPlus_SendWho(whoText);
EmFor@0 2145 g_WhoAttempts = 0;
EmFor@0 2146 else
EmFor@0 2147 --
EmFor@0 2148 -- We are all done, hide the friends frame and report our results
EmFor@0 2149 --
EmFor@0 2150 if( CensusPlus_PerCharInfo["PlayFinishSound"] ) then
EmFor@0 2151 PlaySoundFile("Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg")
EmFor@0 2152 end
EmFor@0 2153
EmFor@0 2154 CensusPlus_DoTimeCounts();
EmFor@0 2155 CensusPlus_DisplayResults();
EmFor@0 2156 end
EmFor@0 2157 end
EmFor@0 2158
EmFor@0 2159 local now = GetTime();
EmFor@0 2160 local delta = now - g_LastOnUpdateTime;
EmFor@0 2161 if (not g_WaitingForWhoUpdate or delta > CensusPlus_UPDATEDELAY) then
EmFor@0 2162 g_LastOnUpdateTime = now;
EmFor@0 2163 if (g_WaitingForWhoUpdate == true ) then
EmFor@0 2164
EmFor@0 2165 --
EmFor@0 2166 -- First check to see if we are waiting for an override
EmFor@0 2167 --
EmFor@0 2168 if( g_WaitingForOverrideUpdate == true ) then
EmFor@0 2169 CensusPlus_SendWho( g_CensusWhoOverrideMsg );
EmFor@0 2170 else
EmFor@0 2171 --
EmFor@0 2172 -- Resend /who command
EmFor@0 2173 --
EmFor@0 2174 g_WhoAttempts = g_WhoAttempts + 1;
EmFor@0 2175 local whoText = CensusPlus_CreateWhoText(g_CurrentJob);
EmFor@0 2176 if( CensusPlus_PerCharInfo["Verbose"] == true ) then
EmFor@0 2177 CensusPlus_Msg(CENSUSPlus_WAITING);
EmFor@0 2178 end
EmFor@0 2179 if( g_WhoAttempts < 2 ) then
EmFor@0 2180 CensusPlus_SendWho(whoText);
EmFor@0 2181 else
EmFor@0 2182 g_WaitingForWhoUpdate = false;
EmFor@0 2183 end
EmFor@0 2184 end
EmFor@0 2185 else
EmFor@0 2186
EmFor@0 2187 --
EmFor@0 2188 -- Check to see if we have an override waiting
EmFor@0 2189 --
EmFor@0 2190 if( g_CensusWhoOverrideMsg ~= nil ) then
EmFor@0 2191 CensusPlus_SendWho( g_CensusWhoOverrideMsg );
EmFor@0 2192 g_WaitingForOverrideUpdate = true;
EmFor@0 2193 g_WaitingForWhoUpdate = true;
EmFor@0 2194 else
EmFor@0 2195 --
EmFor@0 2196 -- Determine if there is any more work to do
EmFor@0 2197 --
EmFor@0 2198 local numJobs = table.getn(g_JobQueue);
EmFor@0 2199 if (numJobs > 0) then
EmFor@0 2200 --
EmFor@0 2201 -- Remove the top job from the queue and send it
EmFor@0 2202 --
EmFor@0 2203 local job = g_JobQueue[numJobs];
EmFor@0 2204 table.remove(g_JobQueue);
EmFor@0 2205 local whoText = CensusPlus_CreateWhoText(job);
EmFor@0 2206 g_CurrentJob = nil;
EmFor@0 2207 g_CurrentJob = job;
EmFor@0 2208 g_WaitingForWhoUpdate = true;
EmFor@0 2209 CensusPlus_SendWho(whoText);
EmFor@0 2210 g_WaitingForWhoUpdate = true;
EmFor@0 2211 g_WhoAttempts = 0;
EmFor@0 2212 else
EmFor@0 2213 --
EmFor@0 2214 -- We are all done, hide the friends frame and report our results
EmFor@0 2215 --
EmFor@0 2216 if( CensusPlus_PerCharInfo["PlayFinishSound"] ) then
EmFor@0 2217 PlaySoundFile("Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg")
EmFor@0 2218 end
EmFor@0 2219
EmFor@0 2220 CensusPlus_DoTimeCounts();
EmFor@0 2221 CensusPlus_DisplayResults();
EmFor@0 2222 end
EmFor@0 2223 end
EmFor@0 2224 end
EmFor@0 2225 end
EmFor@0 2226 end
EmFor@0 2227 end
EmFor@0 2228
EmFor@0 2229 -----------------------------------------------------------------------------------
EmFor@0 2230 --
EmFor@0 2231 -- Take final tally
EmFor@0 2232 --
EmFor@0 2233 -----------------------------------------------------------------------------------
EmFor@0 2234 function CensusPlus_DoTimeCounts()
EmFor@0 2235
EmFor@0 2236 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 2237 return;
EmFor@0 2238 end
EmFor@0 2239
EmFor@0 2240 -- Zero out the times
EmFor@0 2241 g_TimeDatabase[CENSUSPlus_DRUID] = 0;
EmFor@0 2242 g_TimeDatabase[CENSUSPlus_HUNTER] = 0;
EmFor@0 2243 g_TimeDatabase[CENSUSPlus_MAGE] = 0;
EmFor@0 2244 g_TimeDatabase[CENSUSPlus_PRIEST] = 0;
EmFor@0 2245 g_TimeDatabase[CENSUSPlus_ROGUE] = 0;
EmFor@0 2246 g_TimeDatabase[CENSUSPlus_WARLOCK] = 0;
EmFor@0 2247 g_TimeDatabase[CENSUSPlus_WARRIOR] = 0;
EmFor@0 2248 g_TimeDatabase[CENSUSPlus_SHAMAN] = 0;
EmFor@0 2249 g_TimeDatabase[CENSUSPlus_PALADIN] = 0;
EmFor@0 2250 g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] = 0;
EmFor@0 2251 g_TimeDatabase[CENSUSPlus_WarsongGulch] = 0;
EmFor@0 2252 g_TimeDatabase[CENSUSPlus_AlteracValley]= 0;
EmFor@0 2253 g_TimeDatabase[CENSUSPlus_ArathiBasin] = 0;
EmFor@0 2254
EmFor@0 2255 g_NumUpdatedCharacters = 0;
EmFor@0 2256
EmFor@0 2257 for charName, charClass in pairs(g_TempCount) do
EmFor@0 2258 if (CENSUSPlusFemale[charClass] ~= nil) then
EmFor@0 2259 charClass = CENSUSPlusFemale[charClass];
EmFor@0 2260 end
EmFor@0 2261 g_TimeDatabase[charClass] = g_TimeDatabase[charClass] + 1;
EmFor@0 2262 g_NumUpdatedCharacters = g_NumUpdatedCharacters + 1;
EmFor@0 2263 end
EmFor@0 2264
EmFor@0 2265 -- Collect some zone info
EmFor@0 2266 for charName, charZone in pairs(g_TempZoneCount) do
EmFor@0 2267 if( charZone == CENSUSPlus_WarsongGulch or charZone == CENSUSPlus_AlteracValley or charZone == CENSUSPlus_ArathiBasin ) then
EmFor@0 2268 g_TimeDatabase[charZone] = g_TimeDatabase[charZone] + 1;
EmFor@0 2269 end
EmFor@0 2270 end
EmFor@0 2271
EmFor@0 2272
EmFor@0 2273 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 2274 if( CensusPlus_Database["TimesPlus"][realmName] == nil ) then
EmFor@0 2275 CensusPlus_Database["TimesPlus"][realmName]= {};
EmFor@0 2276 end
EmFor@0 2277
EmFor@0 2278 if( CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")] == nil ) then
EmFor@0 2279 CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")] = {};
EmFor@0 2280 end
EmFor@0 2281
EmFor@0 2282 local hour, minute = GetGameTime();
EmFor@0 2283 -- CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")]["" .. hour .. ""] = g_TimeDatabase;
EmFor@0 2284 CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")][CensusPlus_DetermineServerDate() .. "&" .. hour .. ":" .. minute .. ":00"] =
EmFor@0 2285 g_TimeDatabase[CENSUSPlus_DRUID] .. "&" ..
EmFor@0 2286 g_TimeDatabase[CENSUSPlus_HUNTER] .. "&" ..
EmFor@0 2287 g_TimeDatabase[CENSUSPlus_MAGE] .. "&" ..
EmFor@0 2288 g_TimeDatabase[CENSUSPlus_PRIEST] .. "&" ..
EmFor@0 2289 g_TimeDatabase[CENSUSPlus_ROGUE] .. "&" ..
EmFor@0 2290 g_TimeDatabase[CENSUSPlus_WARLOCK] .. "&" ..
EmFor@0 2291 g_TimeDatabase[CENSUSPlus_WARRIOR] .. "&" ..
EmFor@0 2292 g_TimeDatabase[CENSUSPlus_SHAMAN] .. "&" ..
EmFor@0 2293 g_TimeDatabase[CENSUSPlus_PALADIN] .. "&" ..
EmFor@0 2294 g_TimeDatabase[CENSUSPlus_DEATHKNIGHT] .. "&" ..
EmFor@0 2295 g_TimeDatabase[CENSUSPlus_WarsongGulch] .. "&" ..
EmFor@0 2296 g_TimeDatabase[CENSUSPlus_AlteracValley] .. "&" ..
EmFor@0 2297 g_TimeDatabase[CENSUSPlus_ArathiBasin];
EmFor@0 2298 end
EmFor@0 2299
EmFor@0 2300 -----------------------------------------------------------------------------------
EmFor@0 2301 --
EmFor@0 2302 -- Add the contents of the guild results to the database
EmFor@0 2303 --
EmFor@0 2304 -----------------------------------------------------------------------------------
EmFor@0 2305 function CensusPlus_ProcessGuildResults()
EmFor@0 2306
EmFor@0 2307 if( g_VariablesLoaded == false ) then
EmFor@0 2308 return;
EmFor@0 2309 end
EmFor@0 2310
EmFor@0 2311 if( CensusPlus_Database["Info"]["Locale"] == nil ) then
EmFor@0 2312 return;
EmFor@0 2313 end
EmFor@0 2314
EmFor@0 2315 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 2316 return;
EmFor@0 2317 end
EmFor@0 2318
EmFor@0 2319
EmFor@0 2320 --
EmFor@0 2321 -- Grab temp var
EmFor@0 2322 --
EmFor@0 2323 local showOfflineTemp = GetGuildRosterShowOffline();
EmFor@0 2324 SetGuildRosterShowOffline(1);
EmFor@0 2325
EmFor@0 2326
EmFor@0 2327 --
EmFor@0 2328 -- Walk through the guild info
EmFor@0 2329 --
EmFor@0 2330 local numGuildMembers = GetNumGuildMembers();
EmFor@0 2331 -- CensusPlus_Msg("Processing "..numGuildMembers.." guild members.");
EmFor@0 2332
EmFor@0 2333 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 2334 CensusPlus_Database["Guilds"] = nil;
EmFor@0 2335 if( CensusPlus_Database["Guilds"] == nil ) then
EmFor@0 2336 CensusPlus_Database["Guilds"] = {};
EmFor@0 2337 end
EmFor@0 2338
EmFor@0 2339 if (CensusPlus_Database["Guilds"][realmName] == nil) then
EmFor@0 2340 CensusPlus_Database["Guilds"][realmName] = {};
EmFor@0 2341 end
EmFor@0 2342
EmFor@0 2343 local guildRealmDatabase = CensusPlus_Database["Guilds"][realmName];
EmFor@0 2344 if (guildRealmDatabase == nil) then
EmFor@0 2345 CensusPlus_Database["Guilds"][realmName] = {};
EmFor@0 2346 guildRealmDatabase = CensusPlus_Database["Guilds"][realmName];
EmFor@0 2347 end
EmFor@0 2348
EmFor@0 2349 local factionGroup = UnitFactionGroup("player");
EmFor@0 2350 if( factionGroup == nil ) then
EmFor@0 2351 CensusPlus_Database["Guilds"] = nil;
EmFor@0 2352 SetGuildRosterShowOffline(showOfflineTemp);
EmFor@0 2353 return;
EmFor@0 2354 end
EmFor@0 2355
EmFor@0 2356 local factionDatabase = guildRealmDatabase[factionGroup];
EmFor@0 2357 if (factionDatabase == nil) then
EmFor@0 2358 guildRealmDatabase[factionGroup] = {};
EmFor@0 2359 factionDatabase = guildRealmDatabase[factionGroup];
EmFor@0 2360 end
EmFor@0 2361
EmFor@0 2362 CensusPlus_Database["Guilds"][realmName][factionGroup] = nil;
EmFor@0 2363 CensusPlus_Database["Guilds"][realmName][factionGroup] = {};
EmFor@0 2364
EmFor@0 2365 factionDatabase = CensusPlus_Database["Guilds"][realmName][factionGroup];
EmFor@0 2366
EmFor@0 2367 local Ginfo = GetGuildInfo("player");
EmFor@0 2368 if( Ginfo == nil ) then
EmFor@0 2369 CensusPlus_Database["Guilds"] = nil;
EmFor@0 2370 SetGuildRosterShowOffline(showOfflineTemp);
EmFor@0 2371 return;
EmFor@0 2372 end
EmFor@0 2373 local guildDatabase = factionDatabase[Ginfo];
EmFor@0 2374 if (guildDatabase == nil) then
EmFor@0 2375 factionDatabase[Ginfo] = {};
EmFor@0 2376 guildDatabase = factionDatabase[Ginfo];
EmFor@0 2377 end
EmFor@0 2378
EmFor@0 2379 local info = guildDatabase["GuildInfo"];
EmFor@0 2380 if (info == nil) then
EmFor@0 2381 guildDatabase["GuildInfo"] = {};
EmFor@0 2382 info = guildDatabase["GuildInfo"];
EmFor@0 2383 end
EmFor@0 2384
EmFor@0 2385 info["Update"] = date( "%m-%d-%Y", time()) .. "";
EmFor@0 2386 info["ShowOnline"] = 1; -- Variable comes from FriendsFrame
EmFor@0 2387
EmFor@0 2388 guildDatabase["Members"] = nil;
EmFor@0 2389 guildDatabase["Members"] = {};
EmFor@0 2390
EmFor@0 2391 local members = guildDatabase["Members"];
EmFor@0 2392
EmFor@0 2393 for index = 1, numGuildMembers, 1 do
EmFor@0 2394 local name, rank, rankIndex, level, class, zone, note, officernote, online, status = GetGuildRosterInfo(index);
EmFor@0 2395
EmFor@0 2396 if( members[name] == nil ) then
EmFor@0 2397 members[name] = {};
EmFor@0 2398 end
EmFor@0 2399
EmFor@0 2400 -- CensusPlus_Msg( "Name =>" .. name );
EmFor@0 2401 -- CensusPlus_Msg( "rank =>" .. rank );
EmFor@0 2402 -- CensusPlus_Msg( "rankIndex =>" .. rankIndex );
EmFor@0 2403 -- CensusPlus_Msg( "level =>" .. level );
EmFor@0 2404 -- CensusPlus_Msg( "class =>" .. class );
EmFor@0 2405 members[name]["Rank"] = rank;
EmFor@0 2406 members[name]["RankIndex"] = rankIndex;
EmFor@0 2407 members[name]["Level"]= level;
EmFor@0 2408 members[name]["Class"]= class;
EmFor@0 2409 -- members[name]["Zone"]= zone;
EmFor@0 2410 -- members[name]["Note"]= CensusPlus_SafeSet( note );
EmFor@0 2411 -- members[name]["OfficerNote"]= CensusPlus_SafeSet( officernote );
EmFor@0 2412 -- members[name]["Online"]= online;
EmFor@0 2413 -- members[name]["Status"]= CensusPlus_SafeSet( status );
EmFor@0 2414 end
EmFor@0 2415
EmFor@0 2416 SetGuildRosterShowOffline(showOfflineTemp);
EmFor@0 2417 end
EmFor@0 2418
EmFor@0 2419 function CensusPlus_SafeCheck( param )
EmFor@0 2420 if( param == nil ) then
EmFor@0 2421 return "nil";
EmFor@0 2422 else
EmFor@0 2423 return param;
EmFor@0 2424 end
EmFor@0 2425 end
EmFor@0 2426
EmFor@0 2427 -----------------------------------------------------------------------------------
EmFor@0 2428 --
EmFor@0 2429 -- Add the contents of the who results to the database
EmFor@0 2430 --
EmFor@0 2431 -----------------------------------------------------------------------------------
EmFor@0 2432 function CensusPlus_ProcessWhoResults()
EmFor@0 2433
EmFor@0 2434 --
EmFor@0 2435 -- If we are in a BG then stop a census
EmFor@0 2436 --
EmFor@0 2437 if( g_CurrentlyInBG and g_IsCensusPlusInProgress ) then
EmFor@0 2438 g_LastCensusRun = time()-600;
EmFor@0 2439 CensusPlus_Msg(CENSUSPlus_ISINBG);
EmFor@0 2440 CensusPlus_StopCensus( );
EmFor@0 2441 end
EmFor@0 2442
EmFor@0 2443 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 2444 return;
EmFor@0 2445 end
EmFor@0 2446
EmFor@0 2447 --
EmFor@0 2448 -- Get the portion of the database for this server
EmFor@0 2449 --
EmFor@0 2450 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 2451 local realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 2452 if (realmDatabase == nil) then
EmFor@0 2453 CensusPlus_Database["Servers"][realmName] = {};
EmFor@0 2454 realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 2455 end
EmFor@0 2456
EmFor@0 2457 --
EmFor@0 2458 -- Get the portion of the database for this faction
EmFor@0 2459 --
EmFor@0 2460 local factionGroup = UnitFactionGroup("player");
EmFor@0 2461 if( factionGroup == nil ) then
EmFor@0 2462 return
EmFor@0 2463 end
EmFor@0 2464
EmFor@0 2465 local factionDatabase = realmDatabase[factionGroup];
EmFor@0 2466 if (factionDatabase == nil) then
EmFor@0 2467 realmDatabase[factionGroup] = {};
EmFor@0 2468 factionDatabase = realmDatabase[factionGroup];
EmFor@0 2469 end
EmFor@0 2470
EmFor@0 2471 --
EmFor@0 2472 -- Walk through all the who results
EmFor@0 2473 --
EmFor@0 2474 local numWhoResults = GetNumWhoResults();
EmFor@0 2475 if( CensusPlus_PerCharInfo["Verbose"] == true ) then
EmFor@0 2476 CensusPlus_Msg(format(CENSUSPlus_PROCESSING, numWhoResults));
EmFor@0 2477 end
EmFor@0 2478 for i = 1, numWhoResults, 1 do
EmFor@0 2479 --
EmFor@0 2480 -- Get who result entry
EmFor@0 2481 --
EmFor@0 2482 local name, guild, level, race, class, zone, group = GetWhoInfo(i);
EmFor@0 2483
EmFor@0 2484 if (CENSUSPlusFemale[race] ~= nil) then
EmFor@0 2485 race = CENSUSPlusFemale[race];
EmFor@0 2486 end
EmFor@0 2487
EmFor@0 2488 if (CENSUSPlusFemale[class] ~= nil) then
EmFor@0 2489 class = CENSUSPlusFemale[class];
EmFor@0 2490 end
EmFor@0 2491
EmFor@0 2492 --
EmFor@0 2493 -- Test the name for possible color coding
EmFor@0 2494 --
EmFor@0 2495 -- for example |cffff0000Rollie|r
EmFor@0 2496 local karma_check = string.find( name, "|cff" );
EmFor@0 2497 if( karma_check ~= nil ) then
EmFor@0 2498 name = string.sub( name, 11, -3 );
EmFor@0 2499 end
EmFor@0 2500
EmFor@0 2501 --
EmFor@0 2502 -- Further check for problematic chars
EmFor@0 2503 --
EmFor@0 2504 local pattern = "[0-9\| -]";
EmFor@0 2505 if( string.find( name, pattern ) ~= nil ) then
EmFor@0 2506 if( not g_ProblematicMessageShown ) then
EmFor@0 2507 CensusPlus_Msg( "This name is problematic => " .. name .. ", name skipped. This message will only be shown once." );
EmFor@0 2508 g_ProblematicMessageShown = true;
EmFor@0 2509 end
EmFor@0 2510 return;
EmFor@0 2511 end
EmFor@0 2512
EmFor@0 2513
EmFor@0 2514 --
EmFor@0 2515 -- Get racial database
EmFor@0 2516 --
EmFor@0 2517 local raceDatabase = factionDatabase[race];
EmFor@0 2518 if (raceDatabase == nil) then
EmFor@0 2519 factionDatabase[race] = {};
EmFor@0 2520 raceDatabase = factionDatabase[race];
EmFor@0 2521 end
EmFor@0 2522
EmFor@0 2523 --
EmFor@0 2524 -- Get class database
EmFor@0 2525 --
EmFor@0 2526 local classDatabase = raceDatabase[class];
EmFor@0 2527 if (classDatabase == nil) then
EmFor@0 2528 raceDatabase[class] = {};
EmFor@0 2529 classDatabase = raceDatabase[class];
EmFor@0 2530 end
EmFor@0 2531
EmFor@0 2532 --
EmFor@0 2533 -- Get this player's entry
EmFor@0 2534 --
EmFor@0 2535 local entry = classDatabase[name];
EmFor@0 2536 if (entry == nil) then
EmFor@0 2537 classDatabase[name] = {};
EmFor@0 2538 entry = classDatabase[name];
EmFor@0 2539 g_NumNewCharacters = g_NumNewCharacters + 1;
EmFor@0 2540 end
EmFor@0 2541
EmFor@0 2542 --
EmFor@0 2543 -- Update the information
EmFor@0 2544 --
EmFor@0 2545 entry[1] = level;
EmFor@0 2546 entry[2] = guild;
EmFor@0 2547 -- local hour, minute = GetGameTime();
EmFor@0 2548 entry[3] = CensusPlus_DetermineServerDate() .. "";
EmFor@0 2549
EmFor@0 2550 g_TempCount[name] = class;
EmFor@0 2551 g_TempZoneCount[name] = zone;
EmFor@0 2552
EmFor@0 2553 end
EmFor@0 2554 -- CensusPlus_UpdateView();
EmFor@0 2555 end
EmFor@0 2556
EmFor@0 2557
EmFor@0 2558 ----------------------------------------------------------------------------------
EmFor@0 2559 --
EmFor@0 2560 -- Process a single entry
EmFor@0 2561 --
EmFor@0 2562 ---------------------------------------------------------------------------------
EmFor@0 2563 function WR_ProcessSingleEntry( name, level, race, class, guild, zone )
EmFor@0 2564
EmFor@0 2565 CensusPlus_Msg2( "Processing " .. name );
EmFor@0 2566
EmFor@0 2567 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 2568 return;
EmFor@0 2569 end
EmFor@0 2570
EmFor@0 2571 if (CENSUSPlusFemale[race] ~= nil) then
EmFor@0 2572 race = CENSUSPlusFemale[race];
EmFor@0 2573 end
EmFor@0 2574
EmFor@0 2575 if (CENSUSPlusFemale[class] ~= nil) then
EmFor@0 2576 class = CENSUSPlusFemale[class];
EmFor@0 2577 end
EmFor@0 2578
EmFor@0 2579 --
EmFor@0 2580 -- Get the portion of the database for this server
EmFor@0 2581 --
EmFor@0 2582 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 2583 local realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 2584 if (realmDatabase == nil) then
EmFor@0 2585 CensusPlus_Database["Servers"][realmName] = {};
EmFor@0 2586 realmDatabase = CensusPlus_Database["Servers"][realmName];
EmFor@0 2587 end
EmFor@0 2588
EmFor@0 2589 --
EmFor@0 2590 -- Get the portion of the database for this faction
EmFor@0 2591 --
EmFor@0 2592 local factionGroup = UnitFactionGroup("player");
EmFor@0 2593 if( factionGroup == nil ) then
EmFor@0 2594 return
EmFor@0 2595 end
EmFor@0 2596
EmFor@0 2597 local factionDatabase = realmDatabase[factionGroup];
EmFor@0 2598 if (factionDatabase == nil) then
EmFor@0 2599 realmDatabase[factionGroup] = {};
EmFor@0 2600 factionDatabase = realmDatabase[factionGroup];
EmFor@0 2601 end
EmFor@0 2602
EmFor@0 2603 --
EmFor@0 2604 -- Remove the trailing ] that I can't remove through patterns
EmFor@0 2605 --
EmFor@0 2606 -- local oldname = name;
EmFor@0 2607 -- name = string.sub( oldname, 1, string.len(oldname) - 3 );
EmFor@0 2608
EmFor@0 2609 level = tonumber( level );
EmFor@0 2610
EmFor@0 2611 --
EmFor@0 2612 -- Test the name for possible color coding
EmFor@0 2613 --
EmFor@0 2614 -- for example |cffff0000Rollie|r
EmFor@0 2615 local karma_check = string.find( name, "|cff" );
EmFor@0 2616 if( karma_check ~= nil ) then
EmFor@0 2617 name = string.sub( name, 11, -3 );
EmFor@0 2618 end
EmFor@0 2619
EmFor@0 2620 local pattern = "[0-9\| :]";
EmFor@0 2621 if( string.find( name, pattern ) ~= nil ) then
EmFor@0 2622 if( not g_ProblematicMessageShown ) then
EmFor@0 2623 CensusPlus_Msg( "This name is problematic => " .. name .. ", name skipped. This message will only be shown once." );
EmFor@0 2624 end
EmFor@0 2625 return;
EmFor@0 2626 end
EmFor@0 2627
EmFor@0 2628 --
EmFor@0 2629 -- Do a race check just to be sure this is working
EmFor@0 2630 --
EmFor@0 2631 if( g_FactionCheck[race] == nil ) then
EmFor@0 2632 CensusPlus_Msg( "Found an unknown race (" .. race .. "), please tell Rollie at WarcraftRealms.com" );
EmFor@0 2633 return;
EmFor@0 2634 end
EmFor@0 2635
EmFor@0 2636 --
EmFor@0 2637 -- Get racial database
EmFor@0 2638 --
EmFor@0 2639 local raceDatabase = factionDatabase[race];
EmFor@0 2640 if (raceDatabase == nil) then
EmFor@0 2641 factionDatabase[race] = {};
EmFor@0 2642 raceDatabase = factionDatabase[race];
EmFor@0 2643 end
EmFor@0 2644
EmFor@0 2645 --
EmFor@0 2646 -- Get class database
EmFor@0 2647 --
EmFor@0 2648 local classDatabase = raceDatabase[class];
EmFor@0 2649 if (classDatabase == nil) then
EmFor@0 2650 raceDatabase[class] = {};
EmFor@0 2651 classDatabase = raceDatabase[class];
EmFor@0 2652 end
EmFor@0 2653
EmFor@0 2654 --
EmFor@0 2655 -- Get this player's entry
EmFor@0 2656 --
EmFor@0 2657 local entry = classDatabase[name];
EmFor@0 2658 if (entry == nil) then
EmFor@0 2659 classDatabase[name] = {};
EmFor@0 2660 entry = classDatabase[name];
EmFor@0 2661 g_NumNewCharacters = g_NumNewCharacters + 1;
EmFor@0 2662 end
EmFor@0 2663
EmFor@0 2664 --
EmFor@0 2665 -- Update the information
EmFor@0 2666 --
EmFor@0 2667 entry[1] = level;
EmFor@0 2668 entry[2] = guild;
EmFor@0 2669 -- local hour, minute = GetGameTime();
EmFor@0 2670 entry[3] = CensusPlus_DetermineServerDate() .. "";
EmFor@0 2671
EmFor@0 2672 g_TempCount[name] = class;
EmFor@0 2673 g_TempZoneCount[name] = zone;
EmFor@0 2674
EmFor@0 2675 -- CensusPlus_Msg2( "Processed " .. name );
EmFor@0 2676 end
EmFor@0 2677
EmFor@0 2678 ----------------------------------------------------------------------------------
EmFor@0 2679 --
EmFor@0 2680 -- Find a guild in the CensusPlus_Guilds array by name
EmFor@0 2681 --
EmFor@0 2682 ---------------------------------------------------------------------------------
EmFor@0 2683 local function FindGuildByName(name)
EmFor@0 2684 local i;
EmFor@0 2685 local size = table.getn(CensusPlus_Guilds);
EmFor@0 2686 for i = 1, size, 1 do
EmFor@0 2687 local entry = CensusPlus_Guilds[i];
EmFor@0 2688 if (entry.m_Name == name) then
EmFor@0 2689 return i;
EmFor@0 2690 end
EmFor@0 2691 end
EmFor@0 2692 return nil;
EmFor@0 2693 end
EmFor@0 2694
EmFor@0 2695 ----------------------------------------------------------------------------------
EmFor@0 2696 --
EmFor@0 2697 -- Add up the total character XP and count
EmFor@0 2698 --
EmFor@0 2699 ---------------------------------------------------------------------------------
EmFor@0 2700 local g_AccumulateGuildTotals = true;
EmFor@0 2701 local function TotalsAccumulator(name, level, guild)
EmFor@0 2702 --
EmFor@0 2703 -- Add character to our player list
EmFor@0 2704 --
EmFor@0 2705 CensusPlus_AddPlayerToList( name, level, guild );
EmFor@0 2706
EmFor@0 2707 if( g_TotalCharacterXPPerLevel[level] ) then
EmFor@0 2708 InitConstantTables();
EmFor@0 2709 end
EmFor@0 2710
EmFor@0 2711 local totalCharacterXP = g_TotalCharacterXPPerLevel[level];
EmFor@0 2712 if( totalCharacterXP == nil ) then
EmFor@0 2713 totalCharacterXP = 0;
EmFor@0 2714 end
EmFor@0 2715 if( g_TotalCharacterXP == nil ) then
EmFor@0 2716 g_TotalCharacterXP = 0;
EmFor@0 2717 end
EmFor@0 2718 g_TotalCharacterXP = g_TotalCharacterXP + totalCharacterXP;
EmFor@0 2719 g_TotalCount = g_TotalCount + 1;
EmFor@0 2720 if (g_AccumulateGuildTotals and (guild ~= nil)) then
EmFor@0 2721 local index = FindGuildByName(guild);
EmFor@0 2722 if (index == nil) then
EmFor@0 2723 local size = table.getn(CensusPlus_Guilds);
EmFor@0 2724 index = size + 1;
EmFor@0 2725 CensusPlus_Guilds[index] = {m_Name = guild, m_TotalCharacterXP = 0, m_Count = 0};
EmFor@0 2726 end
EmFor@0 2727 local entry = CensusPlus_Guilds[index];
EmFor@0 2728 entry.m_TotalCharacterXP = entry.m_TotalCharacterXP + totalCharacterXP;
EmFor@0 2729 entry.m_Count = entry.m_Count + 1;
EmFor@0 2730 end
EmFor@0 2731 end
EmFor@0 2732
EmFor@0 2733 ----------------------------------------------------------------------------------
EmFor@0 2734 --
EmFor@0 2735 -- Predicate function which can be used to compare two guilds for sorting
EmFor@0 2736 --
EmFor@0 2737 ---------------------------------------------------------------------------------
EmFor@0 2738 local function GuildPredicate(lhs, rhs)
EmFor@0 2739 --
EmFor@0 2740 -- nil references are always less than
EmFor@0 2741 --
EmFor@0 2742 if (lhs == nil) then
EmFor@0 2743 if (rhs == nil) then
EmFor@0 2744 return false;
EmFor@0 2745 else
EmFor@0 2746 return true;
EmFor@0 2747 end
EmFor@0 2748 elseif (rhs == nil) then
EmFor@0 2749 return false;
EmFor@0 2750 end
EmFor@0 2751 --
EmFor@0 2752 -- Sort by total XP first
EmFor@0 2753 --
EmFor@0 2754 if (rhs.m_TotalCharacterXP < lhs.m_TotalCharacterXP) then
EmFor@0 2755 return true;
EmFor@0 2756 elseif (lhs.m_TotalCharacterXP < rhs.m_TotalCharacterXP) then
EmFor@0 2757 return false;
EmFor@0 2758 end
EmFor@0 2759 --
EmFor@0 2760 -- Sort by name
EmFor@0 2761 --
EmFor@0 2762 if (lhs.m_Name < rhs.m_Name) then
EmFor@0 2763 return true;
EmFor@0 2764 elseif (rhs.m_Name < lhs.m_Name) then
EmFor@0 2765 return false;
EmFor@0 2766 end
EmFor@0 2767
EmFor@0 2768 --
EmFor@0 2769 -- identical
EmFor@0 2770 --
EmFor@0 2771 return false;
EmFor@0 2772 end
EmFor@0 2773
EmFor@0 2774
EmFor@0 2775 ----------------------------------------------------------------------------------
EmFor@0 2776 --
EmFor@0 2777 -- Another accumulator for adding up XP and counts
EmFor@0 2778 --
EmFor@0 2779 ---------------------------------------------------------------------------------
EmFor@0 2780 local g_AccumulatorCount = 0;
EmFor@0 2781 local g_AccumulatorXPTotal = 0;
EmFor@0 2782 local function CensusPlus_Accumulator(name, level, guild)
EmFor@0 2783 if( g_TotalCharacterXPPerLevel[level] == nil ) then
EmFor@0 2784 InitConstantTables();
EmFor@0 2785 end
EmFor@0 2786 local totalCharacterXP = g_TotalCharacterXPPerLevel[level];
EmFor@0 2787 if( totalCharacterXP == nil or g_TotalCharacterXPPerLevel[level] == nil ) then
EmFor@0 2788 return;
EmFor@0 2789 end
EmFor@0 2790 g_AccumulatorXPTotal = g_AccumulatorXPTotal + totalCharacterXP;
EmFor@0 2791 g_AccumulatorCount = g_AccumulatorCount + 1;
EmFor@0 2792 end
EmFor@0 2793
EmFor@0 2794 ----------------------------------------------------------------------------------
EmFor@0 2795 --
EmFor@0 2796 -- Reset the above accumulator
EmFor@0 2797 --
EmFor@0 2798 ---------------------------------------------------------------------------------
EmFor@0 2799 function CensusPlus_ResetAccumulator()
EmFor@0 2800 g_AccumulatorCount = 0;
EmFor@0 2801 g_AccumulatorXPTotal = 0;
EmFor@0 2802 end
EmFor@0 2803
EmFor@0 2804
EmFor@0 2805 ----------------------------------------------------------------------------------
EmFor@0 2806 --
EmFor@0 2807 -- Search the character database using the search criteria and update display
EmFor@0 2808 --
EmFor@0 2809 ---------------------------------------------------------------------------------
EmFor@0 2810 function CensusPlus_UpdateView()
EmFor@0 2811
EmFor@0 2812 --
EmFor@0 2813 -- No need to do anything if the window is not open
EmFor@0 2814 --
EmFor@0 2815 if( not CensusPlus:IsVisible() ) then
EmFor@0 2816 return;
EmFor@0 2817 end
EmFor@0 2818
EmFor@0 2819 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 2820 return;
EmFor@0 2821 end
EmFor@0 2822
EmFor@0 2823 --
EmFor@0 2824 -- Get realm and faction
EmFor@0 2825 --
EmFor@0 2826 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 2827 if( realmName == nil ) then
EmFor@0 2828 return;
EmFor@0 2829 end
EmFor@0 2830 CensusPlusRealmName:SetText(format(CENSUSPlus_REALMNAME, realmName));
EmFor@0 2831
EmFor@0 2832 local factionGroup = UnitFactionGroup("player");
EmFor@0 2833 if( factionGroup == nil ) then
EmFor@0 2834 return;
EmFor@0 2835 end
EmFor@0 2836
EmFor@0 2837 CensusPlusFactionName:SetText(format(CENSUSPlus_FACTION, factionGroup));
EmFor@0 2838
EmFor@0 2839 if( CensusPlus_Database["Info"]["Locale"] ~= nil ) then
EmFor@0 2840 CensusPlusLocaleName:SetText(format(CENSUSPlus_LOCALE, CensusPlus_Database["Info"]["Locale"]));
EmFor@0 2841 end
EmFor@0 2842
EmFor@0 2843 local guildKey = nil;
EmFor@0 2844 local raceKey = nil;
EmFor@0 2845 local classKey = nil;
EmFor@0 2846 local levelKey = nil;
EmFor@0 2847 g_TotalCharacterXP = 0;
EmFor@0 2848 g_TotalCount = 0;
EmFor@0 2849
EmFor@0 2850 --
EmFor@0 2851 -- Has the user selected a guild?
EmFor@0 2852 --
EmFor@0 2853 if (g_GuildSelected ~= nil ) then
EmFor@0 2854 guildKey = g_GuildSelected;
EmFor@0 2855 end
EmFor@0 2856 if (g_RaceSelected > 0) then
EmFor@0 2857 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
EmFor@0 2858 raceKey = thisFactionRaces[g_RaceSelected];
EmFor@0 2859 end
EmFor@0 2860 if (g_ClassSelected > 0) then
EmFor@0 2861 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup);
EmFor@0 2862 classKey = thisFactionClasses[g_ClassSelected];
EmFor@0 2863 end
EmFor@0 2864 if (g_LevelSelected > 0 or g_LevelSelected < 0) then
EmFor@0 2865 levelKey = g_LevelSelected;
EmFor@0 2866 end
EmFor@0 2867
EmFor@0 2868 debugprofilestart();
EmFor@0 2869
EmFor@0 2870 --
EmFor@0 2871 -- Has the user added any search criteria?
EmFor@0 2872 --
EmFor@0 2873 if ((guildKey ~= nil) or (raceKey ~= nil) or (classKey ~= nil) or (levelKey ~= nil)) then
EmFor@0 2874 --
EmFor@0 2875 -- Get totals for this criteria
EmFor@0 2876 --
EmFor@0 2877 CensusPlus_Guilds = {};
EmFor@0 2878 g_AccumulateGuildTotals = true;
EmFor@0 2879 CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, classKey, guildKey, levelKey, TotalsAccumulator);
EmFor@0 2880
EmFor@0 2881 if( CensusPlus_EnableProfiling ) then
EmFor@0 2882 CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 );
EmFor@0 2883 debugprofilestart();
EmFor@0 2884 end
EmFor@0 2885
EmFor@0 2886 else
EmFor@0 2887 --
EmFor@0 2888 -- Get the overall totals and find guild information
EmFor@0 2889 --
EmFor@0 2890 CensusPlus_Guilds = {};
EmFor@0 2891 g_AccumulateGuildTotals = true;
EmFor@0 2892 CensusPlus_ForAllCharacters(realmName, factionGroup, nil, nil, nil, nil, TotalsAccumulator);
EmFor@0 2893
EmFor@0 2894 if( CensusPlus_EnableProfiling ) then
EmFor@0 2895 CensusPlus_Msg( "PROFILE: Time to do calcs 1 " .. debugprofilestop() / 1000000000 );
EmFor@0 2896 debugprofilestart();
EmFor@0 2897 end
EmFor@0 2898
EmFor@0 2899 local size = table.getn(CensusPlus_Guilds);
EmFor@0 2900 if (size) then
EmFor@0 2901 table.sort(CensusPlus_Guilds, GuildPredicate);
EmFor@0 2902 end
EmFor@0 2903
EmFor@0 2904 if( CensusPlus_EnableProfiling ) then
EmFor@0 2905 CensusPlus_Msg( "PROFILE: Time to sort guilds " .. debugprofilestop() / 1000000000 );
EmFor@0 2906 debugprofilestart();
EmFor@0 2907 end
EmFor@0 2908 end
EmFor@0 2909
EmFor@0 2910 local levelSearch = nil;
EmFor@0 2911 if (levelKey ~= nil) then
EmFor@0 2912 levelSearch = " ("..CENSUSPlus_LEVEL..": ";
EmFor@0 2913 local level = levelKey;
EmFor@0 2914 if (levelKey < 0) then
EmFor@0 2915 levelSearch = levelSearch.."!";
EmFor@0 2916 level = 0 - levelKey;
EmFor@0 2917 end
EmFor@0 2918 levelSearch = levelSearch..level..")";
EmFor@0 2919 end
EmFor@0 2920
EmFor@0 2921 local totalCharactersText = nil;
EmFor@0 2922 if (levelSearch ~= nil) then
EmFor@0 2923 totalCharactersText = format(CENSUSPlus_TOTALCHAR, g_TotalCount)..levelSearch;
EmFor@0 2924 else
EmFor@0 2925 totalCharactersText = format(CENSUSPlus_TOTALCHAR, g_TotalCount);
EmFor@0 2926 end
EmFor@0 2927 CensusPlusTotalCharacters:SetText(totalCharactersText);
EmFor@0 2928 CensusPlusTotalCharacterXP:SetText(format(CENSUSPlus_TOTALCHARXP, g_TotalCharacterXP));
EmFor@0 2929 CensusPlus_UpdateGuildButtons();
EmFor@0 2930
EmFor@0 2931 if( CensusPlus_EnableProfiling ) then
EmFor@0 2932 CensusPlus_Msg( "PROFILE: Update Guilds " .. debugprofilestop() / 1000000000 );
EmFor@0 2933 debugprofilestart();
EmFor@0 2934 end
EmFor@0 2935
EmFor@0 2936 --
EmFor@0 2937 -- Accumulate totals for each race
EmFor@0 2938 --
EmFor@0 2939 local maxCount = 0;
EmFor@0 2940 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
EmFor@0 2941 local numRaces = table.getn(thisFactionRaces);
EmFor@0 2942 for i = 1, numRaces, 1 do
EmFor@0 2943 local race = thisFactionRaces[i];
EmFor@0 2944 CensusPlus_ResetAccumulator();
EmFor@0 2945 if ((raceKey == nil) or (raceKey == race)) then
EmFor@0 2946 CensusPlus_ForAllCharacters(realmName, factionGroup, race, classKey, guildKey, levelKey, CensusPlus_Accumulator);
EmFor@0 2947 end
EmFor@0 2948 if (g_AccumulatorCount > maxCount) then
EmFor@0 2949 maxCount = g_AccumulatorCount;
EmFor@0 2950 end
EmFor@0 2951 g_RaceCount[i] = g_AccumulatorCount;
EmFor@0 2952 end
EmFor@0 2953
EmFor@0 2954 --
EmFor@0 2955 -- Update race bars
EmFor@0 2956 --
EmFor@0 2957 for i = 1, numRaces, 1 do
EmFor@0 2958 local race = thisFactionRaces[i];
EmFor@0 2959 local buttonName = "CensusPlusRaceBar"..i;
EmFor@11 2960
EmFor@0 2961 local button = getglobal(buttonName);
EmFor@0 2962 local thisCount = g_RaceCount[i];
EmFor@0 2963 if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then
EmFor@0 2964 local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) );
EmFor@0 2965 if (height < 2 or height == nil ) then height = 2; end
EmFor@0 2966 button:SetHeight(height);
EmFor@0 2967 button:Show();
EmFor@0 2968 else
EmFor@0 2969 button:Hide();
EmFor@0 2970 end
EmFor@0 2971 local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[race];
EmFor@11 2972
EmFor@11 2973
EmFor@0 2974 local legendName = "CensusPlusRaceLegend"..i;
EmFor@0 2975 local legend = getglobal(legendName);
EmFor@0 2976 legend:SetNormalTexture(normalTextureName);
EmFor@0 2977 if (g_RaceSelected == i) then
EmFor@0 2978 legend:LockHighlight();
EmFor@0 2979 else
EmFor@0 2980 legend:UnlockHighlight();
EmFor@0 2981 end
EmFor@0 2982 end
EmFor@0 2983
EmFor@0 2984 if( CensusPlus_EnableProfiling ) then
EmFor@0 2985 CensusPlus_Msg( "PROFILE: Update Races " .. debugprofilestop() / 1000000000 );
EmFor@0 2986 debugprofilestart();
EmFor@0 2987 end
EmFor@0 2988
EmFor@0 2989 --
EmFor@0 2990 -- Accumulate totals for each class
EmFor@0 2991 --
EmFor@0 2992 local maxCount = 0;
EmFor@0 2993 local thisFactionClasss = CensusPlus_GetFactionClasses(factionGroup);
EmFor@0 2994 local numClasses = table.getn(thisFactionClasss);
EmFor@0 2995 for i = 1, numClasses, 1 do
EmFor@0 2996 local class = thisFactionClasss[i];
EmFor@0 2997 CensusPlus_ResetAccumulator();
EmFor@0 2998 if ((classKey == nil) or (classKey == class)) then
EmFor@0 2999 CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, class, guildKey, levelKey, CensusPlus_Accumulator);
EmFor@0 3000 end
EmFor@0 3001 if (g_AccumulatorCount > maxCount) then
EmFor@0 3002 maxCount = g_AccumulatorCount;
EmFor@0 3003 end
EmFor@0 3004 g_ClassCount[i] = g_AccumulatorCount;
EmFor@0 3005 end
EmFor@0 3006
EmFor@0 3007 --
EmFor@0 3008 -- Update class bars
EmFor@0 3009 --
EmFor@0 3010 for i = 1, numClasses, 1 do
EmFor@0 3011 local class = thisFactionClasss[i];
EmFor@0 3012
EmFor@0 3013 local buttonName = "CensusPlusClassBar"..i;
EmFor@0 3014 local button = getglobal(buttonName);
EmFor@0 3015 local thisCount = g_ClassCount[i];
EmFor@0 3016 if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then
EmFor@0 3017 local height = floor((thisCount * CensusPlus_MAXBARHEIGHT / maxCount) );
EmFor@0 3018 if (height < 2 or height == nil ) then height = 2; end
EmFor@0 3019 button:SetHeight(height);
EmFor@0 3020 button:Show();
EmFor@0 3021 else
EmFor@0 3022 button:Hide();
EmFor@0 3023 end
EmFor@0 3024
EmFor@0 3025 local normalTextureName="Interface\\AddOns\\CensusPlus\\Skin\\CensusPlus_"..g_RaceClassList[class];
EmFor@0 3026 local legendName = "CensusPlusClassLegend"..i;
EmFor@0 3027 local legend = getglobal(legendName);
EmFor@0 3028 legend:SetNormalTexture(normalTextureName);
EmFor@0 3029 if (g_ClassSelected == i) then
EmFor@0 3030 legend:LockHighlight();
EmFor@0 3031 else
EmFor@0 3032 legend:UnlockHighlight();
EmFor@0 3033 end
EmFor@0 3034 end
EmFor@0 3035
EmFor@0 3036 if( CensusPlus_EnableProfiling ) then
EmFor@0 3037 CensusPlus_Msg( "PROFILE: Update Classes " .. debugprofilestop() / 1000000000 );
EmFor@0 3038 debugprofilestart();
EmFor@0 3039 end
EmFor@0 3040
EmFor@0 3041 --
EmFor@0 3042 -- Accumulate totals for each level
EmFor@0 3043 --
EmFor@0 3044 local maxCount = 0;
EmFor@0 3045 for i = 1, MAX_CHARACTER_LEVEL, 1 do
EmFor@0 3046 if ((levelKey == nil) or (levelKey == i) or (levelKey < 0 and levelKey + i ~= 0)) then
EmFor@0 3047 CensusPlus_ResetAccumulator();
EmFor@0 3048 CensusPlus_ForAllCharacters(realmName, factionGroup, raceKey, classKey, guildKey, i, CensusPlus_Accumulator);
EmFor@0 3049 if (g_AccumulatorCount > maxCount) then
EmFor@0 3050 maxCount = g_AccumulatorCount;
EmFor@0 3051 end
EmFor@0 3052 g_LevelCount[i] = g_AccumulatorCount;
EmFor@0 3053 else
EmFor@0 3054 g_LevelCount[i] = 0;
EmFor@0 3055 end
EmFor@0 3056 end
EmFor@0 3057 local logMaxCount = math.log( maxCount / 3 + 1 );
EmFor@0 3058
EmFor@0 3059 --
EmFor@0 3060 -- To make the data easier to use, we need to massage it a bit for levels
EmFor@0 3061 --
EmFor@0 3062
EmFor@0 3063
EmFor@0 3064 --
EmFor@0 3065 -- Update level bars
EmFor@0 3066 --
EmFor@0 3067 for i = 1, MAX_CHARACTER_LEVEL, 1 do
EmFor@0 3068 local buttonName = "CensusPlusLevelBar"..i;
EmFor@0 3069 local buttonEmptyName = "CensusPlusLevelBarEmpty"..i;
EmFor@0 3070 local button = getglobal(buttonName);
EmFor@0 3071 local emptyButton = getglobal(buttonEmptyName);
EmFor@0 3072 local thisCount = g_LevelCount[i];
EmFor@0 3073 if ((thisCount ~= nil) and (thisCount > 0) and (maxCount > 0)) then
EmFor@0 3074 local height = floor(( math.log(thisCount / 3 + 1) * CensusPlus_MAXBARHEIGHT / logMaxCount) );
EmFor@0 3075 if( CensusPlus_Database["Info"]["UseLogBars"] == 0 ) then
EmFor@0 3076 height = floor(( CensusPlus_MAXBARHEIGHT * (thisCount) / maxCount) );
EmFor@0 3077 end
EmFor@0 3078
EmFor@0 3079 if (height < 2 or height == nil ) then height = 2; end
EmFor@0 3080 button:SetHeight(height);
EmFor@0 3081 button:Show();
EmFor@0 3082 if (emptyButton ~= nil) then
EmFor@0 3083 emptyButton:Hide();
EmFor@0 3084 end
EmFor@0 3085 else
EmFor@0 3086 button:Hide();
EmFor@0 3087 if (emptyButton ~= nil) then
EmFor@0 3088 emptyButton:SetHeight(CensusPlus_MAXBARHEIGHT);
EmFor@0 3089 emptyButton:Show();
EmFor@0 3090 end
EmFor@0 3091 end
EmFor@0 3092 end
EmFor@0 3093
EmFor@0 3094 if( CensusPlus_EnableProfiling ) then
EmFor@0 3095 CensusPlus_Msg( "PROFILE: Update Levels " .. debugprofilestop() / 1000000000 );
EmFor@0 3096 debugprofilestart();
EmFor@0 3097 end
EmFor@0 3098
EmFor@0 3099 if( CP_PlayerListWindow:IsVisible() ) then
EmFor@0 3100 CensusPlus_PlayerListOnShow();
EmFor@0 3101 end
EmFor@0 3102
EmFor@0 3103
EmFor@0 3104 debugprofilestop();
EmFor@0 3105
EmFor@0 3106 end
EmFor@0 3107
EmFor@0 3108 ----------------------------------------------------------------------------------
EmFor@0 3109 --
EmFor@0 3110 -- Walk the character database and call the callback function for every entry that matches the search criteria
EmFor@0 3111 --
EmFor@0 3112 ---------------------------------------------------------------------------------
EmFor@0 3113 function CensusPlus_ForAllCharacters(realmKey, factionKey, raceKey, classKey, guildKey, levelKey, callback)
EmFor@0 3114 for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do
EmFor@0 3115 if ((realmKey == nil) or (realmKey == realmName)) then
EmFor@0 3116 for factionName, factionDatabase in pairs(realmDatabase) do
EmFor@0 3117 if ((factionKey == nil) or (factionKey == factionName)) then
EmFor@0 3118 for raceName, raceDatabase in pairs(factionDatabase) do
EmFor@0 3119 if ((raceKey == nil) or (raceKey == raceName)) then
EmFor@0 3120 for className, classDatabase in pairs(raceDatabase) do
EmFor@0 3121 if ((classKey == nil) or (classKey == className)) then
EmFor@0 3122 for characterName, character in pairs(classDatabase) do
EmFor@0 3123 local characterGuild = character[2];
EmFor@0 3124 if ((guildKey == nil) or (guildKey == characterGuild)) then
EmFor@0 3125 local characterLevel = character[1];
EmFor@0 3126 if( characterLevel == nil ) then
EmFor@0 3127 characterLevel = 0;
EmFor@0 3128 end
EmFor@0 3129 if ((levelKey == nil) or (levelKey == characterLevel) or (levelKey < 0 and levelKey + characterLevel ~= 0)) then
EmFor@0 3130 callback(characterName, characterLevel, characterGuild, raceName, className, character[3] );
EmFor@0 3131 end
EmFor@0 3132 end
EmFor@0 3133 end
EmFor@0 3134 end
EmFor@0 3135 end
EmFor@0 3136 end
EmFor@0 3137 end
EmFor@0 3138 end
EmFor@0 3139 end
EmFor@0 3140 end
EmFor@0 3141 end
EmFor@0 3142 end
EmFor@0 3143
EmFor@0 3144 ----------------------------------------------------------------------------------
EmFor@0 3145 --
EmFor@0 3146 -- Race legend clicked
EmFor@0 3147 --
EmFor@0 3148 ---------------------------------------------------------------------------------
EmFor@6 3149 function CensusPlus_OnClickRace( this )
EmFor@0 3150 local id = this:GetID();
EmFor@0 3151 if (id == g_RaceSelected) then
EmFor@0 3152 g_RaceSelected = 0;
EmFor@0 3153 else
EmFor@0 3154 g_RaceSelected = id;
EmFor@0 3155 end
EmFor@0 3156 CensusPlus_UpdateView();
EmFor@0 3157 end
EmFor@0 3158
EmFor@0 3159 ----------------------------------------------------------------------------------
EmFor@0 3160 --
EmFor@0 3161 -- Class legend clicked
EmFor@0 3162 --
EmFor@0 3163 ---------------------------------------------------------------------------------
EmFor@6 3164 function CensusPlus_OnClickClass( this )
EmFor@0 3165 local id = this:GetID();
EmFor@0 3166 if (id == g_ClassSelected) then
EmFor@0 3167 g_ClassSelected = 0;
EmFor@0 3168 else
EmFor@0 3169 g_ClassSelected = id;
EmFor@0 3170 end
EmFor@0 3171 CensusPlus_UpdateView();
EmFor@0 3172 end
EmFor@0 3173
EmFor@0 3174
EmFor@0 3175 ----------------------------------------------------------------------------------
EmFor@0 3176 --
EmFor@0 3177 -- Level bar loaded
EmFor@0 3178 --
EmFor@0 3179 ---------------------------------------------------------------------------------
EmFor@6 3180 function CensusPlus_OnLoadLevel( self )
EmFor@6 3181 self:RegisterForClicks("LeftButtonUp","RightButtonUp");
EmFor@0 3182 end
EmFor@0 3183
EmFor@0 3184 ----------------------------------------------------------------------------------
EmFor@0 3185 --
EmFor@0 3186 -- Level bar clicked
EmFor@0 3187 --
EmFor@0 3188 ---------------------------------------------------------------------------------
EmFor@6 3189 function CensusPlus_OnClickLevel(this, button)
EmFor@0 3190 local id = this:GetID();
EmFor@0 3191 if (((button == "LeftButton") and (id == g_LevelSelected)) or ((button == "RightButton") and (id + g_LevelSelected == 0))) then
EmFor@0 3192 g_LevelSelected = 0;
EmFor@0 3193 elseif (button == "RightButton") then
EmFor@0 3194 g_LevelSelected = 0 - id;
EmFor@0 3195 else
EmFor@0 3196 g_LevelSelected = id;
EmFor@0 3197 end
EmFor@0 3198 CensusPlus_UpdateView();
EmFor@0 3199 end
EmFor@0 3200
EmFor@0 3201 ----------------------------------------------------------------------------------
EmFor@0 3202 --
EmFor@0 3203 -- Race tooltip
EmFor@0 3204 --
EmFor@0 3205 ---------------------------------------------------------------------------------
EmFor@6 3206 function CensusPlus_OnEnterRace( this )
EmFor@0 3207 local factionGroup = UnitFactionGroup("player");
EmFor@0 3208 local thisFactionRaces = CensusPlus_GetFactionRaces(factionGroup);
EmFor@0 3209 local id = this:GetID();
EmFor@0 3210 local raceName = thisFactionRaces[id];
EmFor@0 3211 local count = g_RaceCount[id];
EmFor@0 3212 if (count ~= nil) then
EmFor@0 3213 local percent = floor((count / g_TotalCount) * 100);
EmFor@0 3214 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 3215 GameTooltip:SetText(raceName.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
EmFor@0 3216 GameTooltip:Show();
EmFor@0 3217 end
EmFor@0 3218 end
EmFor@0 3219
EmFor@0 3220 ----------------------------------------------------------------------------------
EmFor@0 3221 --
EmFor@0 3222 -- Class tooltip
EmFor@0 3223 --
EmFor@0 3224 ---------------------------------------------------------------------------------
EmFor@6 3225 function CensusPlus_OnEnterClass( self )
EmFor@0 3226 local factionGroup = UnitFactionGroup("player");
EmFor@0 3227 local thisFactionClasses = CensusPlus_GetFactionClasses(factionGroup);
EmFor@6 3228 local id = self:GetID();
EmFor@0 3229 local className = thisFactionClasses[id];
EmFor@0 3230 local count = g_ClassCount[id];
EmFor@0 3231 if (count ~= nil) then
EmFor@0 3232 local percent = floor((count / g_TotalCount) * 100);
EmFor@6 3233 GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
EmFor@0 3234 GameTooltip:SetText(className.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
EmFor@0 3235 GameTooltip:Show();
EmFor@0 3236 end
EmFor@0 3237 end
EmFor@0 3238
EmFor@0 3239 ----------------------------------------------------------------------------------
EmFor@0 3240 --
EmFor@0 3241 -- Level tooltip
EmFor@0 3242 --
EmFor@0 3243 ---------------------------------------------------------------------------------
EmFor@6 3244 function CensusPlus_OnEnterLevel( this )
EmFor@0 3245 local id = this:GetID();
EmFor@0 3246 local count = g_LevelCount[id];
EmFor@0 3247 if (count ~= nil) then
EmFor@6 3248 local percent = floor((count / g_TotalCount) * 100);
EmFor@0 3249 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
EmFor@0 3250 GameTooltip:SetText("Level "..id.."\n"..count.."\n"..percent.."%", 1.0, 1.0, 1.0);
EmFor@0 3251 GameTooltip:Show();
EmFor@0 3252 end
EmFor@0 3253 end
EmFor@0 3254
EmFor@0 3255 ----------------------------------------------------------------------------------
EmFor@0 3256 --
EmFor@0 3257 -- Clicked a guild button
EmFor@0 3258 --
EmFor@0 3259 ---------------------------------------------------------------------------------
EmFor@6 3260 function CensusPlus_GuildButton_OnClick( this )
EmFor@0 3261 local id = this:GetID();
EmFor@0 3262 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame);
EmFor@0 3263 local newSelection = id + offset;
EmFor@0 3264 local guildKey = CensusPlus_Guilds[newSelection].m_Name;
EmFor@0 3265 if (g_GuildSelected ~= guildKey) then
EmFor@0 3266 g_GuildSelected = guildKey;
EmFor@0 3267 else
EmFor@0 3268 g_GuildSelected = nil;
EmFor@0 3269 end
EmFor@0 3270 CensusPlus_UpdateView();
EmFor@0 3271 end
EmFor@0 3272
EmFor@0 3273 ----------------------------------------------------------------------------------
EmFor@0 3274 --
EmFor@0 3275 -- Update the guild button contents
EmFor@0 3276 --
EmFor@0 3277 ---------------------------------------------------------------------------------
EmFor@0 3278 function CensusPlus_UpdateGuildButtons()
EmFor@0 3279 --
EmFor@0 3280 -- Determine where the scroll bar is
EmFor@0 3281 --
EmFor@0 3282 local offset = FauxScrollFrame_GetOffset(CensusPlusGuildScrollFrame);
EmFor@0 3283 --
EmFor@0 3284 -- Walk through all the rows in the frame
EmFor@0 3285 --
EmFor@0 3286 local size = table.getn(CensusPlus_Guilds);
EmFor@0 3287 local i = 1;
EmFor@0 3288 while (i <= CensusPlus_NUMGUILDBUTTONS) do
EmFor@0 3289 --
EmFor@0 3290 -- Get the index to the ad displayed in this row
EmFor@0 3291 --
EmFor@0 3292 local iGuild = i + offset;
EmFor@0 3293 --
EmFor@0 3294 -- Get the button on this row
EmFor@0 3295 --
EmFor@0 3296 local button = getglobal("CensusPlusGuildButton"..i);
EmFor@0 3297 --
EmFor@0 3298 -- Is there a valid guild on this row?
EmFor@0 3299 --
EmFor@0 3300 if (iGuild <= size) then
EmFor@0 3301 local guild = CensusPlus_Guilds[iGuild];
EmFor@0 3302 --
EmFor@0 3303 -- Update the button text
EmFor@0 3304 --
EmFor@0 3305 button:Show();
EmFor@0 3306 local textField = "CensusPlusGuildButton"..i.."Text";
EmFor@0 3307 if (guild.m_Name == "") then
EmFor@0 3308 getglobal(textField):SetText(CENSUSPlus_UNGUILDED);
EmFor@0 3309 else
EmFor@0 3310 getglobal(textField):SetText(guild.m_Name);
EmFor@0 3311 end
EmFor@0 3312 --
EmFor@0 3313 -- If this is the guild, highlight it
EmFor@0 3314 --
EmFor@0 3315 local guildName = CensusPlus_Guilds[iGuild].m_Name
EmFor@0 3316 if (g_GuildSelected == guildName) then
EmFor@0 3317 button:LockHighlight();
EmFor@0 3318 else
EmFor@0 3319 button:UnlockHighlight();
EmFor@0 3320 end
EmFor@0 3321 else
EmFor@0 3322 --
EmFor@0 3323 -- Hide the button
EmFor@0 3324 --
EmFor@0 3325 button:Hide();
EmFor@0 3326 end
EmFor@0 3327 --
EmFor@0 3328 -- Next row
EmFor@0 3329 --
EmFor@0 3330 i = i + 1;
EmFor@0 3331 end
EmFor@0 3332 --
EmFor@0 3333 -- Update the scroll bar
EmFor@0 3334 --
EmFor@0 3335 FauxScrollFrame_Update(CensusPlusGuildScrollFrame, size, CensusPlus_NUMGUILDBUTTONS, CensusPlus_GUILDBUTTONSIZEY);
EmFor@0 3336 end
EmFor@0 3337
EmFor@0 3338
EmFor@0 3339 ----------------------------------------------------------------------------------
EmFor@0 3340 --
EmFor@0 3341 -- Census_AutoStartOnLoad
EmFor@0 3342 --
EmFor@0 3343 ---------------------------------------------------------------------------------
EmFor@0 3344 function Census_AutoStartOnLoad( )
EmFor@0 3345 CP_OptionAutoStartButton:SetChecked(g_MiniOnStart);
EmFor@0 3346 if( g_MiniOnStart == 1 ) then
EmFor@0 3347 MiniCensusPlus:Show();
EmFor@0 3348 else
EmFor@0 3349 MiniCensusPlus:Hide();
EmFor@0 3350 end
EmFor@0 3351 MiniCensusPlus:Hide();
EmFor@0 3352 end
EmFor@0 3353
EmFor@0 3354 ----------------------------------------------------------------------------------
EmFor@0 3355 --
EmFor@0 3356 -- CensusPlus_AutoStart - Set the auto-start option
EmFor@0 3357 --
EmFor@0 3358 ---------------------------------------------------------------------------------
EmFor@0 3359 function CensusPlus_AutoStart( check )
EmFor@0 3360 g_MiniOnStart = check;
EmFor@0 3361 CensusPlus_Database["Info"]["MiniStart"] = g_MiniOnStart;
EmFor@0 3362 Census_AutoStartOnLoad();
EmFor@0 3363 end
EmFor@0 3364
EmFor@0 3365
EmFor@0 3366 ----------------------------------------------------------------------------------
EmFor@0 3367 --
EmFor@0 3368 -- CensusPlus_VerifyLocale - Set the locale (US or EU)
EmFor@0 3369 --
EmFor@0 3370 ---------------------------------------------------------------------------------
EmFor@0 3371 function CensusPlus_VerifyLocale( locale )
EmFor@0 3372 if( CensusPlus_Database["Info"]["Locale"] ~= locale ) then
EmFor@0 3373 --
EmFor@0 3374 -- Purge
EmFor@0 3375 --
EmFor@0 3376 CensusPlus_DoPurge()
EmFor@0 3377 end
EmFor@0 3378 end
EmFor@0 3379
EmFor@0 3380 ----------------------------------------------------------------------------------
EmFor@0 3381 --
EmFor@0 3382 -- CensusPlus_SelectLocale - Set the locale (US or EU)
EmFor@0 3383 --
EmFor@0 3384 ---------------------------------------------------------------------------------
EmFor@0 3385 function CensusPlus_SelectLocale( locale, auto )
EmFor@0 3386
EmFor@0 3387 if( not auto ) then
EmFor@0 3388 CensusPlus_Msg( "You have set your locale to " .. locale .. " from " .. g_CensusPlusLocale );
EmFor@0 3389 end
EmFor@0 3390
EmFor@0 3391 g_CensusPlusLocale = locale;
EmFor@0 3392 if( g_CensusPlusLocale == "EU" ) then
EmFor@0 3393 g_CensusPlusLocale = g_CensusPlusLocale .. "-";
EmFor@0 3394 else
EmFor@0 3395 g_CensusPlusLocale = "";
EmFor@0 3396 end
EmFor@0 3397
EmFor@0 3398
EmFor@0 3399 if( CensusPlus_Database["Info"]["Locale"] ~= locale ) then
EmFor@0 3400 if( not ( CensusPlus_Database["Info"]["Locale"] == nil and locale == "US" ) ) then
EmFor@0 3401 CensusPlus_Msg( "Locale differs from previous setting, purging database." );
EmFor@0 3402 CensusPlus_DoPurge();
EmFor@0 3403 CensusPlus_Database["Info"]["Locale"] = locale;
EmFor@0 3404 end
EmFor@0 3405 end
EmFor@0 3406 CensusPlus_Database["Info"]["Locale"] = locale;
EmFor@0 3407
EmFor@0 3408 textLine = getglobal("CensusPlusText");
EmFor@0 3409 textLine:SetText("Census+ EmSpe\195\167ial v"..CensusPlus_VERSION .. " " .. g_CensusPlusLocale );
EmFor@0 3410
EmFor@0 3411 if(( CENSUSPlus_DWARF == "Nain" or CENSUSPlus_DWARF == "Zwerg" ) and GetLocale() == "usEN") then
EmFor@0 3412 CensusPlus_Msg( "You appear to have a US Census version, yet your localization is set to French or German." );
EmFor@0 3413 CensusPlus_Msg( "Please do not upload stats to WarcraftRealms until this has been resolved." );
EmFor@0 3414 CensusPlus_Msg( "If this is incorrect, please let Rollie know at www.WarcraftRealms.com about your situation so he can make corrections." );
EmFor@0 3415 end
EmFor@0 3416
EmFor@0 3417 CP_EU_US_Version:Hide();
EmFor@0 3418
EmFor@0 3419 end
EmFor@0 3420
EmFor@0 3421 ----------------------------------------------------------------------------------
EmFor@0 3422 --
EmFor@0 3423 -- Walk the character database prune all characters entries that are older than 30 days
EmFor@0 3424 --
EmFor@0 3425 ---------------------------------------------------------------------------------
EmFor@0 3426 function CensusPlus_PruneData( nDays, sServer )
EmFor@0 3427
EmFor@0 3428 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 3429 return;
EmFor@0 3430 end
EmFor@0 3431
EmFor@0 3432
EmFor@0 3433 local thisRealmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 3434
EmFor@0 3435 if( sServer == 1 ) then
EmFor@0 3436 nDays = 0;
EmFor@0 3437 end
EmFor@0 3438
EmFor@0 3439 local pruneTime = 24 * 60 * 60 * nDays;
EmFor@0 3440
EmFor@0 3441 for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do
EmFor@0 3442 if ((realmKey == nil) or (realmKey == realmName)) then
EmFor@0 3443 for factionName, factionDatabase in pairs(realmDatabase) do
EmFor@0 3444 if ((factionKey == nil) or (factionKey == factionName)) then
EmFor@0 3445 for raceName, raceDatabase in pairs(factionDatabase) do
EmFor@0 3446 if ((raceKey == nil) or (raceKey == raceName)) then
EmFor@0 3447 for className, classDatabase in pairs(raceDatabase) do
EmFor@0 3448 if ((classKey == nil) or (classKey == className)) then
EmFor@0 3449 for characterName, character in pairs(classDatabase) do
EmFor@0 3450 if( characterName ~= nil ) then
EmFor@0 3451 if( sServer == 1 ) then
EmFor@0 3452 if( realmName ~= thisRealmName ) then
EmFor@0 3453 CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName );
EmFor@0 3454 end
EmFor@0 3455 else
EmFor@0 3456 local lastSeen = character[3]; -- 2005-05-02
EmFor@0 3457
EmFor@0 3458 local tYear, tMonth, tDay;
EmFor@0 3459 tYear = string.sub( lastSeen, 1, 4 );
EmFor@0 3460 tMonth = string.sub( lastSeen, 6, 7 );
EmFor@0 3461 tDay = string.sub( lastSeen, 9 );
EmFor@0 3462
EmFor@0 3463 local lastSeenTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );
EmFor@0 3464
EmFor@0 3465 if( time() - lastSeenTime > pruneTime ) then
EmFor@0 3466 CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName );
EmFor@0 3467 end
EmFor@0 3468 end
EmFor@0 3469 end
EmFor@0 3470 end
EmFor@0 3471 end
EmFor@0 3472 end
EmFor@0 3473 end
EmFor@0 3474 end
EmFor@0 3475 end
EmFor@0 3476 end
EmFor@0 3477 end
EmFor@0 3478 end
EmFor@0 3479
EmFor@0 3480 CensusPlus_PruneTimes();
EmFor@0 3481 CensusPlus_UpdateView();
EmFor@0 3482 CensusPlus_PruneTheData();
EmFor@0 3483 end
EmFor@0 3484
EmFor@0 3485 -----------------------------------------------------------------------------------
EmFor@0 3486 --
EmFor@0 3487 -- Prune the accumulation
EmFor@0 3488 --
EmFor@0 3489 -----------------------------------------------------------------------------------
EmFor@0 3490 function CensusPlus_AccumulatePruneData( realm, faction, race, class, name )
EmFor@0 3491 local pruneData = {};
EmFor@0 3492 pruneData.realm = realm;
EmFor@0 3493 pruneData.faction = faction;
EmFor@0 3494 pruneData.race = race;
EmFor@0 3495 pruneData.class = class;
EmFor@0 3496 pruneData.name = name;
EmFor@0 3497
EmFor@0 3498 table.insert(g_AccumulatedPruneData, pruneData);
EmFor@0 3499 end
EmFor@0 3500 -----------------------------------------------------------------------------------
EmFor@0 3501 --
EmFor@0 3502 -- Prune the accumulation
EmFor@0 3503 --
EmFor@0 3504 -----------------------------------------------------------------------------------
EmFor@0 3505 function CensusPlus_PruneTheData()
EmFor@0 3506 local num = table.getn(g_AccumulatedPruneData);
EmFor@0 3507 CensusPlus_Msg( format(CENSUSPlus_PRUNEINFO, num ) );
EmFor@0 3508 while( num > 0 )do
EmFor@0 3509 --
EmFor@0 3510 -- Remove the top job from the queue and send it
EmFor@0 3511 --
EmFor@0 3512 local pruneData = g_AccumulatedPruneData[num];
EmFor@0 3513
EmFor@0 3514 CensusPlus_Database["Servers"][pruneData.realm][pruneData.faction][pruneData.race][pruneData.class][pruneData.name] = {};
EmFor@0 3515 CensusPlus_Database["Servers"][pruneData.realm][pruneData.faction][pruneData.race][pruneData.class][pruneData.name] = nil;
EmFor@0 3516
EmFor@0 3517 table.remove(g_AccumulatedPruneData);
EmFor@0 3518 num = table.getn(g_AccumulatedPruneData);
EmFor@0 3519 end
EmFor@0 3520 end
EmFor@0 3521
EmFor@0 3522 -----------------------------------------------------------------------------------
EmFor@0 3523 --
EmFor@0 3524 -- Prune time entries
EmFor@0 3525 --
EmFor@0 3526 -----------------------------------------------------------------------------------
EmFor@0 3527 function CensusPlus_PruneTimes()
EmFor@0 3528 local pruneDays = 60*60*24*21; -- num seconds
EmFor@0 3529
EmFor@0 3530 local accumTimesData = {};
EmFor@0 3531 for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do
EmFor@0 3532 if (realmName ~= nil ) then
EmFor@0 3533 for factionName, factionDatabase in pairs(realmDatabase) do
EmFor@0 3534 if ( factionName ~= nil) then
EmFor@0 3535 for moment, count in pairs( factionDatabase ) do
EmFor@0 3536 -- Moment is in format of YYYY-MM-DD&HH:MM
EmFor@0 3537 local test = string.sub( moment, 1, 2 );
EmFor@0 3538 local tYear, tMonth, tDay;
EmFor@0 3539 tYear = string.sub( moment, 1, 4 );
EmFor@0 3540 tMonth = string.sub( moment, 6, 7 );
EmFor@0 3541 tDay = string.sub( moment, 9, 10 );
EmFor@0 3542 local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );
EmFor@0 3543
EmFor@0 3544 if( time() - momentTime > pruneDays ) then
EmFor@0 3545 -- cull entry
EmFor@0 3546 local pruneData = {};
EmFor@0 3547 pruneData.realm = realmName;
EmFor@0 3548 pruneData.faction = factionName;
EmFor@0 3549 pruneData.entry = moment;
EmFor@0 3550 table.insert(accumTimesData, pruneData);
EmFor@0 3551 end
EmFor@0 3552 end
EmFor@0 3553 end
EmFor@0 3554 end
EmFor@0 3555 end
EmFor@0 3556 end
EmFor@0 3557
EmFor@0 3558 local num = table.getn(accumTimesData);
EmFor@0 3559 while( num > 0 )do
EmFor@0 3560 local pruneData = accumTimesData[num];
EmFor@0 3561
EmFor@0 3562 CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = {};
EmFor@0 3563 CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = nil;
EmFor@0 3564
EmFor@0 3565 table.remove(accumTimesData);
EmFor@0 3566 num = table.getn(accumTimesData);
EmFor@0 3567 end
EmFor@0 3568 end
EmFor@0 3569
EmFor@0 3570
EmFor@0 3571 function CensusPlus_CheckForBattleground()
EmFor@0 3572
EmFor@0 3573
EmFor@0 3574 -- CensusPlus_Msg( "Checking for BG" );
EmFor@0 3575 g_CurrentlyInBG_Msg = false;
EmFor@0 3576
EmFor@0 3577 local battlefieldTime = GetBattlefieldInstanceRunTime();
EmFor@0 3578 if( battlefieldTime > 0 ) then
EmFor@0 3579 --
EmFor@0 3580 -- We are in a battleground so cancel the current take
EmFor@0 3581 --
EmFor@0 3582 g_CurrentlyInBG = true;
EmFor@0 3583 else
EmFor@0 3584 if( GetBattlefieldStatInfo(1) ~= nil ) then
EmFor@0 3585 g_CurrentlyInBG = true;
EmFor@0 3586 else
EmFor@0 3587 g_CurrentlyInBG = false;
EmFor@0 3588 end
EmFor@0 3589 end
EmFor@0 3590
EmFor@0 3591 end
EmFor@0 3592
EmFor@0 3593 function CensusPlus_IsInspectLoaded()
EmFor@0 3594 if (IsAddOnLoaded("Blizzard_InspectUI")) then
EmFor@0 3595 --ChatFrame1:AddMessage("Inspect Loaded");
EmFor@0 3596 return true;
EmFor@0 3597 end
EmFor@0 3598
EmFor@0 3599 if (CensusPlus_Database["Info"]["LoadInspect"] ~= nil and CensusPlus_Database["Info"]["LoadInspect"] == true) then
EmFor@0 3600 --ChatFrame1:AddMessage("Loading Inspect Frame");
EmFor@0 3601 LoadAddOn("Blizzard_InspectUI");
EmFor@0 3602 end
EmFor@0 3603
EmFor@0 3604 --ChatFrame1:AddMessage("Inspect Not Loaded");
EmFor@0 3605 return false;
EmFor@0 3606 end
EmFor@0 3607
EmFor@0 3608 function CensusPlus_IsTalentLoaded()
EmFor@0 3609 if (IsAddOnLoaded("Blizzard_TalentUI")) then
EmFor@0 3610 --ChatFrame1:AddMessage("Talent Loaded");
EmFor@0 3611 return true;
EmFor@0 3612 end
EmFor@0 3613
EmFor@0 3614 if (CensusPlus_Database["Info"]["LoadTalent"] ~= nil and CensusPlus_Database["Info"]["LoadTalent"] == true) then
EmFor@0 3615 --ChatFrame1:AddMessage("Loading Talent Frame");
EmFor@0 3616 LoadAddOn("Blizzard_TalentUI");
EmFor@0 3617 end
EmFor@0 3618
EmFor@0 3619 --ChatFrame1:AddMessage("Talent Not Loaded");
EmFor@0 3620 return false;
EmFor@0 3621 end
EmFor@0 3622
EmFor@0 3623
EmFor@0 3624
EmFor@0 3625 function showAllUnitBuffs(sUnitname)
EmFor@0 3626 local iIterator = 1
EmFor@0 3627 DEFAULT_CHAT_FRAME:AddMessage(format("[%s] Buffs", sUnitname))
EmFor@0 3628 while (UnitBuff(sUnitname, iIterator)) do
EmFor@0 3629 DEFAULT_CHAT_FRAME:AddMessage(UnitBuff(sUnitname, iIterator), 1, 1, 0)
EmFor@0 3630 iIterator = iIterator + 1
EmFor@0 3631 end
EmFor@0 3632 DEFAULT_CHAT_FRAME:AddMessage("---", 1, 1, 0)
EmFor@0 3633 end
EmFor@0 3634
EmFor@0 3635 function CensusPlus_GetUTCDateTimeStr()
EmFor@0 3636 return date( "!%Y-%m-%d %H:%M", time() );
EmFor@0 3637 end
EmFor@0 3638
EmFor@0 3639 -----------------------------------------------------------------------------------
EmFor@0 3640 --
EmFor@0 3641 -- CensusPlus_DetermineServerDate
EmFor@0 3642 --
EmFor@0 3643 -----------------------------------------------------------------------------------
EmFor@0 3644 function CensusPlus_DetermineServerDate()
EmFor@0 3645
EmFor@0 3646 CensusPlus_CheckTZ();
EmFor@0 3647
EmFor@0 3648 local strDate;
EmFor@0 3649 local TZOffset = g_CensusPlusTZOffset;
EmFor@0 3650
EmFor@0 3651 --
EmFor@0 3652 -- Timezone offsets should fall into distinct numbers for now
EmFor@0 3653 -- And now that we know if they are playing on US or EU servers
EmFor@0 3654 -- we can be even better estimates
EmFor@0 3655 --
EmFor@0 3656
EmFor@0 3657 --
EmFor@0 3658 -- For US servers, the offset should be either -9 to -5 or 16/19 depending on DST for NA times
EmFor@0 3659 -- and for oceana it is +11/-13
EmFor@0 3660 -- EU servers are either +1 or 0 or -23 depending on DST
EmFor@0 3661 --
EmFor@0 3662
EmFor@0 3663 if( CensusPlus_Database["Info"]["Locale"] == "US" ) then
EmFor@0 3664 if( TZOffset > 12 ) then
EmFor@0 3665 -- NA server times but wrong day
EmFor@0 3666 TZOffset = TZOffset - 24;
EmFor@0 3667 elseif( TZOffset < -11 ) then
EmFor@0 3668 -- Oceana times but wrong day
EmFor@0 3669 TZOffset = 24 - TZOffset;
EmFor@0 3670 end
EmFor@0 3671 else
EmFor@0 3672 if( TZOffset == -23 ) then
EmFor@0 3673 TZOffset = 1;
EmFor@0 3674 end
EmFor@0 3675 end
EmFor@0 3676
EmFor@0 3677 -- Now, take the TZOffset and modify our time to give us server date
EmFor@0 3678 strDate = date( "!%Y-%m-%d", time() + (TZOffset * 3600 ) );
EmFor@0 3679
EmFor@0 3680 -- local strDate2 = date( "%Y-%m-%d : %H:%M", time() );
EmFor@0 3681 -- CensusPlus_Msg("Server date = " .. strDate .. " for TZOffset : " .. TZOffset .. " curr local: " .. strDate2 );
EmFor@0 3682
EmFor@0 3683 return strDate;
EmFor@0 3684 end
EmFor@0 3685
EmFor@0 3686 -----------------------------------------------------------------------------------
EmFor@0 3687 --
EmFor@0 3688 -- Check time zone
EmFor@0 3689 --
EmFor@0 3690 -----------------------------------------------------------------------------------
EmFor@0 3691 function CensusPlus_CheckTZ()
EmFor@0 3692
EmFor@0 3693 local UTCTimeHour = date( "!%H", time() );
EmFor@0 3694 local LocTimeHour = date( "%H", time() );
EmFor@0 3695 local hour, minute = GetGameTime();
EmFor@0 3696
EmFor@0 3697 local locDiff = LocTimeHour - UTCTimeHour;
EmFor@0 3698 local servDiff = hour - UTCTimeHour;
EmFor@0 3699 g_CensusPlusTZOffset = servDiff;
EmFor@0 3700 end
EmFor@0 3701
EmFor@0 3702
EmFor@0 3703 function CensusPlus_UpdateBattleGroundInfo()
EmFor@0 3704 local status, mapName, instanceID, lowestLevel, highestLevel;
EmFor@0 3705 local numberQueues = 0;
EmFor@0 3706 local waitTime, timeInQueue;
EmFor@0 3707 local map = {};
EmFor@0 3708
EmFor@0 3709 if( g_CensusPlusLocale == "N/A" ) then
EmFor@0 3710 return;
EmFor@0 3711 end
EmFor@0 3712
EmFor@0 3713 for i=1, MAX_BATTLEFIELD_QUEUES do
EmFor@0 3714 map = {};
EmFor@0 3715 status, mapName, instanceID, lowestLevel, highestLevel = GetBattlefieldStatus(i);
EmFor@0 3716
EmFor@0 3717 if ( status ~= "none" ) then
EmFor@0 3718 numberQueues = numberQueues+1;
EmFor@0 3719
EmFor@0 3720 if ( status == "queued" ) then
EmFor@0 3721 -- Update queue info
EmFor@0 3722 waitTime = GetBattlefieldEstimatedWaitTime(i)/1000;
EmFor@0 3723 timeInQueue = GetBattlefieldTimeWaited(i)/1000;
EmFor@0 3724
EmFor@0 3725 map[0] = waitTime;
EmFor@0 3726 map[1] = timeInQueue;
EmFor@0 3727 map[2] = mapName;
EmFor@0 3728 map[3] = "Inactive";
EmFor@0 3729
EmFor@0 3730 -- CensusPlus_Msg( "INSERT " .. mapName .. " : " .. map[2] .. " to " .. i );
EmFor@0 3731 CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i] = map;
EmFor@0 3732
EmFor@0 3733 elseif ( status == "confirm" ) then
EmFor@0 3734 -- In the battleground
EmFor@0 3735 -- Check to see if we know we've already entered, and if so, add info to
EmFor@0 3736 -- our database
EmFor@0 3737 map = CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i];
EmFor@0 3738
EmFor@0 3739 -- CensusPlus_Msg( "ACTIVE " .. mapName );
EmFor@0 3740 -- CensusPlus_Msg( map[2] );
EmFor@0 3741 if( map ~= nil and map[3] == "Inactive" ) then
EmFor@0 3742 map[3] = "Active";
EmFor@0 3743
EmFor@0 3744 CENSUSPLUS_CURRENT_BATTLEFIELD_QUEUES[i] = map;
EmFor@0 3745
EmFor@0 3746 -- Make an entry in our database
EmFor@0 3747
EmFor@0 3748 --
EmFor@0 3749 -- Get the portion of the database for this server
EmFor@0 3750 --
EmFor@0 3751 local realmName = g_CensusPlusLocale .. GetCVar("realmName");
EmFor@0 3752 if (CensusPlus_BGInfo[realmName] == nil) then
EmFor@0 3753 CensusPlus_BGInfo[realmName] = {};
EmFor@0 3754 end
EmFor@0 3755
EmFor@0 3756 --
EmFor@0 3757 -- Get the portion of the database for this faction
EmFor@0 3758 --
EmFor@0 3759 local factionGroup = UnitFactionGroup("player");
EmFor@0 3760 if( factionGroup ~= nil ) then
EmFor@0 3761 if (CensusPlus_BGInfo[realmName][factionGroup] == nil) then
EmFor@0 3762 CensusPlus_BGInfo[realmName][factionGroup] = {};
EmFor@0 3763 end
EmFor@0 3764
EmFor@0 3765 local playerLevel = UnitLevel( "player" );
EmFor@0 3766 if( playerLevel ~= nil ) then
EmFor@0 3767 if (CensusPlus_BGInfo[realmName][factionGroup][playerLevel] == nil) then
EmFor@0 3768 CensusPlus_BGInfo[realmName][factionGroup][playerLevel] = {};
EmFor@0 3769 end
EmFor@0 3770
EmFor@0 3771 local hour, minute = GetGameTime();
EmFor@0 3772 CensusPlus_BGInfo[realmName][factionGroup][playerLevel][CensusPlus_DetermineServerDate() .. "&" .. hour .. ":" .. minute .. ":00"] =
EmFor@0 3773 map[2] .. "&" .. map[0] .. "&" .. map[1] .. "&" .. lowestLevel .. "&" .. highestLevel;
EmFor@0 3774 end
EmFor@0 3775 end
EmFor@0 3776 end
EmFor@0 3777 end
EmFor@0 3778 end
EmFor@0 3779 end
EmFor@0 3780 end
EmFor@0 3781
EmFor@0 3782 function CensusPlus_PruneBGInfo()
EmFor@0 3783 local pruneDays = 60*60*24*21; -- num seconds
EmFor@0 3784
EmFor@0 3785 local accumData = {};
EmFor@0 3786 for realmName, realmDatabase in pairs(CensusPlus_BGInfo) do
EmFor@0 3787 if (realmName ~= nil and table.getn( realmDatabase ) > 0 ) then
EmFor@0 3788 for factionName, factionDatabase in pairs(realmDatabase) do
EmFor@0 3789 if ( factionName ~= nil and table.getn( factionDatabase ) > 0 ) then
EmFor@0 3790 for level, levelDatabase in pairs( factionDatabase ) do
EmFor@0 3791 if( level ~= nil and table.getn( levelDatabase ) > 0 ) then
EmFor@0 3792 for moment, data in pairs( levelDatabase ) do
EmFor@0 3793 -- Moment is in format of YYYY-MM-DD&HH:MM
EmFor@0 3794 local test = string.sub( moment, 1, 2 );
EmFor@0 3795 local tYear, tMonth, tDay;
EmFor@0 3796 tYear = string.sub( moment, 1, 4 );
EmFor@0 3797 tMonth = string.sub( moment, 6, 7 );
EmFor@0 3798 tDay = string.sub( moment, 9, 10 );
EmFor@0 3799 local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );
EmFor@0 3800
EmFor@0 3801 if( time() - momentTime > pruneDays ) then
EmFor@0 3802 -- cull entry
EmFor@0 3803 local pruneData = {};
EmFor@0 3804 pruneData.realm = realmName;
EmFor@0 3805 pruneData.faction = factionName;
EmFor@0 3806 pruneData.level = level;
EmFor@0 3807 pruneData.entry = moment;
EmFor@0 3808 table.insert(accumData, pruneData);
EmFor@0 3809 end
EmFor@0 3810 end
EmFor@0 3811 end
EmFor@0 3812 end
EmFor@0 3813 end
EmFor@0 3814 end
EmFor@0 3815 end
EmFor@0 3816 end
EmFor@0 3817
EmFor@0 3818 local num = table.getn(accumData);
EmFor@0 3819 while( num > 0 )do
EmFor@0 3820 local pruneData = accumData[num];
EmFor@0 3821
EmFor@0 3822 CensusPlus_BGInfo[pruneData.realm][pruneData.faction][pruneData.level][pruneData.entry] = {};
EmFor@0 3823 CensusPlus_BGInfo[pruneData.realm][pruneData.faction][pruneData.level][pruneData.entry] = nil;
EmFor@0 3824
EmFor@0 3825 table.remove(accumData);
EmFor@0 3826 num = table.getn(accumData);
EmFor@0 3827 end
EmFor@0 3828 end
EmFor@0 3829
EmFor@0 3830 -----------------------------------------------------------------------------------
EmFor@0 3831 --
EmFor@0 3832 -- My Test function
EmFor@0 3833 --
EmFor@0 3834 -----------------------------------------------------------------------------------
EmFor@0 3835 function CensusPlus_Test( val )
EmFor@0 3836
EmFor@0 3837
EmFor@0 3838 -- local file = "Interface\\AddOns\\CensusPlus\\Sounds\\CensusComplete.ogg";
EmFor@0 3839 -- CensusPlus_Msg( "Play sound " .. file );
EmFor@0 3840 -- PlaySoundFile( file );
EmFor@0 3841
EmFor@0 3842 local test = {};
EmFor@0 3843 test[1] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Tauren Warrior <CSM AND NOVA SUX> - Hellfire Peninsula";
EmFor@0 3844 test[2] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Tauren Warrior - Hellfire Peninsula";
EmFor@0 3845 test[3] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Troll Death Knight <CSM AND NOVA SUX> - Hellfire Peninsula";
EmFor@0 3846 test[4] = "|Hplayer:Cdrom|h[Cdrom]|h: Level 60 Troll Death Knight - Hellfire Peninsula";
EmFor@0 3847 test[5] = "|Hplayer:Frostbiite|h[Frostbiite]|h: Level 61 Troll Death Knight - Hellfire Peninsula";
EmFor@0 3848 test[6] = "|Hplayer:Dynanite|h[Dynanite]|h: Level 60 Troll Death Knight - Hellfire Peninsula";
EmFor@0 3849 test[7] = "|Hplayer:Physco|h[Physco]|h: Level 61 Troll Death Knight - Hellfire Peninsula";
EmFor@0 3850 test[8] = "|Hplayer:Gordoom|h[Gordoom]|h: Level 60 Troll Death Knight <Hellfire Club> - Hellfire Peninsula";
EmFor@0 3851 test[9] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Death Knight <Carnage> - Nagrand";
EmFor@0 3852 test[10] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Death Knight <Carnage> - Nagrand";
EmFor@0 3853 test[11] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Death Knight - Nagrand";
EmFor@0 3854 test[12] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Death Knight - Nagrand";
EmFor@0 3855 test[13] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Paladin <Carnage> - Nagrand";
EmFor@0 3856 test[14] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Paladin <Carnage> - Nagrand";
EmFor@0 3857 test[15] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Blood Elf Paladin - Nagrand";
EmFor@0 3858 test[16] = "|Hplayer:Seroa|h[Seroa]|h: Level 67 Night Elf Paladin - Nagrand";
EmFor@0 3859
EmFor@0 3860
EmFor@0 3861 for index, case in pairs(test) do
EmFor@0 3862 CensusPlus_Msg( "Checking : " .. case );
EmFor@0 3863 local t = CensusPlus_GatherSingleReturn( case );
EmFor@0 3864 if( t ~= nil ) then
EmFor@0 3865 CensusPlus_Msg( index .. " Name : " .. t["NAME"]
EmFor@0 3866 .. " L: " .. t["LEVEL"]
EmFor@0 3867 .. " R: " .. t["RACE"]
EmFor@0 3868 .. " C: " .. t["CLASS"]
EmFor@0 3869 .. " G: " .. t["GUILD"]
EmFor@0 3870 .. " Z: " .. t["ZONE"] );
EmFor@0 3871 end
EmFor@0 3872 end
EmFor@0 3873
EmFor@0 3874
EmFor@0 3875 --[[
EmFor@0 3876 local pattern = "[0-9\| ]";
EmFor@0 3877
EmFor@0 3878 local name = "11:58]|r |Hplayer:Azide|h[Azide";
EmFor@0 3879 if( string.find( name, pattern ) ~= nil ) then
EmFor@0 3880 CensusPlus_Msg( "This name is problematic => " .. name );
EmFor@0 3881 end
EmFor@0 3882
EmFor@0 3883 name = "Rollie";
EmFor@0 3884 if( string.find( name, pattern ) ~= nil ) then
EmFor@0 3885 CensusPlus_Msg( "This name is problematic => " .. name );
EmFor@0 3886 else
EmFor@0 3887 CensusPlus_Msg( "This name is NOT problematic => " .. name );
EmFor@0 3888 end
EmFor@0 3889 ]]--
EmFor@0 3890
EmFor@0 3891 end
EmFor@0 3892
EmFor@0 3893 function CensusPlus_GatherSingleReturn( line )
EmFor@0 3894 local t = {};
EmFor@0 3895 local s, e, name, level_text, level, rcg, zone, junk;
EmFor@0 3896 local RCG = {};
EmFor@0 3897 local presults = {};
EmFor@0 3898 local RCG_Pattern = "(.+) <(.+)>";
EmFor@0 3899 local possibles = {};
EmFor@0 3900 possibles[1] = "(" .. CENSUSPlus_NIGHTELF .. ")" .. " ([%a%s]+)";
EmFor@0 3901 possibles[2] = "(" .. CENSUSPlus_BLOODELF .. ")" .. " ([%a%s]+)";
EmFor@0 3902 possibles[3] = "(%a+) " .. "(" .. CENSUSPlus_DEATHKNIGHT .. ")";
EmFor@0 3903 possibles[4] = "(%a+) (%a+)";
EmFor@0 3904
EmFor@0 3905 --CensusPlus_Msg2( " CHECKING " .. line );
EmFor@0 3906
EmFor@0 3907 if( g_PratLoaded ) then
EmFor@0 3908 s, e, junk, junk, junk, name, junk, junk, level_text, level, rcg, zone = string.find(line, CENSUS_SINGLE_MATCH_PATTERN_PRAT );
EmFor@0 3909 else
EmFor@0 3910 s, e, junk, junk, name, level_text, level, rcg, zone = string.find(line, CENSUS_SINGLE_MATCH_PATTERN);
EmFor@0 3911 end
EmFor@0 3912 if( name ~= nil ) then
EmFor@0 3913 --
EmFor@0 3914 -- Now let's break out our race, class & guild
EmFor@0 3915 --
EmFor@0 3916 local race_class = rcg;
EmFor@0 3917 t["GUILD"] = '';
EmFor@0 3918 t["NAME"] = name;
EmFor@0 3919 t["LEVEL"] = level;
EmFor@0 3920 t["ZONE"] = zone;
EmFor@0 3921 s, e, RCG[0], RCG[1] = string.find(rcg, RCG_Pattern);
EmFor@0 3922 if( RCG[0] ~= nil ) then
EmFor@0 3923 race_class = RCG[0];
EmFor@0 3924 t["GUILD"] = RCG[1];
EmFor@0 3925 end
EmFor@0 3926
EmFor@0 3927 --
EmFor@0 3928 -- Now we need to figure out race/class
EmFor@0 3929 --
EmFor@0 3930 for pi, poss in pairs(possibles) do
EmFor@0 3931 s, e, presults[0], presults[1] = string.find(race_class, poss);
EmFor@0 3932 if( presults[0] ~= nil ) then
EmFor@0 3933 -- CensusPlus_Msg( pi .. " 0: " .. presults[0] .. " 1: " .. presults[1]);
EmFor@0 3934 t["RACE"] = presults[0];
EmFor@0 3935 t["CLASS"] = presults[1];
EmFor@0 3936 break;
EmFor@0 3937 end
EmFor@0 3938 end
EmFor@0 3939
EmFor@0 3940 -- CensusPlus_Msg2( " IN Fn Name : " .. t["NAME"] .. " L: " .. t["LEVEL"] .. " R: " .. t["RACE"] .. " C: " .. t["CLASS"].. " G: " .. t["GUILD"] .. " Z: " .. t["ZONE"] );
EmFor@0 3941 end
EmFor@0 3942
EmFor@0 3943 return t;
EmFor@0 3944 end
EmFor@0 3945
EmFor@0 3946
EmFor@0 3947 function CensusPlus_SetItemRef(link, text, button)
EmFor@0 3948 --
EmFor@0 3949 -- We only care about if they are sending a who, otherwise send on through
EmFor@0 3950 --
EmFor@0 3951 if ( g_IsCensusPlusInProgress and strsub(link, 1, 6) == "player" ) then
EmFor@0 3952 if ( strsub(link, 1, 6) == "player" ) then
EmFor@0 3953 local namelink = strsub(link, 8);
EmFor@0 3954 local name, lineid = strsplit(":", namelink);
EmFor@0 3955 if ( name and (strlen(name) > 0) ) then
EmFor@0 3956 name = gsub(name, "([^%s]*)%s+([^%s]*)%s+([^%s]*)", "%3");
EmFor@0 3957 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
EmFor@0 3958 if ( IsShiftKeyDown() ) then
EmFor@6 3959 if ( not ChatFrame1EditBox:IsVisible() ) then
EmFor@0 3960 --
EmFor@0 3961 -- This is the part we need to snag
EmFor@0 3962 --
EmFor@0 3963
EmFor@0 3964 --
EmFor@0 3965 -- Queue up the command to run next
EmFor@0 3966 --
EmFor@0 3967 g_CensusWhoOverrideMsg = "n-"..name;
EmFor@0 3968 CensusPlus_Msg( CENSUSPlus_OVERRIDE );
EmFor@0 3969
EmFor@0 3970 -- CensusPlus_SendWho("n-"..name);
EmFor@0 3971 return;
EmFor@0 3972 end
EmFor@0 3973 end
EmFor@0 3974 end
EmFor@0 3975 end
EmFor@0 3976 end
EmFor@0 3977
EmFor@0 3978 g_SetItemRef_Override( link, text, button );
EmFor@0 3979 end
EmFor@0 3980
EmFor@0 3981 function CensusPlus_CleanChars()
EmFor@0 3982
EmFor@0 3983 local pattern = "[0-9\| -]";
EmFor@0 3984 local count = 0;
EmFor@0 3985
EmFor@0 3986 for realmName, realmDatabase in pairs(CensusPlus_Database["Servers"]) do
EmFor@0 3987 if ((realmKey == nil) or (realmKey == realmName)) then
EmFor@0 3988 for factionName, factionDatabase in pairs(realmDatabase) do
EmFor@0 3989 if ((factionKey == nil) or (factionKey == factionName)) then
EmFor@0 3990 for raceName, raceDatabase in pairs(factionDatabase) do
EmFor@0 3991 if ((raceKey == nil) or (raceKey == raceName)) then
EmFor@0 3992 for className, classDatabase in pairs(raceDatabase) do
EmFor@0 3993 if ((classKey == nil) or (classKey == className)) then
EmFor@0 3994 for characterName, character in pairs(classDatabase) do
EmFor@0 3995 if( characterName ~= nil ) then
EmFor@0 3996 if( string.find( characterName, pattern ) ~= nil ) then
EmFor@0 3997 CensusPlus_AccumulatePruneData( realmName, factionName, raceName, className, characterName );
EmFor@0 3998 count = count + 1;
EmFor@0 3999 end
EmFor@0 4000 end
EmFor@0 4001 end
EmFor@0 4002 end
EmFor@0 4003 end
EmFor@0 4004 end
EmFor@0 4005 end
EmFor@0 4006 end
EmFor@0 4007 end
EmFor@0 4008 end
EmFor@0 4009 end
EmFor@0 4010
EmFor@0 4011 CensusPlus_PruneTheData();
EmFor@0 4012 CensusPlus_Msg( "Found " .. count .. " entries to remove" );
EmFor@0 4013 end
EmFor@0 4014
EmFor@0 4015 function CensusPlus_SendWho( msg )
EmFor@0 4016
EmFor@0 4017 if( CensusPlus_PerCharInfo["Verbose"] == true ) then
EmFor@0 4018 CensusPlus_Msg(format(CENSUSPlus_SENDING, msg));
EmFor@0 4019 end
EmFor@0 4020
EmFor@0 4021 if wholib then
EmFor@0 4022 wholib:AskWho({query = msg, queue = wholib.WHOLIB_QUEUE_QUIET, callback = CP_ProcessWhoEvent })
EmFor@0 4023 else
EmFor@0 4024 SendWho( msg );
EmFor@0 4025 end
EmFor@0 4026 end
EmFor@6 4027 function CensusPlus_Options_OnMouseUp(self,...)
EmFor@6 4028 CensusPlus_Msg('Mouse up');
EmFor@6 4029 if ( self.isMoving ) then
EmFor@6 4030 self:StopMovingOrSizing();
EmFor@6 4031 self.isMoving = false;
EmFor@6 4032 end
EmFor@6 4033 end
EmFor@6 4034 function CensusPlus_Options_OnMouseDown(self,arg1,arg2,arg3,...)
EmFor@6 4035 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
EmFor@6 4036 self:StartMoving();
EmFor@6 4037 self.isMoving = true;
EmFor@6 4038 end
EmFor@6 4039 end
EmFor@6 4040 function CensusPlus_Mini_OnMouseDown( self, arg1 )
EmFor@6 4041 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
EmFor@6 4042 self:StartMoving();
EmFor@6 4043 self.isMoving = true;
EmFor@6 4044 end
EmFor@6 4045 end
EmFor@6 4046 function CensusPlus_Census_OnMouseDown( self, arg1 )
EmFor@6 4047 if ( ( ( not self.isLocked ) or ( self.isLocked == 0 ) ) and ( arg1 == "LeftButton" ) ) then
EmFor@6 4048 self:StartMoving();
EmFor@6 4049 self.isMoving = true;
EmFor@6 4050 end
EmFor@11 4051 end