Mercurial > wow > wowdb-profiler
comparison Main.lua @ 540:b7f2e3b03853 7.3.0-1
Update for Patch 7.3.0, including a currency fix, constants update, and TOC bump.
author | MMOSimca |
---|---|
date | Wed, 30 Aug 2017 18:22:40 -0400 |
parents | 1bcaf08ae424 |
children | c6fafd40a7b7 |
comparison
equal
deleted
inserted
replaced
539:1bcaf08ae424 | 540:b7f2e3b03853 |
---|---|
311 return math.floor(copper_cost / modifier) | 311 return math.floor(copper_cost / modifier) |
312 end | 312 end |
313 end -- do-block | 313 end -- do-block |
314 | 314 |
315 | 315 |
316 local CurrencyInfoToID | |
317 local PopulateCurrencyInfoLookup | |
318 do | |
319 local MAX_CURRENCY_ID_GAP = 800 | |
320 | |
321 local currency_info_lookup = {} | |
322 | |
323 | |
324 -- Going to have to support paths until Patch 7.2.5 comes out (after that, the 'tostring' use can go away) | |
325 function CurrencyInfoToID(name, texture_id) | |
326 if not name or not texture_id then return nil end | |
327 return currency_info_lookup[("%s:%s"):format(name, tostring(texture_id))] | |
328 end | |
329 | |
330 | |
331 -- Going to have to support paths until Patch 7.2.5 comes out (after that, the 'tostring' use can go away) | |
332 function PopulateCurrencyInfoLookup() | |
333 local currency_index = 1 | |
334 local gap_since_last_currency = 0 | |
335 repeat | |
336 -- Store ID by info (name and texture_id combined) | |
337 local name, _, texture_id = GetCurrencyInfo(currency_index) | |
338 | |
339 -- If we found nothing, increment gap | |
340 if name and texture_id and name ~= "" and tostring(texture_id) ~= "0" and tostring(texture_id) ~= "" then | |
341 currency_info_lookup[("%s:%s"):format(name, tostring(texture_id))] = currency_index | |
342 gap_since_last_currency = 0 | |
343 else | |
344 gap_since_last_currency = gap_since_last_currency + 1 | |
345 end | |
346 | |
347 -- Increment loop counter | |
348 currency_index = currency_index + 1 | |
349 | |
350 until (gap_since_last_currency > MAX_CURRENCY_ID_GAP) | |
351 end | |
352 end | |
353 | |
354 | |
355 local function InstanceDifficultyToken() | 316 local function InstanceDifficultyToken() |
356 -- Sometimes, instance information is returned when not in an instance. This check protects against that. | 317 -- Sometimes, instance information is returned when not in an instance. This check protects against that. |
357 if _G.IsInInstance() then | 318 if _G.IsInInstance() then |
358 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() | 319 local _, instance_type, instance_difficulty, _, _, _, is_dynamic = _G.GetInstanceInfo() |
359 | 320 |
512 | 473 |
513 local function CurrencyLinkToID(currency_link) | 474 local function CurrencyLinkToID(currency_link) |
514 if not currency_link then | 475 if not currency_link then |
515 return nil | 476 return nil |
516 end | 477 end |
517 return tonumber(currency_link:match("currency:(%d+)")) or 0 | 478 return tonumber(tostring(currency_link):match("currency:(%d+)")) |
518 --texture_path:match("[^\\]+$"):lower() | |
519 end | 479 end |
520 | 480 |
521 | 481 |
522 local function ItemLinkToID(item_link) | 482 local function ItemLinkToID(item_link) |
523 if not item_link then | 483 if not item_link then |
975 -- Gather known languages | 935 -- Gather known languages |
976 for index = 1, _G.GetNumLanguages() do | 936 for index = 1, _G.GetNumLanguages() do |
977 languages_known[_G.GetLanguageByIndex(index)] = true | 937 languages_known[_G.GetLanguageByIndex(index)] = true |
978 end | 938 end |
979 | 939 |
980 -- Populate currency data from known currency information | |
981 PopulateCurrencyInfoLookup() | |
982 | |
983 -- These timers loop indefinitely using Lua's infinity constant | 940 -- These timers loop indefinitely using Lua's infinity constant |
984 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, math.huge) | 941 item_process_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_ITEMS, WDP.ProcessItems, math.huge) |
985 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, math.huge) | 942 target_location_timer_handle = C_Timer.NewTicker(DELAY_UPDATE_TARGET_LOCATION, WDP.UpdateTargetLocation, math.huge) |
986 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, math.huge) | 943 world_quest_timer_handle = C_Timer.NewTicker(DELAY_PROCESS_WORLD_QUESTS, WDP.ProcessWorldQuests, math.huge) |
987 | 944 |
1076 -- 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) | 1033 -- 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) |
1077 if _G.UnitLevel("player") ~= 110 then return end | 1034 if _G.UnitLevel("player") ~= 110 then return end |
1078 | 1035 |
1079 -- Get current continent and zones in current continent | 1036 -- Get current continent and zones in current continent |
1080 local continentIndex, continentID = GetCurrentMapContinent() | 1037 local continentIndex, continentID = GetCurrentMapContinent() |
1081 local continentMaps = { GetMapZones(continentIndex) } | 1038 local continentMaps = { GetMapZones(continentIndex) } |
1082 | 1039 |
1083 -- Iterate over zones in continent | 1040 -- Iterate over zones in continent |
1084 for i = 1, #continentMaps, 2 do | 1041 for i = 1, #continentMaps, 2 do |
1085 | 1042 |
1086 -- Get data for World Quests | 1043 -- Get data for World Quests |
1087 local api_data = C_TaskQuest.GetQuestsForPlayerByMapID(continentMaps[i], continentID); | 1044 local api_data = C_TaskQuest.GetQuestsForPlayerByMapID(continentMaps[i], continentID); |
1088 | 1045 |
1089 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries | 1046 -- Iterate over the questIDs for each map, doing preload reward requests and creating SavedVariables entries |
1090 if api_data and type(api_data) == "table" and #api_data > 0 then | 1047 if api_data and type(api_data) == "table" and #api_data > 0 then |
1091 for _, current_data in ipairs(api_data) do | 1048 for _, current_data in ipairs(api_data) do |
1092 | 1049 |
2551 --price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0) | 2508 --price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0) |
2552 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0) | 2509 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0) |
2553 | 2510 |
2554 for cost_index = 1, item_count do | 2511 for cost_index = 1, item_count do |
2555 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. | 2512 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. |
2556 local texture_id, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index) | 2513 local texture_id, amount_required, hyperlink, name = _G.GetMerchantItemCostItem(item_index, cost_index) |
2557 | 2514 |
2558 -- Try to get item ID | 2515 -- Try to get item ID |
2559 local item_id = ItemLinkToID(item_link) | 2516 local item_id = ItemLinkToID(hyperlink) |
2560 | 2517 |
2561 -- 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 | 2518 -- 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 |
2562 -- Handle cases when the additional cost is another item | 2519 -- Handle cases when the additional cost is another item |
2563 if item_id and item_id > 0 then | 2520 if item_id and item_id > 0 then |
2564 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id) | 2521 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id) |
2565 -- Handle cases when the additional cost is another currency | |
2566 else | 2522 else |
2567 local currency_id = CurrencyInfoToID(name, texture_id) | 2523 -- Try to get currency ID |
2524 local currency_id = CurrencyLinkToID(hyperlink) | |
2568 if currency_id and currency_id > 0 then | 2525 if currency_id and currency_id > 0 then |
2569 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) | 2526 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) |
2527 else | |
2528 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) | |
2570 end | 2529 end |
2571 end | 2530 end |
2572 end | 2531 end |
2573 | 2532 |
2574 for currency_index = 1, #currency_list do | 2533 for currency_index = 1, #currency_list do |