comparison Main.lua @ 165:311e2144c9ed

Added more debug prints. Break out of loop when finding a locked item during the AF.ITEM loot verification.
author James D. Callahan III <jcallahan@curse.com>
date Mon, 08 Oct 2012 15:02:24 -0500
parents b5ced741f9e6
children 135ef8805021
comparison
equal deleted inserted replaced
164:b5ced741f9e6 165:311e2144c9ed
435 if current_line:GetText() == _G.ITEM_OPENABLE then 435 if current_line:GetText() == _G.ITEM_OPENABLE then
436 table.wipe(current_action) 436 table.wipe(current_action)
437 current_action.target_type = AF.ITEM 437 current_action.target_type = AF.ITEM
438 current_action.identifier = item_id 438 current_action.identifier = item_id
439 current_action.loot_label = "contains" 439 current_action.loot_label = "contains"
440
441 Debug(("HandleItemUse: current_action.identifier: '%s'"):format(item_id))
440 break 442 break
441 end 443 end
442 end 444 end
443 end 445 end
444 446
510 if current_loot.sources then 512 if current_loot.sources then
511 for source_guid, loot_data in pairs(current_loot.sources) do 513 for source_guid, loot_data in pairs(current_loot.sources) do
512 local entry, source_id 514 local entry, source_id
513 515
514 if current_loot.target_type == AF.ITEM then 516 if current_loot.target_type == AF.ITEM then
517 Debug(("GenericLootUpdate: current_loot.identifier: '%s'"):format(tostring(current_loot.identifier)))
515 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc) 518 -- Items return the player as the source, so we need to use the item's ID (disenchant, milling, etc)
516 source_id = current_loot.identifier 519 source_id = current_loot.identifier
517 entry = DBEntry(data_type, source_id) 520 entry = DBEntry(data_type, source_id)
518 elseif current_loot.target_type == AF.OBJECT then 521 elseif current_loot.target_type == AF.OBJECT then
519 source_id = ("%s:%s"):format(current_loot.spell_label, select(2, ParseGUID(source_guid))) 522 source_id = ("%s:%s"):format(current_loot.spell_label, select(2, ParseGUID(source_guid)))
1200 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do 1203 for slot_index = 1, _G.GetContainerNumSlots(bag_index) do
1201 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index) 1204 local _, _, is_locked = _G.GetContainerItemInfo(bag_index, slot_index)
1202 1205
1203 if is_locked then 1206 if is_locked then
1204 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index)) 1207 locked_item_id = ItemLinkToID(_G.GetContainerItemLink(bag_index, slot_index))
1208 break
1205 end 1209 end
1206 end 1210 end
1211
1212 if locked_item_id then
1213 break
1214 end
1207 end 1215 end
1208 1216
1209 if not locked_item_id or (current_action.identifier and current_action.identifier ~= locked_item_id) then 1217 if not locked_item_id or (current_action.identifier and current_action.identifier ~= locked_item_id) then
1210 return false 1218 return false
1211 end 1219 end
1220 Debug(("LOOT_VERIFY_FUNCS[AF.ITEM]: current_action.identifier: '%s'"):format(locked_item_id))
1212 current_action.identifier = locked_item_id 1221 current_action.identifier = locked_item_id
1213 return true 1222 return true
1214 end, 1223 end,
1215 [AF.NPC] = function() 1224 [AF.NPC] = function()
1216 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then 1225 if not _G.UnitExists("target") or _G.UnitIsFriend("player", "target") or _G.UnitIsPlayer("target") or _G.UnitPlayerControlled("target") then
1833 1842
1834 if not profession_skills then 1843 if not profession_skills then
1835 class_professions[profession] = {} 1844 class_professions[profession] = {}
1836 profession_skills = class_professions[profession] 1845 profession_skills = class_professions[profession]
1837 end 1846 end
1838 -- profession_skills[spell_id] = ("%d:%d:%d"):format(required_level, min_skill, ActualCopperCost(_G.GetTrainerServiceCost(index), trainer_standing)) 1847 -- profession_skills[spell_id] = ("%d:%d:%d"):format(required_level, min_skill, ActualCopperCost(_G.GetTrainerServiceCost(index), trainer_standing))
1839 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill) 1848 profession_skills[spell_id] = ("%d:%d"):format(required_level, min_skill)
1840 end 1849 end
1841 end 1850 end
1842 end 1851 end
1843 -- Reset the filters to what they were before 1852 -- Reset the filters to what they were before
1858 end 1867 end
1859 table.wipe(current_action) 1868 table.wipe(current_action)
1860 1869
1861 local item_name, item_link = _G.GameTooltip:GetItem() 1870 local item_name, item_link = _G.GameTooltip:GetItem()
1862 local unit_name, unit_id = _G.GameTooltip:GetUnit() 1871 local unit_name, unit_id = _G.GameTooltip:GetUnit()
1863
1864 Debug(("Item name: '%s', Unit name: '%s'"):format(tostring(item_name), tostring(unit_name)))
1865 1872
1866 if not unit_name and _G.UnitName("target") == target_name then 1873 if not unit_name and _G.UnitName("target") == target_name then
1867 unit_name = target_name 1874 unit_name = target_name
1868 unit_id = "target" 1875 unit_id = "target"
1869 end 1876 end
1880 if not private.NON_LOOT_SPELL_LABELS[spell_label] then 1887 if not private.NON_LOOT_SPELL_LABELS[spell_label] then
1881 current_action.loot_label = spell_label:lower() 1888 current_action.loot_label = spell_label:lower()
1882 end 1889 end
1883 1890
1884 if unit_name and unit_name == target_name and not item_name then 1891 if unit_name and unit_name == target_name and not item_name then
1885 Debug("Unit name is same as target_name")
1886 if bit.band(spell_flags, AF.NPC) == AF.NPC then 1892 if bit.band(spell_flags, AF.NPC) == AF.NPC then
1887 if not unit_id or unit_name ~= target_name then 1893 if not unit_id or unit_name ~= target_name then
1888 return 1894 return
1889 end 1895 end
1890 current_action.target_type = AF.NPC 1896 current_action.target_type = AF.NPC
1891 end 1897 end
1892 elseif bit.band(spell_flags, AF.ITEM) == AF.ITEM then 1898 elseif bit.band(spell_flags, AF.ITEM) == AF.ITEM then
1893 current_action.target_type = AF.ITEM 1899 current_action.target_type = AF.ITEM
1900
1901 Debug(("%s: Item name: '%s'"):format(event_name, tostring(item_name)))
1894 1902
1895 if item_name and item_name == target_name then 1903 if item_name and item_name == target_name then
1896 current_action.identifier = ItemLinkToID(item_link) 1904 current_action.identifier = ItemLinkToID(item_link)
1897 elseif target_name and target_name ~= "" then 1905 elseif target_name and target_name ~= "" then
1898 current_action.identifier = ItemLinkToID(select(2, _G.GetItemInfo(target_name))) 1906 current_action.identifier = ItemLinkToID(select(2, _G.GetItemInfo(target_name)))
1899 end 1907 end
1908 Debug(("%s: current_action.identifier: '%s'"):format(event_name, tostring(current_action.identifier)))
1900 elseif not item_name and not unit_name then 1909 elseif not item_name and not unit_name then
1901 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then 1910 if bit.band(spell_flags, AF.OBJECT) == AF.OBJECT then
1902 if target_name == "" then 1911 if target_name == "" then
1903 Debug("Didn't set current_action.target_type") 1912 Debug("Didn't set current_action.target_type")
1904 return 1913 return