Mercurial > wow > wowdb-profiler
comparison Main.lua @ 14:27c153c3a1ed
Wipe SavedVariables if the current WoW build number is greater than the last recorded build number. If a merchant can repair items, record that fact.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Thu, 03 May 2012 10:43:18 -0500 |
parents | 39972835bdc9 |
children | 62b0fb4281cd |
comparison
equal
deleted
inserted
replaced
13:39972835bdc9 | 14:27c153c3a1ed |
---|---|
157 ----------------------------------------------------------------------- | 157 ----------------------------------------------------------------------- |
158 -- Methods. | 158 -- Methods. |
159 ----------------------------------------------------------------------- | 159 ----------------------------------------------------------------------- |
160 function WDP:OnInitialize() | 160 function WDP:OnInitialize() |
161 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global | 161 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global |
162 | |
163 local wow_version, build_num = _G.GetBuildInfo() | |
164 local raw_db = _G["WoWDBProfilerData"] | |
165 | |
166 build_num = tonumber(build_num) | |
167 | |
168 if raw_db.build_num and raw_db.build_num < build_num then | |
169 for entry in pairs(DATABASE_DEFAULTS.global) do | |
170 db[entry] = {} | |
171 end | |
172 raw_db.build_num = build_num | |
173 elseif not raw_db.build_num then | |
174 raw_db.build_num = build_num | |
175 end | |
162 end | 176 end |
163 | 177 |
164 | 178 |
165 function WDP:OnEnable() | 179 function WDP:OnEnable() |
166 for event_name, mapping in pairs(EVENT_MAPPING) do | 180 for event_name, mapping in pairs(EVENT_MAPPING) do |
272 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target")) | 286 local unit_type, id_num = WDP:ParseGUID(_G.UnitGUID("target")) |
273 action_data.id_num = id_num | 287 action_data.id_num = id_num |
274 end | 288 end |
275 return true | 289 return true |
276 end, | 290 end, |
277 [AF.OBJECT] = function() | 291 [AF.OBJECT] = true, |
278 return true | |
279 end, | |
280 } | 292 } |
281 | 293 |
282 | 294 |
283 local LOOT_UPDATE_FUNCS = { | 295 local LOOT_UPDATE_FUNCS = { |
284 [AF.NPC] = function() | 296 [AF.NPC] = function() |
306 action_data.type = AF.NPC | 318 action_data.type = AF.NPC |
307 end | 319 end |
308 local verify_func = LOOT_VERIFY_FUNCS[action_data.type] | 320 local verify_func = LOOT_VERIFY_FUNCS[action_data.type] |
309 local update_func = LOOT_UPDATE_FUNCS[action_data.type] | 321 local update_func = LOOT_UPDATE_FUNCS[action_data.type] |
310 | 322 |
311 if not verify_func or not update_func or not verify_func() then | 323 if not verify_func or not update_func then |
312 return | 324 return |
313 end | 325 end |
314 | 326 |
327 if _G.type(verify_func) == "function" and not verify_func() then | |
328 return | |
329 end | |
315 local loot_registry = {} | 330 local loot_registry = {} |
316 action_data.drops = {} | 331 action_data.drops = {} |
317 | 332 |
318 for loot_slot = 1, _G.GetNumLootItems() do | 333 for loot_slot = 1, _G.GetNumLootItems() do |
319 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot) | 334 local icon_texture, item_text, quantity, quality, locked = _G.GetLootSlotInfo(loot_slot) |
412 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) | 427 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) |
413 end | 428 end |
414 end | 429 end |
415 merchant.sells[("%s:%s:[%s]"):format(item_id, stack_size, price_string)] = num_available | 430 merchant.sells[("%s:%s:[%s]"):format(item_id, stack_size, price_string)] = num_available |
416 end | 431 end |
432 end | |
433 | |
434 if _G.CanMerchantRepair() then | |
435 merchant.can_repair = true | |
417 end | 436 end |
418 end | 437 end |
419 | 438 |
420 | 439 |
421 local GENDER_NAMES = { | 440 local GENDER_NAMES = { |