comparison Main.lua @ 581:78e9cbbf3d58 11.0.2-1

Updated for Patch 11.0.2 changes.
author MMOSimca
date Tue, 20 Aug 2024 09:42:51 -0400
parents 89fab01eaba0
children
comparison
equal deleted inserted replaced
580:211556c5167b 581:78e9cbbf3d58
14 local select = _G.select 14 local select = _G.select
15 local type = _G.type 15 local type = _G.type
16 local unpack = _G.unpack 16 local unpack = _G.unpack
17 17
18 local C_Timer = _G.C_Timer 18 local C_Timer = _G.C_Timer
19 local C_Spell = _G.C_Spell
19 local GetCurrencyInfo = _G.GetCurrencyInfo 20 local GetCurrencyInfo = _G.GetCurrencyInfo
20 21
21 22
22 -- ADDON NAMESPACE ---------------------------------------------------- 23 -- ADDON NAMESPACE ----------------------------------------------------
23 24
46 local DELAY_PROCESS_WORLD_QUESTS = 90 47 local DELAY_PROCESS_WORLD_QUESTS = 90
47 local DELAY_UPDATE_TARGET_LOCATION = 0.5 48 local DELAY_UPDATE_TARGET_LOCATION = 0.5
48 49
49 local ITEM_ID_TIMBER = 114781 50 local ITEM_ID_TIMBER = 114781
50 51
51 local LOOT_SLOT_CURRENCY = _G.LOOT_SLOT_CURRENCY 52 local ENUM_LOOTSLOTTYPE_CURRENCY = _G.Enum.LootSlotType.Currency
52 local LOOT_SLOT_ITEM = _G.LOOT_SLOT_ITEM 53 local ENUM_LOOTSLOTTYPE_ITEM = _G.Enum.LootSlotType.Item
53 local LOOT_SLOT_MONEY = _G.LOOT_SLOT_MONEY 54 local ENUM_LOOTSLOTTYPE_MONEY = _G.Enum.LootSlotType.Money
54 55
55 --local LOOT_SOURCE_ID_UNKNOWN = 1 -- Technically unused right now, but has future use potential 56 --local LOOT_SOURCE_ID_UNKNOWN = 1 -- Technically unused right now, but has future use potential
56 --local LOOT_SOURCE_ID_REDUNDANT = 3 -- Technically unused right now, but has future use potential 57 --local LOOT_SOURCE_ID_REDUNDANT = 3 -- Technically unused right now, but has future use potential
57 local LOOT_SOURCE_ID_GARRISON_CACHE = 10 58 local LOOT_SOURCE_ID_GARRISON_CACHE = 10
58 59
110 CHAT_MSG_MONSTER_WHISPER = "RecordQuote", 111 CHAT_MSG_MONSTER_WHISPER = "RecordQuote",
111 CHAT_MSG_MONSTER_YELL = "RecordQuote", 112 CHAT_MSG_MONSTER_YELL = "RecordQuote",
112 CHAT_MSG_SYSTEM = true, 113 CHAT_MSG_SYSTEM = true,
113 COMBAT_LOG_EVENT_UNFILTERED = true, 114 COMBAT_LOG_EVENT_UNFILTERED = true,
114 COMBAT_TEXT_UPDATE = true, 115 COMBAT_TEXT_UPDATE = true,
115 CURSOR_UPDATE = true, 116 WORLD_CURSOR_TOOLTIP_UPDATE = true,
116 GARRISON_MISSION_NPC_CLOSED = "ResumeChatLootRecording", 117 GARRISON_MISSION_NPC_CLOSED = "ResumeChatLootRecording",
117 GARRISON_MISSION_NPC_OPENED = "StopChatLootRecording", 118 GARRISON_MISSION_NPC_OPENED = "StopChatLootRecording",
118 GARRISON_SHIPYARD_NPC_CLOSED = "ResumeChatLootRecording", 119 GARRISON_SHIPYARD_NPC_CLOSED = "ResumeChatLootRecording",
119 GARRISON_SHIPYARD_NPC_OPENED = "StopChatLootRecording", 120 GARRISON_SHIPYARD_NPC_OPENED = "StopChatLootRecording",
120 GOSSIP_CLOSED = "ResumeChatLootRecording", 121 GOSSIP_CLOSED = "ResumeChatLootRecording",
123 GUILDBANKFRAME_CLOSED = "ResumeChatLootRecording", 124 GUILDBANKFRAME_CLOSED = "ResumeChatLootRecording",
124 GUILDBANKFRAME_OPENED = true, -- also triggers StopChatLootRecording 125 GUILDBANKFRAME_OPENED = true, -- also triggers StopChatLootRecording
125 ISLAND_AZERITE_GAIN = true, 126 ISLAND_AZERITE_GAIN = true,
126 ISLAND_COMPLETED = true, 127 ISLAND_COMPLETED = true,
127 ITEM_TEXT_BEGIN = true, 128 ITEM_TEXT_BEGIN = true,
128 ITEM_UPGRADE_MASTER_OPENED = true,
129 LOOT_CLOSED = true, 129 LOOT_CLOSED = true,
130 LOOT_OPENED = true, 130 LOOT_OPENED = true,
131 LOOT_SLOT_CLEARED = "HandleBadChatLootData", 131 LOOT_SLOT_CLEARED = "HandleBadChatLootData",
132 MAIL_CLOSED = "ResumeChatLootRecording", 132 MAIL_CLOSED = "ResumeChatLootRecording",
133 MAIL_SHOW = true, -- also triggers StopChatLootRecording 133 MAIL_SHOW = true, -- also triggers StopChatLootRecording
146 SHOW_LOOT_TOAST = true, 146 SHOW_LOOT_TOAST = true,
147 SPELL_CONFIRMATION_PROMPT = true, 147 SPELL_CONFIRMATION_PROMPT = true,
148 TAXIMAP_OPENED = true, 148 TAXIMAP_OPENED = true,
149 TRADE_CLOSED = "ResumeChatLootRecording", 149 TRADE_CLOSED = "ResumeChatLootRecording",
150 TRADE_SHOW = "StopChatLootRecording", 150 TRADE_SHOW = "StopChatLootRecording",
151 TRADE_SKILL_SHOW = true, 151 --TRADE_SKILL_SHOW = true,
152 TRAINER_CLOSED = true, 152 --TRAINER_CLOSED = true,
153 TRAINER_SHOW = true, 153 --TRAINER_SHOW = true,
154 TRANSMOGRIFY_OPEN = true,
155 UNIT_PET = true, 154 UNIT_PET = true,
156 UNIT_QUEST_LOG_CHANGED = true, 155 UNIT_QUEST_LOG_CHANGED = true,
157 UNIT_SPELLCAST_FAILED = "HandleSpellFailure", 156 UNIT_SPELLCAST_FAILED = "HandleSpellFailure",
158 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure", 157 UNIT_SPELLCAST_FAILED_QUIET = "HandleSpellFailure",
159 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure", 158 UNIT_SPELLCAST_INTERRUPTED = "HandleSpellFailure",
160 UNIT_SPELLCAST_SENT = true, 159 UNIT_SPELLCAST_SENT = true,
161 UNIT_SPELLCAST_SUCCEEDED = true, 160 UNIT_SPELLCAST_SUCCEEDED = true,
162 VOID_STORAGE_OPEN = true, 161 PLAYER_INTERACTION_MANAGER_FRAME_SHOW = true,
163 } 162 }
164 163
165 164
166 -- VARIABLES ---------------------------------------------------------- 165 -- VARIABLES ----------------------------------------------------------
167 166
554 end 553 end
555 local item_id = ItemLinkToID(item_link) 554 local item_id = ItemLinkToID(item_link)
556 555
557 if not bag_index or not slot_index then 556 if not bag_index or not slot_index then
558 for new_bag_index = 0, _G.NUM_BAG_FRAMES do 557 for new_bag_index = 0, _G.NUM_BAG_FRAMES do
559 for new_slot_index = 1, _G.GetContainerNumSlots(new_bag_index) do 558 for new_slot_index = 1, _G.C_Container.GetContainerNumSlots(new_bag_index) do
560 if item_id == ItemLinkToID(_G.GetContainerItemLink(new_bag_index, new_slot_index)) then 559 if item_id == ItemLinkToID(_G.C_Container.GetContainerItemLink(new_bag_index, new_slot_index)) then
561 bag_index = new_bag_index 560 bag_index = new_bag_index
562 slot_index = new_slot_index 561 slot_index = new_slot_index
563 break 562 break
564 end 563 end
565 end 564 end
568 567
569 local any_loot = false 568 local any_loot = false
570 569
571 -- Check if Blizzard has marked this item as officially having a chance of containing loot 570 -- Check if Blizzard has marked this item as officially having a chance of containing loot
572 if bag_index and slot_index then 571 if bag_index and slot_index then
573 local _, _, _, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index) 572 local _, _, _, _, _, is_lootable = _G.C_Container.GetContainerItemInfo(bag_index, slot_index)
574 if is_lootable then 573 if is_lootable then
575 any_loot = true 574 any_loot = true
576 end 575 end
577 end 576 end
578 577
635 end 634 end
636 635
637 636
638 function UpdateFactionData() 637 function UpdateFactionData()
639 for faction_index = 1, MAX_FACTION_INDEX do 638 for faction_index = 1, MAX_FACTION_INDEX do
640 local faction_name, _, current_standing, _, _, _, _, _, is_header = _G.GetFactionInfo(faction_index) 639 local faction_table = _G.C_Reputation.GetFactionDataByIndex(faction_index)
641 640
642 if faction_name then 641 if faction_table then
643 faction_standings[faction_name] = STANDING_NAMES[current_standing] 642 if faction_table.name then
644 elseif not faction_name then 643 faction_standings[faction_table.name] = STANDING_NAMES[faction_table.currentStanding]
645 break 644 elseif not faction_table.name then
646 end 645 break
646 end
647 end
647 end 648 end
648 end 649 end
649 end -- do-block 650 end -- do-block
650 651
651 652
963 -- These timers loop indefinitely using Lua's infinity constant 964 -- These timers loop indefinitely using Lua's infinity constant
964 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, nil) 965 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, nil)
965 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, nil) 966 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, nil)
966 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, nil) 967 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, nil)
967 968
968 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) 969 _G.hooksecurefunc(C_Container, "UseContainerItem", function(bag_index, slot_index, target_unit)
969 if target_unit then 970 if target_unit then
970 return 971 return
971 end 972 end
972 HandleItemUse(_G.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index) 973 HandleItemUse(_G.C_Container.GetContainerItemLink(bag_index, slot_index), bag_index, slot_index)
973 end) 974 end)
974 975
975 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit) 976 _G.hooksecurefunc("UseItemByName", function(identifier, target_unit)
976 if target_unit then 977 if target_unit then
977 return 978 return
1175 RecordItemData(item_id, _G.GetInventoryItemLink("player", slot_index), false, max_durability) 1176 RecordItemData(item_id, _G.GetInventoryItemLink("player", slot_index), false, max_durability)
1176 end 1177 end
1177 end 1178 end
1178 1179
1179 for bag_index = 0, _G.NUM_BAG_SLOTS do 1180 for bag_index = 0, _G.NUM_BAG_SLOTS do
1180 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do 1181 for slot_index = 1, _G.C_Container.GetContainerNumSlots(bag_index) do
1181 local item_id = _G.GetContainerItemID(bag_index, slot_index) 1182 local item_id = _G.C_Container.GetContainerItemID(bag_index, slot_index)
1182 1183
1183 if item_id and item_id > 0 then 1184 if item_id and item_id > 0 then
1184 local _, max_durability = _G.GetContainerItemDurability(bag_index, slot_index) 1185 local _, max_durability = _G.C_Container.GetContainerItemDurability(bag_index, slot_index)
1185 RecordItemData(item_id, _G.GetContainerItemLink(bag_index, slot_index), false, max_durability) 1186 RecordItemData(item_id, _G.C_Container.GetContainerItemLink(bag_index, slot_index), false, max_durability)
1186 end 1187 end
1187 end 1188 end
1188 end 1189 end
1189 end 1190 end
1190 1191
1938 end 1939 end
1939 1940
1940 -- Determine faction ID 1941 -- Determine faction ID
1941 local faction_ID 1942 local faction_ID
1942 for pseudo_faction_name, faction_data_table in pairs(private.FACTION_DATA) do 1943 for pseudo_faction_name, faction_data_table in pairs(private.FACTION_DATA) do
1943 if faction_name == faction_data_table[3] then 1944 if faction_data_table[3] and faction_data_table[3].currentStanding and faction_name == faction_data_table[3].currentStanding then
1944 -- Check ignore flag 1945 -- Check ignore flag
1945 if faction_data_table[2] then 1946 if faction_data_table[2] then
1946 return 1947 return
1947 end 1948 end
1948 faction_ID = faction_data_table[1] 1949 faction_ID = faction_data_table[1]
1949 break 1950 break
1950 end 1951 end
1951 end 1952 end
1952 if faction_ID and faction_ID > 0 then 1953 if faction_ID and faction_ID > 0 then
1953 -- Check for modifiers from Commendations (applied directly to the faction, account-wide) 1954 -- Check for modifiers from Commendations (applied directly to the faction, account-wide)
1954 local _, _, _, _, _, _, _, _, _, _, _, _, _, _, has_bonus_rep_gain = GetFactionInfoByID(faction_ID) 1955 local factionReturn = _G.C_Reputation.GetFactionDataByID(faction_ID)
1955 if has_bonus_rep_gain then 1956 if factionReturn and factionReturn.hasBonusRepGain then
1956 modifier = modifier + 1 1957 modifier = modifier + 1
1957 end 1958 end
1958 end 1959 end
1959 1960
1960 -- Check for modifiers from buffs 1961 -- Check for modifiers from buffs
1978 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier) 1979 npc.reputations[("%s:%s"):format(faction_name, faction_standings[faction_name])] = math.floor(amount / modifier)
1979 end 1980 end
1980 end -- do-block 1981 end -- do-block
1981 1982
1982 1983
1983 function WDP:CURSOR_UPDATE(event_name) 1984 function WDP:WORLD_CURSOR_TOOLTIP_UPDATE(event_name, is_shown)
1984 if current_action.fishing_target or _G.Minimap:IsMouseOver() then 1985 if current_action.fishing_target or _G.Minimap:IsMouseOver() then
1985 return 1986 return
1986 end 1987 end
1987 local text = _G["GameTooltipTextLeft1"]:GetText() 1988 local text = _G["GameTooltipTextLeft1"]:GetText()
1988 1989
2016 -- Item containers can be AOE-looted in Patch 5.4.2 if the user clicks fast enough, but this verification still works as long as they both have loot. 2017 -- Item containers can be AOE-looted in Patch 5.4.2 if the user clicks fast enough, but this verification still works as long as they both have loot.
2017 [AF.ITEM] = function() 2018 [AF.ITEM] = function()
2018 local locked_item_id 2019 local locked_item_id
2019 2020
2020 for bag_index = 0, _G.NUM_BAG_FRAMES do 2021 for bag_index = 0, _G.NUM_BAG_FRAMES do
2021 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do 2022 for slot_index = 1, _G.C_Container.GetContainerNumSlots(bag_index) do
2022 local _, _, is_locked, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index) 2023 local _, _, is_locked, _, _, is_lootable = _G.C_Container.GetContainerItemInfo(bag_index, slot_index)
2023 2024
2024 if is_locked and is_lootable then 2025 if is_locked and is_lootable then
2025 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index)) 2026 locked_item_id = ItemLinkToID(_G.C_Container.GetContainerItemLink(bag_index, slot_index))
2026 break 2027 break
2027 end 2028 end
2028 end 2029 end
2029 2030
2030 if locked_item_id then 2031 if locked_item_id then
2290 2291
2291 InitializeCurrentLoot() 2292 InitializeCurrentLoot()
2292 loot_guid_registry[current_loot.label] = loot_guid_registry[current_loot.label] or {} 2293 loot_guid_registry[current_loot.label] = loot_guid_registry[current_loot.label] or {}
2293 2294
2294 for loot_slot = 1, _G.GetNumLootItems() do 2295 for loot_slot = 1, _G.GetNumLootItems() do
2295 local texture_filedata_id, item_text, slot_quantity, quality, locked = _G.GetLootSlotInfo(loot_slot) 2296 local texture_filedata_id, item_text, slot_quantity, _, locked = _G.GetLootSlotInfo(loot_slot)
2296 local slot_type = _G.GetLootSlotType(loot_slot) 2297 local slot_type = _G.GetLootSlotType(loot_slot)
2297 local loot_info = { _G.GetLootSourceInfo(loot_slot) } 2298 local loot_info = { _G.GetLootSourceInfo(loot_slot) }
2298 local loot_link = _G.GetLootSlotLink(loot_slot) 2299 local loot_link = _G.GetLootSlotLink(loot_slot)
2299 2300
2300 -- Odd index is GUID, even is count. 2301 -- Odd index is GUID, even is count.
2310 loot_quantity = slot_quantity 2311 loot_quantity = slot_quantity
2311 end 2312 end
2312 local source_type, source_id = ParseGUID(source_guid) 2313 local source_type, source_id = ParseGUID(source_guid)
2313 local source_key = ("%s:%d"):format(source_type, source_id) 2314 local source_key = ("%s:%d"):format(source_type, source_id)
2314 2315
2315 if slot_type == LOOT_SLOT_ITEM then 2316 if slot_type == ENUM_LOOTSLOTTYPE_ITEM then
2316 if loot_link then 2317 if loot_link then
2317 local item_id = ItemLinkToID(loot_link) 2318 local item_id = ItemLinkToID(loot_link)
2318 Debug("GUID: %s - Type:ID: %s - ItemID: %d - Amount: %d (%d)", loot_info[loot_index], source_key, item_id, loot_info[loot_index + 1], slot_quantity) 2319 Debug("GUID: %s - Type:ID: %s - ItemID: %d - Amount: %d (%d)", loot_info[loot_index], source_key, item_id, loot_info[loot_index + 1], slot_quantity)
2319 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 2320 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
2320 current_loot.sources[source_guid][item_id] = (current_loot.sources[source_guid][item_id] or 0) + loot_quantity 2321 current_loot.sources[source_guid][item_id] = (current_loot.sources[source_guid][item_id] or 0) + loot_quantity
2321 guids_used[source_guid] = true 2322 guids_used[source_guid] = true
2322 else 2323 else
2323 Debug("%s: Loot link is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key) 2324 Debug("%s: Loot link is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key)
2324 end 2325 end
2325 elseif slot_type == LOOT_SLOT_MONEY then 2326 elseif slot_type == ENUM_LOOTSLOTTYPE_MONEY then
2326 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity) 2327 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity)
2327 if current_loot.target_type == AF.ZONE then 2328 if current_loot.target_type == AF.ZONE then
2328 table.insert(current_loot.list, ("money:%d"):format(loot_quantity)) 2329 table.insert(current_loot.list, ("money:%d"):format(loot_quantity))
2329 else 2330 else
2330 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 2331 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
2331 current_loot.sources[source_guid]["money"] = (current_loot.sources[source_guid]["money"] or 0) + loot_quantity 2332 current_loot.sources[source_guid]["money"] = (current_loot.sources[source_guid]["money"] or 0) + loot_quantity
2332 guids_used[source_guid] = true 2333 guids_used[source_guid] = true
2333 end 2334 end
2334 elseif slot_type == LOOT_SLOT_CURRENCY then 2335 elseif slot_type == ENUM_LOOTSLOTTYPE_CURRENCY then
2335 -- Same bug with GetLootSlotInfo() will screw up currency when it happens, so we won't process this slot's loot. 2336 -- Same bug with GetLootSlotInfo() will screw up currency when it happens, so we won't process this slot's loot.
2336 if loot_link then 2337 if loot_link then
2337 local currency_id = CurrencyLinkToID(loot_link) 2338 local currency_id = CurrencyLinkToID(loot_link)
2338 Debug("GUID: %s - Type:ID: %s - Currency: %d - Amount: %d (%d)", loot_info[loot_index], source_key, currency_id, loot_info[loot_index + 1], slot_quantity) 2339 Debug("GUID: %s - Type:ID: %s - Currency: %d - Amount: %d (%d)", loot_info[loot_index], source_key, currency_id, loot_info[loot_index + 1], slot_quantity)
2339 if current_loot.target_type == AF.ZONE then 2340 if current_loot.target_type == AF.ZONE then
2346 guids_used[source_guid] = true 2347 guids_used[source_guid] = true
2347 end 2348 end
2348 else 2349 else
2349 Debug("%s: Loot link is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key) 2350 Debug("%s: Loot link is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key)
2350 end 2351 end
2352 else
2353 Debug("Unknown LootSlotType %d. GUID: %s - Type:ID: %s - Loot Slot: %d - Loot Link: %s", slot_type, loot_info[loot_index], source_key, loot_slot, loot_link or "")
2351 end 2354 end
2352 else 2355 else
2353 -- If this is nil, then the item's quantity could be wrong if loot_quantity is wrong, so we won't process this slot's loot. 2356 -- If this is nil, then the item's quantity could be wrong if loot_quantity is wrong, so we won't process this slot's loot.
2354 Debug("%s: Slot quantity is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key) 2357 Debug("%s: Slot quantity is nil for loot slot %d of the entity with GUID %s and Type:ID: %s.", event_name, loot_slot, loot_info[loot_index], source_key)
2355 end 2358 end
2497 2500
2498 for cost_index = 1, item_count do 2501 for cost_index = 1, item_count do
2499 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. 2502 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0.
2500 local texture_id, amount_required, hyperlink, name = _G.GetMerchantItemCostItem(item_index, cost_index) 2503 local texture_id, amount_required, hyperlink, name = _G.GetMerchantItemCostItem(item_index, cost_index)
2501 2504
2502 -- Try to get item ID 2505 if hyperlink then
2503 local item_id = ItemLinkToID(hyperlink) 2506 -- Try to get item ID
2504 2507 local item_id = ItemLinkToID(hyperlink)
2505 -- FUTURE: At some point, we should make the output from these two cases (item_id vs currency_id) slightly different, so that WoWDB doesn't have to guess if it is a currency or item 2508
2506 -- Handle cases when the additional cost is another item 2509 -- FUTURE: At some point, we should make the output from these two cases (item_id vs currency_id) slightly different, so that WoWDB doesn't have to guess if it is a currency or item
2507 if item_id and item_id > 0 then 2510 -- Handle cases when the additional cost is another item
2508 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id) 2511 if item_id and item_id > 0 then
2509 else 2512 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id)
2510 -- Try to get currency ID 2513 else
2511 local currency_id = CurrencyLinkToID(hyperlink) 2514 -- Try to get currency ID
2512 if currency_id and currency_id > 0 then 2515 local currency_id = CurrencyLinkToID(hyperlink)
2513 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) 2516 if currency_id and currency_id > 0 then
2514 else 2517 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id)
2515 Debug("UpdateMerchantItems: Failed to get item ID and failed to get currency ID for item index %d and cost index %d", item_index, cost_index) 2518 else
2516 end 2519 Debug("UpdateMerchantItems: Failed to get item ID and failed to get currency ID for item index %d and cost index %d with hyperlink %s", item_index, cost_index, hyperlink)
2517 end 2520 end
2521 end
2522 end
2518 end 2523 end
2519 2524
2520 for currency_index = 1, #currency_list do 2525 for currency_index = 1, #currency_list do
2521 price_string = ("%s:%s"):format(price_string, currency_list[currency_index]) 2526 price_string = ("%s:%s"):format(price_string, currency_list[currency_index])
2522 end 2527 end
2649 end 2654 end
2650 end -- do-block 2655 end -- do-block
2651 2656
2652 2657
2653 function WDP:QUEST_LOG_UPDATE(event_name) 2658 function WDP:QUEST_LOG_UPDATE(event_name)
2654 local selected_quest = _G.GetQuestLogSelection() -- Save current selection to be restored when we're done. 2659 local selected_quest = _G.C_QuestLog.GetSelectedQuest() -- Save current selection to be restored when we're done.
2655 local entry_index, processed_quests = 1, 0 2660 local entry_index, processed_quests = 1, 0
2656 local _, num_quests = _G.GetNumQuestLogEntries() 2661 local _, num_quests = _G.C_QuestLog.GetNumQuestLogEntries()
2657 2662
2658 while processed_quests <= num_quests do 2663 while processed_quests <= num_quests do
2659 local _, _, _, is_header, _, _, _, quest_id = _G.GetQuestLogTitle(entry_index) 2664 local info = _G.C_QuestLog.GetInfo(entry_index)
2660 2665
2661 if quest_id == 0 then 2666 if info.questID == 0 then
2662 processed_quests = processed_quests + 1 2667 processed_quests = processed_quests + 1
2663 elseif not is_header then 2668 elseif not info.isHeader then
2664 _G.SelectQuestLogEntry(entry_index); 2669 _G.C_QuestLog.SetSelectedQuest(entry_index);
2665 2670
2666 local quest = DBEntry("quests", quest_id) 2671 local quest = DBEntry("quests", info.questID)
2667 quest.timer = _G.GetQuestLogTimeLeft() 2672 quest.timer = _G.GetQuestLogTimeLeft()
2668 quest.can_share = _G.GetQuestLogPushable() and true or nil 2673 quest.can_share = _G.C_QuestLog.IsPushableQuest(info.questID) and true or nil
2669 processed_quests = processed_quests + 1 2674 processed_quests = processed_quests + 1
2670 end 2675 end
2671 entry_index = entry_index + 1 2676 entry_index = entry_index + 1
2672 end 2677 end
2673 _G.SelectQuestLogEntry(selected_quest) 2678 _G.C_QuestLog.SetSelectedQuest(selected_quest)
2674 self:UnregisterEvent("QUEST_LOG_UPDATE") 2679 self:UnregisterEvent("QUEST_LOG_UPDATE")
2675 end 2680 end
2676 2681
2677 2682
2678 function WDP:QUEST_PROGRESS(event_name) 2683 function WDP:QUEST_PROGRESS(event_name)
2689 end 2694 end
2690 self:RegisterEvent("QUEST_LOG_UPDATE") 2695 self:RegisterEvent("QUEST_LOG_UPDATE")
2691 end 2696 end
2692 2697
2693 2698
2699 -- This functionality is broken and should be rethought entirely in the wake of 10.0
2700 --[[
2694 do 2701 do
2695 local TRADESKILL_TOOLS = { 2702 local TRADESKILL_TOOLS = {
2696 Anvil = anvil_spell_ids, 2703 Anvil = anvil_spell_ids,
2697 Forge = forge_spell_ids, 2704 Forge = forge_spell_ids,
2698 } 2705 }
2786 -- Reset the filters to what they were before 2793 -- Reset the filters to what they were before
2787 _G.SetTrainerServiceTypeFilter("available", available or 0) 2794 _G.SetTrainerServiceTypeFilter("available", available or 0)
2788 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0) 2795 _G.SetTrainerServiceTypeFilter("unavailable", unavailable or 0)
2789 _G.SetTrainerServiceTypeFilter("used", used or 0) 2796 _G.SetTrainerServiceTypeFilter("used", used or 0)
2790 end 2797 end
2798 ]]--
2791 2799
2792 2800
2793 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line) 2801 function WDP:UNIT_SPELLCAST_SENT(event_name, unit_id, spell_name, spell_rank, target_name, spell_line)
2794 if private.tracked_line or unit_id ~= "player" then 2802 if private.tracked_line or unit_id ~= "player" then
2795 return 2803 return
3007 WDP:StopChatLootRecording(event_name) 3015 WDP:StopChatLootRecording(event_name)
3008 SetUnitField("auctioneer", private.UNIT_TYPES.NPC) 3016 SetUnitField("auctioneer", private.UNIT_TYPES.NPC)
3009 end 3017 end
3010 3018
3011 3019
3020 -- manager_frame_id is 4 in case we need to merge this into that event
3012 function WDP:BANKFRAME_OPENED(event_name) 3021 function WDP:BANKFRAME_OPENED(event_name)
3013 WDP:StopChatLootRecording(event_name) 3022 WDP:StopChatLootRecording(event_name)
3014 SetUnitField("banker", private.UNIT_TYPES.NPC) 3023 SetUnitField("banker", private.UNIT_TYPES.NPC)
3015 end 3024 end
3016 3025
3020 end 3029 end
3021 3030
3022 3031
3023 local GOSSIP_SHOW_FUNCS = { 3032 local GOSSIP_SHOW_FUNCS = {
3024 [private.UNIT_TYPES.NPC] = function(unit_idnum) 3033 [private.UNIT_TYPES.NPC] = function(unit_idnum)
3025 local gossip_options = { _G.GetGossipOptions() } 3034 local gossip_options = { _G.C_GossipInfo.GetOptions() }
3026 3035
3027 for index = 2, #gossip_options, 2 do 3036 for index = 2, #gossip_options, 2 do
3028 if gossip_options[index] == "binder" then 3037 if gossip_options[index] == "binder" then
3029 SetUnitField("innkeeper", private.UNIT_TYPES.NPC) 3038 SetUnitField("innkeeper", private.UNIT_TYPES.NPC)
3030 return 3039 return
3035 UpdateDBEntryLocation("objects", unit_idnum) 3044 UpdateDBEntryLocation("objects", unit_idnum)
3036 end, 3045 end,
3037 } 3046 }
3038 3047
3039 3048
3049 -- manager_frame_id is 3 in case we need to merge this into that event
3040 function WDP:GOSSIP_SHOW(event_name) 3050 function WDP:GOSSIP_SHOW(event_name)
3041 WDP:StopChatLootRecording(event_name) 3051 WDP:StopChatLootRecording(event_name)
3042 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc")) 3052 local unit_type, unit_idnum = ParseGUID(_G.UnitGUID("npc"))
3043 if not unit_idnum then 3053 if not unit_idnum then
3044 return 3054 return
3048 GOSSIP_SHOW_FUNCS[unit_type](unit_idnum) 3058 GOSSIP_SHOW_FUNCS[unit_type](unit_idnum)
3049 end 3059 end
3050 end 3060 end
3051 3061
3052 3062
3063 -- manager_frame_id is 10 in case we need to merge this into that event
3053 function WDP:GUILDBANKFRAME_OPENED(event_name) 3064 function WDP:GUILDBANKFRAME_OPENED(event_name)
3054 WDP:StopChatLootRecording(event_name) 3065 WDP:StopChatLootRecording(event_name)
3055 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT) 3066 SetUnitField("guild_bank", private.UNIT_TYPES.OBJECT)
3056 end 3067 end
3057 3068
3058 3069
3059 function WDP:ITEM_UPGRADE_MASTER_OPENED(event_name) 3070 -- manager_frame_id is 6 in case we need to merge this into that event
3060 SetUnitField("item_upgrade_master", private.UNIT_TYPES.NPC)
3061 end
3062
3063
3064 function WDP:TAXIMAP_OPENED(event_name) 3071 function WDP:TAXIMAP_OPENED(event_name)
3065 SetUnitField("flight_master", private.UNIT_TYPES.NPC) 3072 SetUnitField("flight_master", private.UNIT_TYPES.NPC)
3066 end 3073 end
3067 3074
3068 3075
3069 function WDP:TRANSMOGRIFY_OPEN(event_name) 3076 function WDP:PLAYER_INTERACTION_MANAGER_FRAME_SHOW(event_name, manager_frame_id)
3070 SetUnitField("transmogrifier", private.UNIT_TYPES.NPC) 3077 if not manager_frame_id then
3071 end 3078 return
3072 3079 elseif manager_frame_id == 24 then
3073 3080 SetUnitField("transmogrifier", private.UNIT_TYPES.NPC)
3074 function WDP:VOID_STORAGE_OPEN(event_name) 3081 elseif manager_frame_id == 26 then
3075 SetUnitField("void_storage", private.UNIT_TYPES.NPC) 3082 WDP:StopChatLootRecording(event_name)
3083 SetUnitField("void_storage", private.UNIT_TYPES.NPC)
3084 elseif manager_frame_id == 53 then
3085 WDP:StopChatLootRecording(event_name)
3086 SetUnitField("item_upgrade_master", private.UNIT_TYPES.NPC)
3087 end
3076 end 3088 end
3077 end -- do-block 3089 end -- do-block