annotate CensusPlus.lua @ 2:adc1113ea1e1 beta 1

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