changeset 519:2325dbe5c10a

Fixed merchant cost detection for items that cost items (i.e. Tricky Treats, Darkmoon Daggermaw, etc).
author MMOSimca <mmosimca@gmail.com>
date Tue, 08 Nov 2016 19:05:42 -0500
parents 0635db205d44
children 3fee2a08fdaa
files Main.lua
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Main.lua	Tue Nov 08 19:03:54 2016 -0500
+++ b/Main.lua	Tue Nov 08 19:05:42 2016 -0500
@@ -2557,12 +2557,17 @@
                         -- The third return (Blizz calls "currency_link") of GetMerchantItemCostItem only returns item links as of Patch 5.3.0.
                         local texture_path, amount_required, item_link, name = _G.GetMerchantItemCostItem(item_index, cost_index)
 
-                        -- Try to detect if this is actually a currency by looking for a nil item_link or item ID
-                        local is_currency = (not item_link) or (not ItemLinkToID(item_link))
-
-                        if is_currency then
+                        -- Try to get item ID
+                        local item_id = ItemLinkToID(item_link)
+
+                        -- 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
+                        -- Handle cases when the additional cost is another item
+                        if item_id and item_id > 0 then
+                            currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, item_id)
+                        -- Handle cases when the additional cost is another currency
+                        else
                             local currency_id = CurrencyInfoToID(name, texture_path)
-                            if currency_id and currency_id ~= 0 then
+                            if currency_id and currency_id > 0 then
                                 currency_list[#currency_list + 1] = ("(%s:%d)"):format(amount_required, currency_id)
                             end
                         end