Mercurial > wow > wowdb-profiler
comparison Main.lua @ 128:b06147ded0bc
Added recording of blacklisted battlegrounds.
author | James D. Callahan III <jcallahan@curse.com> |
---|---|
date | Wed, 19 Sep 2012 09:29:56 -0500 |
parents | f0c0819058b4 |
children | e0550c57972d |
comparison
equal
deleted
inserted
replaced
127:6f48d374cda5 | 128:b06147ded0bc |
---|---|
33 ----------------------------------------------------------------------- | 33 ----------------------------------------------------------------------- |
34 local DB_VERSION = 6 | 34 local DB_VERSION = 6 |
35 | 35 |
36 | 36 |
37 local DATABASE_DEFAULTS = { | 37 local DATABASE_DEFAULTS = { |
38 char = {}, | |
38 global = { | 39 global = { |
39 items = {}, | 40 items = {}, |
40 npcs = {}, | 41 npcs = {}, |
41 objects = {}, | 42 objects = {}, |
42 quests = {}, | 43 quests = {}, |
114 ----------------------------------------------------------------------- | 115 ----------------------------------------------------------------------- |
115 -- Local variables. | 116 -- Local variables. |
116 ----------------------------------------------------------------------- | 117 ----------------------------------------------------------------------- |
117 local anvil_spell_ids = {} | 118 local anvil_spell_ids = {} |
118 local currently_drunk | 119 local currently_drunk |
119 local db | 120 local char_db |
121 local global_db | |
120 local durability_timer_handle | 122 local durability_timer_handle |
121 local faction_standings = {} | 123 local faction_standings = {} |
122 local forge_spell_ids = {} | 124 local forge_spell_ids = {} |
123 local languages_known = {} | 125 local languages_known = {} |
124 local name_to_id_map = {} | 126 local name_to_id_map = {} |
199 | 201 |
200 local function DBEntry(data_type, unit_id) | 202 local function DBEntry(data_type, unit_id) |
201 if not data_type or not unit_id then | 203 if not data_type or not unit_id then |
202 return | 204 return |
203 end | 205 end |
204 local unit = db[data_type][unit_id] | 206 local unit = global_db[data_type][unit_id] |
205 | 207 |
206 if not unit then | 208 if not unit then |
207 db[data_type][unit_id] = {} | 209 global_db[data_type][unit_id] = {} |
208 unit = db[data_type][unit_id] | 210 unit = global_db[data_type][unit_id] |
209 end | 211 end |
210 return unit | 212 return unit |
211 end | 213 end |
212 | 214 |
213 | 215 |
285 return unit_type, tonumber(guid:sub(6, 10), 16) | 287 return unit_type, tonumber(guid:sub(6, 10), 16) |
286 end | 288 end |
287 return unit_type | 289 return unit_type |
288 end | 290 end |
289 end -- do-block | 291 end -- do-block |
292 | |
293 | |
294 local function UpdateBlacklistMaps() | |
295 local empty_count = 0 | |
296 | |
297 for index = 1, _G.MAX_BLACKLIST_BATTLEGROUNDS do | |
298 local map_id = _G.GetBlacklistMap(index) | |
299 char_db.bg_blacklist = char_db.bg_blacklist or {} | |
300 char_db.bg_blacklist[index] = map_id | |
301 | |
302 if map_id < 0 then | |
303 empty_count = empty_count + 1 | |
304 end | |
305 end | |
306 | |
307 if empty_count == _G.MAX_BLACKLIST_BATTLEGROUNDS then | |
308 char_db.bg_blacklist = nil | |
309 end | |
310 end | |
290 | 311 |
291 | 312 |
292 local function UpdateDBEntryLocation(entry_type, identifier) | 313 local function UpdateDBEntryLocation(entry_type, identifier) |
293 if not identifier then | 314 if not identifier then |
294 return | 315 return |
524 | 545 |
525 ----------------------------------------------------------------------- | 546 ----------------------------------------------------------------------- |
526 -- Methods. | 547 -- Methods. |
527 ----------------------------------------------------------------------- | 548 ----------------------------------------------------------------------- |
528 function WDP:OnInitialize() | 549 function WDP:OnInitialize() |
529 db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default").global | 550 local db = LibStub("AceDB-3.0"):New("WoWDBProfilerData", DATABASE_DEFAULTS, "Default") |
551 global_db = db.global | |
552 char_db = db.char | |
530 | 553 |
531 local raw_db = _G["WoWDBProfilerData"] | 554 local raw_db = _G["WoWDBProfilerData"] |
532 local build_num = tonumber(private.build_num) | 555 local build_num = tonumber(private.build_num) |
533 | 556 |
534 -- TODO: Merge this with the DB version check when MoP goes live. | 557 -- TODO: Merge this with the DB version check when MoP goes live. |
535 -- if raw_db.build_num and raw_db.build_num < build_num then | 558 -- if raw_db.build_num and raw_db.build_num < build_num then |
536 if raw_db.version and raw_db.version < DB_VERSION then | 559 if raw_db.version and raw_db.version < DB_VERSION then |
537 for entry in pairs(DATABASE_DEFAULTS.global) do | 560 for entry in pairs(DATABASE_DEFAULTS.global) do |
538 db[entry] = {} | 561 global_db[entry] = {} |
539 end | 562 end |
540 end | 563 end |
541 raw_db.build_num = build_num | 564 raw_db.build_num = build_num |
542 raw_db.version = DB_VERSION | 565 raw_db.version = DB_VERSION |
543 end | 566 end |
566 return | 589 return |
567 end | 590 end |
568 local _, item_link = _G.GetItemInfo(identifier) | 591 local _, item_link = _G.GetItemInfo(identifier) |
569 HandleItemUse(item_link) | 592 HandleItemUse(item_link) |
570 end) | 593 end) |
571 | |
572 SetCurrentAreaID() | 594 SetCurrentAreaID() |
595 | |
596 _G.hooksecurefunc("SetBlacklistMap", UpdateBlacklistMaps) | |
597 _G.hooksecurefunc("ClearBlacklistMap", UpdateBlacklistMaps) | |
598 | |
599 UpdateBlacklistMaps() | |
573 end | 600 end |
574 | 601 |
575 | 602 |
576 local function RecordDurability(item_id, durability) | 603 local function RecordDurability(item_id, durability) |
577 if not durability or durability <= 0 then | 604 if not durability or durability <= 0 then |
578 return | 605 return |
579 end | 606 end |
580 | 607 |
581 if not db.items[item_id] then | 608 if not global_db.items[item_id] then |
582 db.items[item_id] = {} | 609 global_db.items[item_id] = {} |
583 end | 610 end |
584 db.items[item_id].durability = durability | 611 global_db.items[item_id].durability = durability |
585 end | 612 end |
586 | 613 |
587 | 614 |
588 function WDP:ProcessDurability() | 615 function WDP:ProcessDurability() |
589 for slot_index = 0, _G.INVSLOT_LAST_EQUIPPED do | 616 for slot_index = 0, _G.INVSLOT_LAST_EQUIPPED do |
1595 end | 1622 end |
1596 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill) | 1623 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill) |
1597 end | 1624 end |
1598 end | 1625 end |
1599 end | 1626 end |
1600 | |
1601 -- Reset the filters to what they were before | 1627 -- Reset the filters to what they were before |
1602 _G.SetTrainerServiceTypeFilter("available", available or 0) | 1628 _G.SetTrainerServiceTypeFilter("available", available or 0) |
1603 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0) | 1629 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0) |
1604 _G.SetTrainerServiceTypeFilter("used", used or 0) | 1630 _G.SetTrainerServiceTypeFilter("used", used or 0) |
1605 end | 1631 end |