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