comparison Main.lua @ 35:b0264b73986e

Fixed client lockup in MoP Beta. Commented out wipe of DB when detecting a new WoW build, since the sheer number of builds during beta makes this feature an annoyance.
author James D. Callahan III <jcallahan@curse.com>
date Thu, 07 Jun 2012 13:34:01 -0500
parents 2a094108d89b
children 1c30568085db
comparison
equal deleted inserted replaced
34:2a094108d89b 35:b0264b73986e
40 local EVENT_MAPPING = { 40 local EVENT_MAPPING = {
41 COMBAT_LOG_EVENT_UNFILTERED = true, 41 COMBAT_LOG_EVENT_UNFILTERED = true,
42 COMBAT_TEXT_UPDATE = true, 42 COMBAT_TEXT_UPDATE = true,
43 LOOT_OPENED = true, 43 LOOT_OPENED = true,
44 MERCHANT_SHOW = "UpdateMerchantItems", 44 MERCHANT_SHOW = "UpdateMerchantItems",
45 MERCHANT_UPDATE = "UpdateMerchantItems", 45 -- MERCHANT_UPDATE = "UpdateMerchantItems",
46 PET_BAR_UPDATE = true, 46 PET_BAR_UPDATE = true,
47 PLAYER_TARGET_CHANGED = true, 47 PLAYER_TARGET_CHANGED = true,
48 QUEST_COMPLETE = true, 48 QUEST_COMPLETE = true,
49 QUEST_DETAIL = true, 49 QUEST_DETAIL = true,
50 QUEST_LOG_UPDATE = true, 50 QUEST_LOG_UPDATE = true,
313 313
314 local raw_db = _G["WoWDBProfilerData"] 314 local raw_db = _G["WoWDBProfilerData"]
315 315
316 local build_num = tonumber(private.build_num) 316 local build_num = tonumber(private.build_num)
317 317
318 if raw_db.build_num and raw_db.build_num < build_num then 318 -- TODO: Un-comment this when MoP goes live.
319 for entry in pairs(DATABASE_DEFAULTS.global) do 319 -- if raw_db.build_num and raw_db.build_num < build_num then
320 db[entry] = {} 320 -- for entry in pairs(DATABASE_DEFAULTS.global) do
321 end 321 -- db[entry] = {}
322 raw_db.build_num = build_num 322 -- end
323 elseif not raw_db.build_num then 323 -- end
324 raw_db.build_num = build_num 324 raw_db.build_num = build_num
325 end
326 end 325 end
327 326
328 327
329 function WDP:OnEnable() 328 function WDP:OnEnable()
330 for event_name, mapping in pairs(EVENT_MAPPING) do 329 for event_name, mapping in pairs(EVENT_MAPPING) do
674 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary 673 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_5V5:gsub("%%d", "(%%d+)")), -- May no longer be necessary
675 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")), 674 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_BG:gsub("%%d", "(%%d+)")),
676 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")), 675 ("^%s$"):format(_G.ITEM_REQ_ARENA_RATING_3V3_BG:gsub("%%d", "(%%d+)")),
677 } 676 }
678 677
679 678 function WDP:UpdateMerchantItems(event)
680 function WDP:UpdateMerchantItems()
681 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target")) 679 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("target"))
682 680
683 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then 681 if unit_type ~= private.UNIT_TYPES.NPC or not unit_idnum then
684 return 682 return
685 end 683 end
686 local merchant = NPCEntry(unit_idnum) 684 local merchant = NPCEntry(unit_idnum)
687 merchant.sells = merchant.sells or {} 685 merchant.sells = merchant.sells or {}
688 686
689 for item_index = 1, _G.GetMerchantNumItems() do 687 local num_items = _G.GetMerchantNumItems()
688
689 for item_index = 1, num_items do
690 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) 690 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index)
691 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) 691 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
692 692
693 if item_id and item_id > 0 then 693 if item_id and item_id > 0 then
694 local price_string = copper_price 694 local price_string = copper_price
701 DatamineTT:SetMerchantItem(item_index) 701 DatamineTT:SetMerchantItem(item_index)
702 702
703 for line_index = 1, DatamineTT:NumLines() do 703 for line_index = 1, DatamineTT:NumLines() do
704 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] 704 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
705 705
706 if not current_line then 706 if not current_line then
707 break 707 break
708 end 708 end
709 local breakout 709 local breakout
710 710
711 for match_index = 1, #POINT_MATCH_PATTERNS do 711 for match_index = 1, #POINT_MATCH_PATTERNS do
722 if breakout then 722 if breakout then
723 break 723 break
724 end 724 end
725 end 725 end
726 local currency_list = {} 726 local currency_list = {}
727 727 local item_count = _G.GetMerchantItemCostInfo(item_index)
728 price_string = ("%s:%s:%s"):format(price_string, bg_points, personal_points) 728 price_string = ("%s:%s:%s"):format(price_string, bg_points, personal_points)
729 729
730 for cost_index = 1, _G.GetMerchantItemCostInfo(item_index) do 730 for cost_index = 1, item_count do
731 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index) 731 local icon_texture, amount_required, currency_link = _G.GetMerchantItemCostItem(item_index, cost_index)
732 local currency_id = currency_link and ItemLinkToID(currency_link) or nil 732 local currency_id = currency_link and ItemLinkToID(currency_link) or nil
733 733
734 if not currency_id or currency_id < 1 then 734 if (not currency_id or currency_id < 1) and icon_texture then
735 if not icon_texture then
736 return
737 end
738 currency_id = icon_texture:match("[^\\]+$"):lower() 735 currency_id = icon_texture:match("[^\\]+$"):lower()
739 end 736 end
740 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id) 737
738 if currency_id then
739 currency_list[#currency_list + 1] = ("(%s:%s)"):format(amount_required, currency_id)
740 end
741 end 741 end
742 742
743 for currency_index = 1, #currency_list do 743 for currency_index = 1, #currency_list do
744 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) 744 price_string = ("%s:%s"):format(price_string, currency_list[currency_index])
745 end 745 end