Mercurial > wow > wowdb-profiler
comparison Main.lua @ 74:06daf4cb1cf9
Wipe the DB if the version is different from the code version. Simplify WoW version check.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Mon, 20 Aug 2012 11:39:46 -0500 |
parents | 8ff44f76e844 |
children | a034bfa8982b |
comparison
equal
deleted
inserted
replaced
73:762d841192c0 | 74:06daf4cb1cf9 |
---|---|
14 ----------------------------------------------------------------------- | 14 ----------------------------------------------------------------------- |
15 -- AddOn namespace. | 15 -- AddOn namespace. |
16 ----------------------------------------------------------------------- | 16 ----------------------------------------------------------------------- |
17 local ADDON_NAME, private = ... | 17 local ADDON_NAME, private = ... |
18 | 18 |
19 -- TODO: Remove this once 5.0.4 hits Live. | |
20 if private.wow_version == "4.3.4" then | |
21 return | |
22 end | |
23 | |
19 local LibStub = _G.LibStub | 24 local LibStub = _G.LibStub |
20 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0") | 25 local WDP = LibStub("AceAddon-3.0"):NewAddon(ADDON_NAME, "AceEvent-3.0", "AceTimer-3.0") |
21 | 26 |
22 local deformat = LibStub("LibDeformat-3.0") | 27 local deformat = LibStub("LibDeformat-3.0") |
23 | 28 |
26 | 31 |
27 | 32 |
28 ----------------------------------------------------------------------- | 33 ----------------------------------------------------------------------- |
29 -- Local constants. | 34 -- Local constants. |
30 ----------------------------------------------------------------------- | 35 ----------------------------------------------------------------------- |
31 local DB_VERSION = 3 | 36 local DB_VERSION = 4 |
32 | 37 |
33 local DATABASE_DEFAULTS = { | 38 local DATABASE_DEFAULTS = { |
34 global = { | 39 global = { |
35 items = {}, | 40 items = {}, |
36 npcs = {}, | 41 npcs = {}, |
405 | 410 |
406 ----------------------------------------------------------------------- | 411 ----------------------------------------------------------------------- |
407 -- Methods. | 412 -- Methods. |
408 ----------------------------------------------------------------------- | 413 ----------------------------------------------------------------------- |
409 function WDP:OnInitialize() | 414 function WDP:OnInitialize() |
410 -- TODO: Remove this once 5.0.4 hits Live. | |
411 if private.wow_version == "4.3.4" then | |
412 return | |
413 end | |
414 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global | 415 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global |
415 | 416 |
416 local raw_db = _G["WoWDBProfilerData"] | 417 local raw_db = _G["WoWDBProfilerData"] |
417 local build_num = tonumber(private.build_num) | 418 local build_num = tonumber(private.build_num) |
418 | 419 |
419 -- TODO: Un-comment this when MoP goes live. | 420 -- TODO: Merge this with the DB version check when MoP goes live. |
420 -- if raw_db.build_num and raw_db.build_num < build_num then | 421 -- if raw_db.build_num and raw_db.build_num < build_num then |
421 -- for entry in pairs(DATABASE_DEFAULTS.global) do | 422 if raw_db.version and raw_db.version < DB_VERSION then |
422 -- db[entry] = {} | 423 for entry in pairs(DATABASE_DEFAULTS.global) do |
423 -- end | 424 db[entry] = {} |
424 -- end | 425 end |
426 end | |
425 raw_db.build_num = build_num | 427 raw_db.build_num = build_num |
426 raw_db.version = DB_VERSION | 428 raw_db.version = DB_VERSION |
427 end | 429 end |
428 | 430 |
429 | 431 |
430 function WDP:OnEnable() | 432 function WDP:OnEnable() |
431 -- TODO: Remove this once 5.0.4 hits Live. | |
432 if private.wow_version == "4.3.4" then | |
433 return | |
434 end | |
435 | |
436 for event_name, mapping in pairs(EVENT_MAPPING) do | 433 for event_name, mapping in pairs(EVENT_MAPPING) do |
437 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil) | 434 self:RegisterEvent(event_name, (_G.type(mapping) ~= "boolean") and mapping or nil) |
438 end | 435 end |
439 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30) | 436 durability_timer_handle = self:ScheduleRepeatingTimer("ProcessDurability", 30) |
440 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5) | 437 target_location_timer_handle = self:ScheduleRepeatingTimer("UpdateTargetLocation", 0.5) |