comparison Main.lua @ 324:9cc4ffab84d1 5.4.2-1

Miscellaneous fixes.
author James D. Callahan III <jcallahan@curse.com>
date Wed, 22 Jan 2014 08:24:08 -0600
parents 901b9cd2a6c2
children 66b136635f6b
comparison
equal deleted inserted replaced
323:901b9cd2a6c2 324:9cc4ffab84d1
304 local function ClearKilledBossID() 304 local function ClearKilledBossID()
305 if killed_boss_id_timer_handle then 305 if killed_boss_id_timer_handle then
306 WDP:CancelTimer(killed_boss_id_timer_handle) 306 WDP:CancelTimer(killed_boss_id_timer_handle)
307 killed_boss_id_timer_handle = nil 307 killed_boss_id_timer_handle = nil
308 end 308 end
309
309 table.wipe(boss_loot_toasting) 310 table.wipe(boss_loot_toasting)
310 private.raid_finder_boss_id = nil 311 private.raid_finder_boss_id = nil
311 private.world_boss_id = nil 312 private.world_boss_id = nil
312 end 313 end
313 314
314 315
315 local function ClearLootToastContainerID() 316 local function ClearLootToastContainerID()
316 if loot_toast_container_timer_handle then 317 if loot_toast_container_timer_handle then
317 WDP:CancelTimer(loot_toast_container_timer_handle) 318 WDP:CancelTimer(loot_toast_container_timer_handle)
318 killed_boss_id_timer_handle = nil 319 loot_toast_container_timer_handle = nil
319 end 320 end
321
320 private.container_loot_toasting = false 322 private.container_loot_toasting = false
321 private.loot_toast_container_id = nil 323 private.loot_toast_container_id = nil
322 end 324 end
323 325
324 326
572 574
573 for line_index = 1, DatamineTT:NumLines() do 575 for line_index = 1, DatamineTT:NumLines() do
574 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] 576 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
575 577
576 if not current_line then 578 if not current_line then
577 Debug("HandleItemUse: Item with ID %d and link %s did not have a tooltip that contained the string %s.", item_id, item_link, _G.ITEM_OPENABLE) 579 Debug("HandleItemUse: Item with ID %d and link %s had an invalid tooltip.", item_id, item_link, _G.ITEM_OPENABLE)
578 break 580 return
579 end 581 end
580 582
581 if current_line:GetText() == _G.ITEM_OPENABLE then 583 if current_line:GetText() == _G.ITEM_OPENABLE then
582 table.wipe(current_action) 584 table.wipe(current_action)
583 current_loot = nil 585 current_loot = nil
584 586
585 current_action.target_type = AF.ITEM 587 current_action.target_type = AF.ITEM
586 current_action.identifier = item_id 588 current_action.identifier = item_id
587 current_action.loot_label = "contains" 589 current_action.loot_label = "contains"
588 break 590 return
589 end 591 end
590 end 592 end
593
594 Debug("HandleItemUse: Item with ID %d and link %s did not have a tooltip that contained the string %s.", item_id, item_link, _G.ITEM_OPENABLE)
591 end 595 end
592 596
593 597
594 local UnitFactionStanding 598 local UnitFactionStanding
595 local UpdateFactionData 599 local UpdateFactionData
1665 end 1669 end
1666 1670
1667 1671
1668 do 1672 do
1669 local LOOT_OPENED_VERIFY_FUNCS = { 1673 local LOOT_OPENED_VERIFY_FUNCS = {
1674 -- 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.
1670 [AF.ITEM] = function() 1675 [AF.ITEM] = function()
1671 local locked_item_id 1676 local locked_item_id
1672 1677
1673 for bag_index = 0, _G.NUM_BAG_FRAMES do 1678 for bag_index = 0, _G.NUM_BAG_FRAMES do
1674 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do 1679 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
1675 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index) 1680 local _, _, is_locked, _, _, is_lootable = _G.GetContainerItemInfo(bag_index, slot_index)
1676 1681
1677 if is_locked then 1682 if is_locked and is_lootable then
1678 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index)) 1683 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index))
1679 break 1684 break
1680 end 1685 end
1681 end 1686 end
1682 1687
1814 Debug("%s: No GUIDs found in loot. Blank loot window?", log_source) 1819 Debug("%s: No GUIDs found in loot. Blank loot window?", log_source)
1815 return false 1820 return false
1816 end 1821 end
1817 local num_npcs = 0 1822 local num_npcs = 0
1818 local num_objects = 0 1823 local num_objects = 0
1824 local num_itemcontainers = 0
1819 1825
1820 for source_guid, guid_data in pairs(extrapolated_guid_registry) do 1826 for source_guid, guid_data in pairs(extrapolated_guid_registry) do
1821 local unit_type = guid_data[1] 1827 local unit_type = guid_data[1]
1822 local loot_label = (unit_type == private.UNIT_TYPES.OBJECT) and "opening" or (UnitTypeIsNPC(unit_type) and "drops" or nil) 1828 local loot_label = (unit_type == private.UNIT_TYPES.OBJECT) and "opening" or (UnitTypeIsNPC(unit_type) and "drops") or ((unit_type == private.UNIT_TYPES.PLAYER) and "contains")
1823 1829
1824 if loot_label then 1830 if loot_label then
1825 local unit_idnum = guid_data[2] 1831 local unit_idnum = guid_data[2]
1826 1832
1827 if loot_guid_registry[loot_label] and loot_guid_registry[loot_label][source_guid] then 1833 if loot_guid_registry[loot_label] and loot_guid_registry[loot_label][source_guid] then
1835 elseif UnitTypeIsNPC(unit_type) then 1841 elseif UnitTypeIsNPC(unit_type) then
1836 current_action.loot_label = loot_label 1842 current_action.loot_label = loot_label
1837 current_action.target_type = AF.NPC 1843 current_action.target_type = AF.NPC
1838 current_action.identifier = unit_idnum 1844 current_action.identifier = unit_idnum
1839 num_npcs = num_npcs + 1 1845 num_npcs = num_npcs + 1
1846 -- Item container GUIDs are currently of the 'PLAYER' type; this may be unintended and could change in the future.
1847 elseif unit_type == private.UNIT_TYPES.PLAYER then
1848 current_action.loot_label = loot_label
1849 current_action.target_type = AF.ITEM
1850 -- current_action.identifier assigned during loot verification.
1851 num_itemcontainers = num_itemcontainers + 1
1840 end 1852 end
1841 else 1853 else
1842 -- Bail here; not only do we not know what this unit is, but we don't want to attribute loot to something that doesn't actually drop it. 1854 -- Bail here; not only do we not know what this unit is, but we don't want to attribute loot to something that doesn't actually drop it.
1843 Debug("%s: Unit with GUID %s has unsupported type for looting.", log_source, source_guid) 1855 Debug("%s: Unit with GUID %s has unsupported type for looting.", log_source, source_guid)
1844 return false 1856 return false
1849 Debug("%s: Failure to obtain target_type.", log_source) 1861 Debug("%s: Failure to obtain target_type.", log_source)
1850 return false 1862 return false
1851 end 1863 end
1852 1864
1853 -- We can't figure out what dropped the loot. This shouldn't ever happen, but hey - Blizzard does some awesome stuff on occasion. 1865 -- We can't figure out what dropped the loot. This shouldn't ever happen, but hey - Blizzard does some awesome stuff on occasion.
1854 if num_npcs ~= 0 and num_objects ~= 0 then 1866 if (num_npcs > 0 and num_objects + num_itemcontainers > 0) or (num_objects > 0 and num_npcs + num_itemcontainers > 0) or (num_itemcontainers > 0 and num_npcs + num_objects > 0) then
1855 Debug("%s: Mixed target types are not supported.", log_source) 1867 Debug("%s: Mixed target types are not supported. NPCs - %d, Objects - %d, Item Containers - %d.", log_source, num_npcs, num_objects, num_itemcontainers)
1856 return false 1868 return false
1857 end 1869 end
1858 1870
1859 Debug("%s: Successfully extrapolated information for current_action.", log_source) 1871 Debug("%s: Successfully extrapolated information for current_action.", log_source)
1860 return true 1872 return true
1887 Debug("%s: The current action's target type is unsupported or nil.", event_name) 1899 Debug("%s: The current action's target type is unsupported or nil.", event_name)
1888 return 1900 return
1889 end 1901 end
1890 1902
1891 if _G.type(verify_func) == "function" and not verify_func() then 1903 if _G.type(verify_func) == "function" and not verify_func() then
1892 Debug("%s: The current action type, %s, is supported but has failed loot verification.", event_name, current_action.target_type) 1904 Debug("%s: The current action type, %s, is supported but has failed loot verification.", event_name, private.ACTION_TYPE_NAMES[current_action.target_type])
1893 return 1905 return
1894 end 1906 end
1895 local guids_used = {} 1907 local guids_used = {}
1896 1908
1897 InitializeCurrentLoot() 1909 InitializeCurrentLoot()
1908 for loot_index = 1, #loot_info, 2 do 1920 for loot_index = 1, #loot_info, 2 do
1909 local source_guid = loot_info[loot_index] 1921 local source_guid = loot_info[loot_index]
1910 1922
1911 if not loot_guid_registry[current_loot.label][source_guid] then 1923 if not loot_guid_registry[current_loot.label][source_guid] then
1912 local loot_quantity = loot_info[loot_index + 1] 1924 local loot_quantity = loot_info[loot_index + 1]
1913 if #loot_info == 2 and slot_quantity > loot_quantity then 1925
1914 loot_quantity = slot_quantity 1926 -- There is a new bug in 5.4.0 that causes GetLootSlotInfo() to (rarely) return nil values for slot_quantity.
1915 end 1927 if slot_quantity then
1916 local source_type, source_id = ParseGUID(source_guid) 1928 -- We need slot_quantity to account for an old bug where loot_quantity is sometimes '1' for stacks of items, such as cloth.
1917 local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id) 1929 if slot_quantity > loot_quantity then
1918 1930 loot_quantity = slot_quantity
1919 if slot_type == _G.LOOT_SLOT_ITEM then 1931 end
1920 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot)) 1932
1921 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) 1933 local source_type, source_id = ParseGUID(source_guid)
1922 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 1934 local source_key = ("%s:%d"):format(private.UNIT_TYPE_NAMES[source_type + 1], source_id)
1923 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + loot_quantity 1935
1924 guids_used[source_guid] = true 1936 if slot_type == _G.LOOT_SLOT_ITEM then
1925 elseif slot_type == _G.LOOT_SLOT_MONEY then 1937 local item_id = ItemLinkToID(_G.GetLootSlotLink(loot_slot))
1926 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity) 1938 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)
1927 if current_loot.target_type == AF.ZONE then
1928 table.insert(current_loot.list, ("money:%d"):format(loot_quantity))
1929 else
1930 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {} 1939 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1931 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + loot_quantity 1940 current_loot.sources[source_guid][item_id] = current_loot.sources[source_guid][item_id] or 0 + loot_quantity
1932 guids_used[source_guid] = true 1941 guids_used[source_guid] = true
1942 elseif slot_type == _G.LOOT_SLOT_MONEY then
1943 Debug("GUID: %s - Type:ID: %s - Money - Amount: %d (%d)", loot_info[loot_index], source_key, loot_info[loot_index + 1], slot_quantity)
1944 if current_loot.target_type == AF.ZONE then
1945 table.insert(current_loot.list, ("money:%d"):format(loot_quantity))
1946 else
1947 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1948 current_loot.sources[source_guid]["money"] = current_loot.sources[source_guid]["money"] or 0 + loot_quantity
1949 guids_used[source_guid] = true
1950 end
1951 elseif slot_type == _G.LOOT_SLOT_CURRENCY then
1952 -- Same bug with GetLootSlotInfo() will screw up currency when it happens, so we won't process this slot's loot.
1953 if icon_texture then
1954 Debug("GUID: %s - Type:ID: %s - Currency: %s - Amount: %d (%d)", loot_info[loot_index], source_key, icon_texture, loot_info[loot_index + 1], slot_quantity)
1955 if current_loot.target_type == AF.ZONE then
1956 table.insert(current_loot.list, ("currency:%d:%s"):format(loot_quantity, icon_texture:match("[^\\]+$"):lower()))
1957 else
1958 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower())
1959
1960 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1961 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + loot_quantity
1962 guids_used[source_guid] = true
1963 end
1964 else
1965 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)
1966 end
1933 end 1967 end
1934 elseif slot_type == _G.LOOT_SLOT_CURRENCY then 1968 else
1935 Debug("GUID: %s - Type:ID: %s - Currency: %s - Amount: %d (%d)", loot_info[loot_index], source_key, icon_texture, loot_info[loot_index + 1], slot_quantity) 1969 -- 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.
1936 if current_loot.target_type == AF.ZONE then 1970 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)
1937 table.insert(current_loot.list, ("currency:%d:%s"):format(loot_quantity, icon_texture:match("[^\\]+$"):lower()))
1938 else
1939 local currency_token = ("currency:%s"):format(icon_texture:match("[^\\]+$"):lower())
1940
1941 current_loot.sources[source_guid] = current_loot.sources[source_guid] or {}
1942 current_loot.sources[source_guid][currency_token] = current_loot.sources[source_guid][currency_token] or 0 + loot_quantity
1943 guids_used[source_guid] = true
1944 end
1945 end 1971 end
1946 end 1972 end
1947 end 1973 end
1948 end 1974 end
1949 1975
2006 2032
2007 for item_index = 1, num_items do 2033 for item_index = 1, num_items do
2008 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index) 2034 local _, _, copper_price, stack_size, num_available, _, extended_cost = _G.GetMerchantItemInfo(item_index)
2009 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index)) 2035 local item_id = ItemLinkToID(_G.GetMerchantItemLink(item_index))
2010 2036
2037 DatamineTT:ClearLines()
2038 DatamineTT:SetMerchantItem(item_index)
2039
2040 if not item_id then
2041 local item_name, item_link = DatamineTT:GetItem()
2042 item_id = ItemLinkToID(item_link)
2043 Debug("%s: GetMerchantItemLink() still ocassionally fails, apparently. Failed item's ID - %s", event_name, item_id)
2044 end
2045
2011 if item_id and item_id > 0 then 2046 if item_id and item_id > 0 then
2012 local price_string = ActualCopperCost(copper_price, merchant_standing) 2047 local price_string = ActualCopperCost(copper_price, merchant_standing)
2013
2014 DatamineTT:ClearLines()
2015 DatamineTT:SetMerchantItem(item_index)
2016 2048
2017 local num_lines = DatamineTT:NumLines() 2049 local num_lines = DatamineTT:NumLines()
2018 2050
2019 for line_index = 1, num_lines do 2051 for line_index = 1, num_lines do
2020 local current_line = _G["WDPDatamineTTTextLeft" .. line_index] 2052 local current_line = _G["WDPDatamineTTTextLeft" .. line_index]
2074 -- Keeping this around in case Blizzard makes the two points diverge at some point. 2106 -- Keeping this around in case Blizzard makes the two points diverge at some point.
2075 -- price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0) 2107 -- price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0)
2076 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0) 2108 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0)
2077 2109
2078 for cost_index = 1, item_count do 2110 for cost_index = 1, item_count do
2079 -- the third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0 2111 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0.
2080 local icon_texture, amount_required, item_link = _G.GetMerchantItemCostItem(item_index, cost_index) 2112 local icon_texture, amount_required, item_link = _G.GetMerchantItemCostItem(item_index, cost_index)
2081 local currency_identifier = item_link and ItemLinkToID(item_link) or nil 2113 local currency_identifier = item_link and ItemLinkToID(item_link) or nil
2082 2114
2083 if (not currency_identifier or currency_identifier < 1) and icon_texture then 2115 if (not currency_identifier or currency_identifier < 1) and icon_texture then
2084 currency_identifier = icon_texture:match("[^\\]+$"):lower() 2116 currency_identifier = icon_texture:match("[^\\]+$"):lower()
2119 table.wipe(current_action) 2151 table.wipe(current_action)
2120 end 2152 end
2121 2153
2122 2154
2123 function WDP:PET_JOURNAL_LIST_UPDATE(event_name) 2155 function WDP:PET_JOURNAL_LIST_UPDATE(event_name)
2124 -- this function produces data currently unused by wowdb.com and it makes debugging errors in the .lua output nearly impossible due to the massive bloat 2156 -- This function produces data currently unused by wowdb.com and it makes debugging errors in the .lua output nearly impossible due to the massive bloat.
2125 if DEBUGGING then 2157 if DEBUGGING then
2126 return 2158 return
2127 end 2159 end
2128 2160
2129 local num_pets = LPJ:NumPets() 2161 local num_pets = LPJ:NumPets()
2432 else 2464 else
2433 Debug("%s: Spell ID %d is not a known raid or world boss 'Bonus' spell.", event_name, spell_id) 2465 Debug("%s: Spell ID %d is not a known raid or world boss 'Bonus' spell.", event_name, spell_id)
2434 return 2466 return
2435 end 2467 end
2436 2468
2437 -- assign existing loot data to boss if it exists 2469 -- Assign existing loot data to boss if it exists
2438 if loot_toast_data then 2470 if loot_toast_data then
2439 local npc_id = private.raid_finder_boss_id or private.world_boss_id 2471 local npc_id = private.raid_finder_boss_id or private.world_boss_id
2440 2472
2441 -- slightly messy hack to workaround duplicate world bosses 2473 -- Slightly messy hack to workaround duplicate world bosses
2442 local upper_limit = 0 2474 local upper_limit = 0
2443 if DUPLICATE_WORLD_BOSS_IDS[npc_id] then 2475 if DUPLICATE_WORLD_BOSS_IDS[npc_id] then
2444 upper_limit = #DUPLICATE_WORLD_BOSS_IDS[npc_id] 2476 upper_limit = #DUPLICATE_WORLD_BOSS_IDS[npc_id]
2445 end 2477 end
2446 2478
2451 temp_npc_id = DUPLICATE_WORLD_BOSS_IDS[npc_id][i] 2483 temp_npc_id = DUPLICATE_WORLD_BOSS_IDS[npc_id][i]
2452 end 2484 end
2453 2485
2454 local npc = NPCEntry(temp_npc_id) 2486 local npc = NPCEntry(temp_npc_id)
2455 if npc then 2487 if npc then
2456 -- create needed npc fields if required 2488 -- Create needed npc fields if required
2457 local loot_label = "drops" 2489 local loot_label = "drops"
2458 local encounter_data = npc:EncounterData(InstanceDifficultyToken()) 2490 local encounter_data = npc:EncounterData(InstanceDifficultyToken())
2459 encounter_data[loot_label] = encounter_data[loot_label] or {} 2491 encounter_data[loot_label] = encounter_data[loot_label] or {}
2460 encounter_data.loot_counts = encounter_data.loot_counts or {} 2492 encounter_data.loot_counts = encounter_data.loot_counts or {}
2461 2493
2473 Debug("%s: Assigned stored money loot data - money:%d", event_name, quantity) 2505 Debug("%s: Assigned stored money loot data - money:%d", event_name, quantity)
2474 table.insert(encounter_data[loot_label], ("money:%d"):format(quantity)) 2506 table.insert(encounter_data[loot_label], ("money:%d"):format(quantity))
2475 elseif loot_type == "currency" then 2507 elseif loot_type == "currency" then
2476 local currency_texture = CurrencyLinkToTexture(hyperlink) 2508 local currency_texture = CurrencyLinkToTexture(hyperlink)
2477 Debug("%s: Assigned stored currency loot data - %s - currency:%d:%s", event_name, hyperlink, currency_texture, quantity) 2509 Debug("%s: Assigned stored currency loot data - %s - currency:%d:%s", event_name, hyperlink, currency_texture, quantity)
2478 -- workaround for Patch 5.4.0 bug with Flexible raid Siege of Orgrimmar bosses and Valor Points 2510 -- Workaround for Patch 5.4.0 bug with Flexible raid Siege of Orgrimmar bosses and Valor Points
2479 if quantity > 1000 and currency_texture == "pvecurrency-valor" then 2511 if quantity > 1000 and currency_texture == "pvecurrency-valor" then
2480 quantity = math.floor(quantity / 100) 2512 quantity = math.floor(quantity / 100)
2481 end 2513 end
2482 table.insert(encounter_data[loot_label], ("currency:%d:%s"):format(quantity, currency_texture)) 2514 table.insert(encounter_data[loot_label], ("currency:%d:%s"):format(quantity, currency_texture))
2483 end 2515 end