Mercurial > wow > wowdb-profiler
comparison Main.lua @ 562:2be7eedb205b 8.0.1-4
Fixed world quest parsing and recording.
| author | Caleb Atherton <atcaleb@twitch.tv> |
|---|---|
| date | Sat, 21 Jul 2018 06:41:37 -0400 |
| parents | bb5a42af4db0 |
| children | 19c59ee05ab1 |
comparison
equal
deleted
inserted
replaced
| 561:bb5a42af4db0 | 562:2be7eedb205b |
|---|---|
| 924 for index = 1, _G.GetNumLanguages() do | 924 for index = 1, _G.GetNumLanguages() do |
| 925 languages_known[_G.GetLanguageByIndex(index)] = true | 925 languages_known[_G.GetLanguageByIndex(index)] = true |
| 926 end | 926 end |
| 927 | 927 |
| 928 -- These timers loop indefinitely using Lua's infinity constant | 928 -- These timers loop indefinitely using Lua's infinity constant |
| 929 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, math.huge) | 929 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, nil) |
| 930 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, math.huge) | 930 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, nil) |
| 931 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, math.huge) | 931 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, nil) |
| 932 | 932 |
| 933 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) | 933 _G.hooksecurefunc("UseContainerItem", function(bag_index, slot_index, target_unit) |
| 934 if target_unit then | 934 if target_unit then |
| 935 return | 935 return |
| 936 end | 936 end |
| 949 end | 949 end |
| 950 | 950 |
| 951 | 951 |
| 952 -- Record data for a specific quest ID; reward data must be available or nothing will be recorded | 952 -- Record data for a specific quest ID; reward data must be available or nothing will be recorded |
| 953 -- When we reach this point, we've already checked for a valid mapID, questID, quest data, and worldQuestType | 953 -- When we reach this point, we've already checked for a valid mapID, questID, quest data, and worldQuestType |
| 954 local function RecordWorldQuestData(quest_id, continent_world_map_id, zone_world_map_id, api_data_table) | 954 local function RecordWorldQuestData(quest_id, api_data_table) |
| 955 | |
| 956 -- Ensure we have location data and rewards (barely readable so putting it on multiple lines) | 955 -- Ensure we have location data and rewards (barely readable so putting it on multiple lines) |
| 957 -- (Honor is built in to the quest; it is not a sign rewards have been loaded) | 956 -- (Honor is built in to the quest; it is not a sign rewards have been loaded) |
| 958 if not api_data_table.x or not api_data_table.y or not api_data_table.floor or not | 957 if not api_data_table or not api_data_table.x or not api_data_table.y or not api_data_table.mapID or not |
| 959 (_G.GetQuestLogRewardXP(quest_id) > 0 or _G.GetNumQuestLogRewardCurrencies(quest_id) > 0 | 958 (_G.GetQuestLogRewardXP(quest_id) > 0 or _G.GetNumQuestLogRewardCurrencies(quest_id) > 0 |
| 960 or _G.GetNumQuestLogRewards(quest_id) > 0 or _G.GetQuestLogRewardMoney(quest_id) > 0 | 959 or _G.GetNumQuestLogRewards(quest_id) > 0 or _G.GetQuestLogRewardMoney(quest_id) > 0) then |
| 961 or _G.GetQuestLogRewardArtifactXP(quest_id) > 0) then | 960 --or _G.GetQuestLogRewardArtifactXP(quest_id) > 0) |
| 962 return | 961 return |
| 963 end | 962 end |
| 964 | |
| 965 -- Translate continent-level coordinates to zone-coordinates | |
| 966 local oX, oY, dFloor = tonumber(api_data_table.x) or 0, tonumber(api_data_table.y) or 0, tonumber(api_data_table.floor) or 0 | |
| 967 local dX, dY = HereBeDragons:TranslateZoneCoordinates(oX, oY, continent_world_map_id, 0, zone_world_map_id, dFloor, false) | |
| 968 | |
| 969 -- If the translation failed, stop here | |
| 970 if not dX or not dY then return end | |
| 971 | 963 |
| 972 local entry = DBEntry("world_quests", quest_id) | 964 local entry = DBEntry("world_quests", quest_id) |
| 973 if entry then | 965 if entry then |
| 974 | 966 |
| 975 -- Record location | 967 -- Record location |
| 976 entry["location"] = {} | 968 entry["location"] = {} |
| 977 entry["location"]["world_map_id"] = zone_world_map_id | 969 entry["location"]["world_map_id"] = api_data_table.mapID |
| 978 entry["location"]["x"] = dX * 100 | 970 entry["location"]["x"] = api_data_table.x * 100 |
| 979 entry["location"]["y"] = dY * 100 | 971 entry["location"]["y"] = api_data_table.y * 100 |
| 980 entry["location"]["floor"] = dFloor | |
| 981 | 972 |
| 982 -- Record simple rewards (XP, money, artifact XP, honor) | 973 -- Record simple rewards (XP, money, artifact XP, honor) |
| 983 entry["rewards"] = {} | 974 entry["rewards"] = {} |
| 984 entry["rewards"]["xp"] = tonumber(_G.GetQuestLogRewardXP(quest_id)) or 0 | 975 entry["rewards"]["xp"] = tonumber(_G.GetQuestLogRewardXP(quest_id)) or 0 |
| 985 entry["rewards"]["money"] = tonumber(_G.GetQuestLogRewardMoney(quest_id)) or 0 | 976 entry["rewards"]["money"] = tonumber(_G.GetQuestLogRewardMoney(quest_id)) or 0 |
| 986 local actualXP, scaling = _G.GetQuestLogRewardArtifactXP(quest_id) | 977 --local actualXP, scaling = _G.GetQuestLogRewardArtifactXP(quest_id) |
| 987 entry["rewards"]["artifact_xp"] = ("%d:%d"):format(tonumber(actualXP) or 0, tonumber(scaling) or 0) | 978 --entry["rewards"]["artifact_xp"] = ("%d:%d"):format(tonumber(actualXP) or 0, tonumber(scaling) or 0) |
| 988 entry["rewards"]["honor"] = tonumber(_G.GetQuestLogRewardHonor(quest_id)) or 0 | 979 entry["rewards"]["honor"] = tonumber(_G.GetQuestLogRewardHonor(quest_id)) or 0 |
| 989 | 980 |
| 990 -- Record currencies | 981 -- Record currencies |
| 991 entry["rewards"]["currency_count"] = tonumber(_G.GetNumQuestLogRewardCurrencies(quest_id)) or 0 | 982 entry["rewards"]["currency_count"] = tonumber(_G.GetNumQuestLogRewardCurrencies(quest_id)) or 0 |
| 992 | 983 |
| 1017 end | 1008 end |
| 1018 | 1009 |
| 1019 | 1010 |
| 1020 function WDP:ProcessWorldQuests() | 1011 function WDP:ProcessWorldQuests() |
| 1021 -- Ignore if player is low level (there are some world quests before max level now, but we can collect enough data from 110s alone still) | 1012 -- Ignore if player is low level (there are some world quests before max level now, but we can collect enough data from 110s alone still) |
| 1022 if _G.UnitLevel("player") >= 110 then return end | 1013 if _G.UnitLevel("player") < 110 then return end |
| 1023 | 1014 |
| 1024 local current_ui_map_id = C_Map.GetBestMapForUnit("player") | 1015 local current_ui_map_id = C_Map.GetBestMapForUnit("player") |
| 1025 local bounty_maps = MapUtil.GetRelatedBountyZoneMaps(current_ui_map_id) | 1016 local bounty_maps = MapUtil.GetRelatedBountyZoneMaps(current_ui_map_id) |
| 1026 | 1017 |
| 1027 -- Iterate over zones in continent | 1018 -- Iterate over zones in continent |
| 1031 local api_data = C_TaskQuest.GetQuestsForPlayerByMapID(bounty_maps[i]); | 1022 local api_data = C_TaskQuest.GetQuestsForPlayerByMapID(bounty_maps[i]); |
| 1032 local continent_ui_map_id = MapUtil.GetMapParentInfo(bounty_maps[i], _G.Enum.UIMapType.Continent) | 1023 local continent_ui_map_id = MapUtil.GetMapParentInfo(bounty_maps[i], _G.Enum.UIMapType.Continent) |
| 1033 | 1024 |
| 1034 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries | 1025 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries |
| 1035 if api_data and type(api_data) == "table" and #api_data > 0 then | 1026 if api_data and type(api_data) == "table" and #api_data > 0 then |
| 1036 for _, current_data in ipairs(api_data) do | 1027 for j = 1, #api_data do |
| 1037 | 1028 |
| 1038 -- Check if we had a valid API table returned to us | 1029 -- Check if we had a valid API table returned to us |
| 1039 if current_data and type(current_data) == "table" and current_data["questId"] then | 1030 if api_data[j] and type(api_data[j]) == "table" and api_data[j].questId then |
| 1040 local quest_id = tonumber(current_data["questId"]) or 0 | 1031 local quest_id = tonumber(api_data[j].questId) or 0 |
| 1041 | 1032 |
| 1042 -- Check if we have quest data | 1033 -- Check if we have quest data |
| 1043 if quest_id > 0 and _G.HaveQuestData(quest_id) and QuestUtils_IsQuestWorldQuest(quest_id) and current_data["mapID"] == bounty_maps[i] then | 1034 if quest_id > 0 and _G.HaveQuestData(quest_id) and QuestUtils_IsQuestWorldQuest(quest_id) and api_data[j].mapID == bounty_maps[i] then |
| 1044 _G.C_TaskQuest.RequestPreloadRewardData(quest_id) | 1035 _G.C_TaskQuest.RequestPreloadRewardData(quest_id) |
| 1045 RecordWorldQuestData(quest_id, continent_ui_map_id, bounty_maps[i], current_data) | 1036 RecordWorldQuestData(quest_id, api_data[j]) |
| 1046 end | 1037 end |
| 1047 end | 1038 end |
| 1048 end | 1039 end |
| 1049 end | 1040 end |
| 1050 end | 1041 end |
