Mercurial > wow > wowdb-profiler
comparison Main.lua @ 537:ec2ee7b48c21 7.2.5-1
Update for 7.2.5 PTR compatibility; 'texture' arguments for currency conversion can be 'string' or 'number' now.
| author | MMOSimca |
|---|---|
| date | Thu, 11 May 2017 21:23:12 -0400 |
| parents | 4a7989584ae8 |
| children | 1bcaf08ae424 |
comparison
equal
deleted
inserted
replaced
| 536:e8e30b0bcf45 | 537:ec2ee7b48c21 |
|---|---|
| 318 local MAX_CURRENCY_ID_GAP = 800 | 318 local MAX_CURRENCY_ID_GAP = 800 |
| 319 | 319 |
| 320 local currency_info_lookup = {} | 320 local currency_info_lookup = {} |
| 321 | 321 |
| 322 | 322 |
| 323 function CurrencyInfoToID(name, texture) | 323 -- Going to have to support paths until Patch 7.2.5 comes out (after that, the 'tostring' use can go away) |
| 324 if not name or not texture then return nil end | 324 function CurrencyInfoToID(name, texture_id) |
| 325 return currency_info_lookup[("%s:%s"):format(name, texture)] | 325 if not name or not texture_id then return nil end |
| 326 end | 326 return currency_info_lookup[("%s:%s"):format(name, tostring(texture_id))] |
| 327 | 327 end |
| 328 | 328 |
| 329 | |
| 330 -- Going to have to support paths until Patch 7.2.5 comes out (after that, the 'tostring' use can go away) | |
| 329 function PopulateCurrencyInfoLookup() | 331 function PopulateCurrencyInfoLookup() |
| 330 local currency_index = 1 | 332 local currency_index = 1 |
| 331 local gap_since_last_currency = 0 | 333 local gap_since_last_currency = 0 |
| 332 repeat | 334 repeat |
| 333 -- Store ID by info (name and texture combined) | 335 -- Store ID by info (name and texture_id combined) |
| 334 local name, _, texture = GetCurrencyInfo(currency_index) | 336 local name, _, texture_id = GetCurrencyInfo(currency_index) |
| 335 currency_info_lookup[("%s:%s"):format(name, texture)] = currency_index | |
| 336 | 337 |
| 337 -- If we found nothing, increment gap | 338 -- If we found nothing, increment gap |
| 338 if not name or not texture or (name == "" and texture == "") then | 339 if name and texture_id and name ~= "" and tostring(texture_id) ~= "0" and tostring(texture_id) ~= "" then |
| 340 currency_info_lookup[("%s:%s"):format(name, tostring(texture_id))] = currency_index | |
| 341 gap_since_last_currency = 0 | |
| 342 else | |
| 339 gap_since_last_currency = gap_since_last_currency + 1 | 343 gap_since_last_currency = gap_since_last_currency + 1 |
| 340 else | |
| 341 gap_since_last_currency = 0 | |
| 342 end | 344 end |
| 343 | 345 |
| 344 -- Increment loop counter | 346 -- Increment loop counter |
| 345 currency_index = currency_index + 1 | 347 currency_index = currency_index + 1 |
| 346 | 348 |
| 2548 --price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0) | 2550 --price_string = ("%s:%s:%s:%s"):format(price_string, battleground_rating, personal_rating, required_season_amount or 0) |
| 2549 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0) | 2551 price_string = ("%s:%s:%s"):format(price_string, personal_rating, required_season_amount or 0) |
| 2550 | 2552 |
| 2551 for cost_index = 1, item_count do | 2553 for cost_index = 1, item_count do |
| 2552 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. | 2554 -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0. |
| 2553 local texture_path, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index) | 2555 local texture_id, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index) |
| 2554 | 2556 |
| 2555 -- Try to get item ID | 2557 -- Try to get item ID |
| 2556 local item_id = ItemLinkToID(item_link) | 2558 local item_id = ItemLinkToID(item_link) |
| 2557 | 2559 |
| 2558 -- 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 | 2560 -- 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 |
| 2559 -- Handle cases when the additional cost is another item | 2561 -- Handle cases when the additional cost is another item |
| 2560 if item_id and item_id > 0 then | 2562 if item_id and item_id > 0 then |
| 2561 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id) | 2563 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id) |
| 2562 -- Handle cases when the additional cost is another currency | 2564 -- Handle cases when the additional cost is another currency |
| 2563 else | 2565 else |
| 2564 local currency_id = CurrencyInfoToID(name, texture_path) | 2566 local currency_id = CurrencyInfoToID(name, texture_id) |
| 2565 if currency_id and currency_id > 0 then | 2567 if currency_id and currency_id > 0 then |
| 2566 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) | 2568 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id) |
| 2567 end | 2569 end |
| 2568 end | 2570 end |
| 2569 end | 2571 end |
