comparison Main.lua @ 460:9f1d3224d316 6.2.2-1

Fixed Patch 6.2.0+ itemstring processing. While at it, significantly refactored code that records item data so it is vastly better.
author MMOSimca <MMOSimca@gmail.com>
date Mon, 26 Oct 2015 22:06:16 -0400
parents 22f08f6717ea
children 94e59c64a328
comparison
equal deleted inserted replaced
459:22f08f6717ea 460:9f1d3224d316
1012 self:HandleZoneChange("OnEnable") 1012 self:HandleZoneChange("OnEnable")
1013 self:GROUP_ROSTER_UPDATE() 1013 self:GROUP_ROSTER_UPDATE()
1014 end 1014 end
1015 1015
1016 1016
1017 local ScrapeItemUpgradeStats
1018 do
1019 local intermediary = {}
1020
1021 function ScrapeItemUpgradeStats(item_id, upgrade_id, reforge_id)
1022 if not ALLOWED_LOCALES[CLIENT_LOCALE] then
1023 return
1024 end
1025 local create_entry
1026
1027 table.wipe(intermediary)
1028
1029 for line_index = 1, DatamineTT:NumLines() do
1030 local left_text = _G["WDPDatamineTTTextLeft" .. line_index]:GetText():trim()
1031
1032 if not left_text or left_text == "" or left_text:find("Socket") or left_text:find("Set:") then
1033 break
1034 end
1035 local amount, stat = left_text:match("+(.-) (.*)")
1036
1037 if amount and stat then
1038 create_entry = true
1039 intermediary[stat:lower():gsub(" ", "_"):gsub("|r", "")] = tonumber((amount:gsub(",", "")))
1040 end
1041 end
1042
1043 if not create_entry then
1044 return
1045 end
1046 local item = DBEntry("items", item_id)
1047 item.upgrade_id = upgrade_id
1048 item.upgrades = item.upgrades or {}
1049 item.upgrades[upgrade_id] = item.upgrades[upgrade_id] or {}
1050
1051 for stat, amount in pairs(intermediary) do
1052 item.upgrades[upgrade_id][stat] = amount
1053 end
1054 end
1055 end -- do-block
1056
1057
1058 local function RecordItemData(item_id, item_link, process_bonus_ids, durability) 1017 local function RecordItemData(item_id, item_link, process_bonus_ids, durability)
1059 local _, _, item_string = item_link:find("^|%x+|H(.+)|h%[.+%]") 1018 local _, _, item_string = item_link:find("^|%x+|H(.+)|h%[.+%]")
1060 local item 1019 local item
1061 1020
1062 if item_string then 1021 if item_string then
1063 local item_results = { (":"):split(item_string) } 1022 local item_results = { (":"):split(item_string) }
1064 1023
1065 local suffix_id = tonumber(item_results[8]) 1024 local suffix_id = tonumber(item_results[8]) or 0
1066 local unique_id = item_results[9] 1025 local unique_id = item_results[9] or 0
1067 --local level = tonumber(item_results[10]) 1026 --local level = tonumber(item_results[10])
1068 --local unknown = tonumber(item_results[11]) 1027 --local specialization_id = tonumber(item_results[11])
1069 local upgrade_id = tonumber(item_results[12]) 1028 --local unknown_upgrade_related_id = tonumber(item_results[12])
1070 local instance_difficulty_id = tonumber(item_results[13]) 1029 local instance_difficulty_id = tonumber(item_results[13]) or 0
1071 local num_bonus_ids = tonumber(item_results[14]) 1030 local num_bonus_ids = tonumber(item_results[14]) or 0
1072 1031 -- upgrade_id is optional since 6.2! can probably be detected using unknown_upgrade_related_id, but it's just as easy to check like this
1073 if not num_bonus_ids or num_bonus_ids == 0 or not process_bonus_ids then 1032 local upgrade_id = tonumber(item_results[15 + num_bonus_ids]) or 0
1074 if (suffix_id and suffix_id ~= 0) or (instance_difficulty_id and instance_difficulty_id ~= 0) then 1033
1075 item = DBEntry("items", item_id) 1034 -- If there is anything special (non-zero) for this item then we need to make note of everything
1076 item.unique_id = bit.band(unique_id, 0xFFFF) 1035 if math.max(suffix_id, instance_difficulty_id, num_bonus_ids, upgrade_id) ~= 0 then
1077 1036 item = DBEntry("items", item_id)
1078 if suffix_id and suffix_id ~= 0 then 1037 item.suffix_id = suffix_id
1079 item.suffix_id = suffix_id 1038 item.unique_id = bit.band(unique_id, 0xFFFF)
1080 end 1039 item.instance_difficulty_id = instance_difficulty_id
1081 1040 item.upgrade_id = upgrade_id
1082 if instance_difficulty_id and instance_difficulty_id ~= 0 then 1041
1083 item.instance_difficulty_id = instance_difficulty_id 1042 if process_bonus_ids then
1084 end 1043
1085 1044 -- Get ready for bonus IDs
1086 if not item.seen_bonuses then 1045 if not item.seen_bonuses then
1087 item.seen_bonuses = {} 1046 item.seen_bonuses = {}
1088 end 1047 end
1089 item.seen_bonuses["0"] = true 1048
1090 end 1049 if num_bonus_ids > 0 then
1091 elseif num_bonus_ids > 0 then 1050 -- We want the bonus ID combo output to be in the form ["bonusID1:bonusID2:bonusID3"] = true
1092 item = DBEntry("items", item_id) 1051 -- And sorted numerically with the smallest bonusID first
1093 1052 local sorted_bonus_string = ""
1094 item.unique_id = bit.band(unique_id, 0xFFFF) 1053 local min_bonus_id_array = {}
1095 item.instance_difficulty_id = instance_difficulty_id 1054 for iterations = 1, num_bonus_ids do
1096 1055 -- Find minimum of this iteration
1097 if not item.seen_bonuses then 1056 local min_bonus_id = 100000
1098 item.seen_bonuses = {} 1057 for bonus_index = 1, num_bonus_ids do
1099 end 1058 local temp_bonus_id = tonumber(item_results[14 + bonus_index])
1100 1059 if temp_bonus_id and (not min_bonus_id_array[temp_bonus_id]) and (temp_bonus_id < min_bonus_id) then
1101 -- We want the bonus ID combo output to be in the form ["bonusID1:bonusID2:bonusID3"] = true 1060 min_bonus_id = temp_bonus_id
1102 -- And sorted numerically with the smallest bonusID first 1061 end
1103 local sorted_bonus_string = "" 1062 end
1104 local min_bonus_id_array = {} 1063
1105 for iterations = 1, num_bonus_ids do 1064 -- Keep track of already processed IDs
1106 -- Find minimum of this iteration 1065 min_bonus_id_array[min_bonus_id] = true
1107 local min_bonus_id = 100000 1066
1108 for bonus_index = 1, num_bonus_ids do 1067 -- Build string
1109 local temp_bonus_id = tonumber(item_results[14 + bonus_index]) 1068 if iterations == 1 then
1110 if temp_bonus_id and (not min_bonus_id_array[temp_bonus_id]) and (temp_bonus_id < min_bonus_id) then 1069 sorted_bonus_string = sorted_bonus_string .. tostring(min_bonus_id)
1111 min_bonus_id = temp_bonus_id 1070 else
1071 sorted_bonus_string = sorted_bonus_string .. ":" .. tostring(min_bonus_id)
1072 end
1112 end 1073 end
1113 end 1074
1114 1075 item.seen_bonuses[sorted_bonus_string] = true
1115 -- Keep track of already processed IDs 1076 Debug("RecordItemData: Recorded bonus IDs %s for item %d.", sorted_bonus_string, item_id)
1116 min_bonus_id_array[min_bonus_id] = true
1117
1118 -- Build string
1119 if iterations == 1 then
1120 sorted_bonus_string = sorted_bonus_string .. tostring(min_bonus_id)
1121 else 1077 else
1122 sorted_bonus_string = sorted_bonus_string .. ":" .. tostring(min_bonus_id) 1078 item.seen_bonuses["0"] = true
1123 end 1079 end
1124 end 1080 end
1125
1126 item.seen_bonuses[sorted_bonus_string] = true
1127 Debug("RecordItemData: Recorded bonus IDs %s for item %d.", sorted_bonus_string, item_id)
1128 else
1129 Debug("RecordItemData: num_bonus_ids is supposed to be 0 or positive, instead it was %d.", num_bonus_ids)
1130 end
1131 if upgrade_id and upgrade_id ~= 0 then
1132 DatamineTT:SetHyperlink(item_link)
1133 ScrapeItemUpgradeStats(item_id, upgrade_id)
1134 end 1081 end
1135 end 1082 end
1136 1083
1137 if durability and durability > 0 then 1084 if durability and durability > 0 then
1138 item = item or DBEntry("items", item_id) 1085 item = item or DBEntry("items", item_id)
1769 local BLACKLISTED_SPELLS = { 1716 local BLACKLISTED_SPELLS = {
1770 [117526] = true, -- Binding Shot (cast by Hunters) 1717 [117526] = true, -- Binding Shot (cast by Hunters)
1771 [121308] = true, -- Disguise (cast by Rogues) 1718 [121308] = true, -- Disguise (cast by Rogues)
1772 [132464] = true, -- Chi Wave (cast by Monks) 1719 [132464] = true, -- Chi Wave (cast by Monks)
1773 [132467] = true, -- Chi Wave (cast by Monks) 1720 [132467] = true, -- Chi Wave (cast by Monks)
1721 [167432] = true, -- Savagery (cast by Warsong Commander)
1722 [175077] = true, -- Fearsome Battle Standard (cast by Fearsome Battle Standard item)
1774 [176813] = true, -- Itchy Spores (cast by Marsh Creatures in Ashran) 1723 [176813] = true, -- Itchy Spores (cast by Marsh Creatures in Ashran)
1775 [183901] = true, -- Stolen Strength (cast by Felblood NPCs in Tanaan Jungle) 1724 [183901] = true, -- Stolen Strength (cast by Felblood NPCs in Tanaan Jungle)
1776 [183904] = true, -- Stolen Speed (cast by Felblood NPCs in Tanaan Jungle) 1725 [183904] = true, -- Stolen Speed (cast by Felblood NPCs in Tanaan Jungle)
1777 [183907] = true, -- Stolen Fervor (cast by Felblood NPCs in Tanaan Jungle) 1726 [183907] = true, -- Stolen Fervor (cast by Felblood NPCs in Tanaan Jungle)
1778 } 1727 }