wow-addon / Broker_CurrencyFlow

Keeps track of current money and other currencies on all your characters on one realm
https://www.curseforge.com/wow/addons/broker_currencyflow
5 stars 6 forks source link

Currency Names #10

Closed DreadfulSanity closed 1 month ago

DreadfulSanity commented 3 years ago

I cannot figure out why that is the case, but the currency names in the settings > columns section are the name of the character that is logged in. When I delete the saved variables settings, first char is fine. Logging into the next character results again in all currencies named after my character. Archaeology fragments are named properly. Everything else looks like this:

grafik

davidcraig commented 3 years ago

Yea I've seen this happen too, very curious bug, no idea how/why it happens, I first noticed it in pre-patch where all the currencies became "Korrak's Revenge" - https://github.com/wow-addon/Broker_CurrencyFlow/issues/7 - i'll keep an eye out.

Rubio9 commented 3 years ago

I have a fix for this - you're referencing a variable "name" that is never set in Currencyflow:LoadCurrencies(). I also refactored the function a bit to do what you were doing already but with considerably less repetition of the code. See below.

-- This function tries to update the currencies list with client info
function Currencyflow:LoadCurrencies()
  for id,currency in pairs(tracking) do
    local name, icon
    if currency.type == TYPE_CURRENCY then
      local currencyInfo = C_CurrencyInfo.GetCurrencyInfo(id)
      if currencyInfo ~= nil then
        name = currencyInfo.name
        icon = currencyInfo.iconFileID
      end
    elseif currency.type == TYPE_ITEM then
      name, _, _, _, _, _, _, _, _, icon, _ = GetItemInfo(id)
    elseif currency.type == TYPE_FRAGMENT then
      local name, icon, _, _ = GetArchaeologyRaceInfo(currency.index)
      -- Another dumb marvel of blizz consistency. When info
      -- is not available, instead of returning nil or "",
      -- this one puts "UNKNOWN" in the name.... sigh...
      if icon == nil or icon == "" then
         name = nil
      end
    end

    if name ~= nil and name ~= "" then
       currency.name = name
    else
       currency.name = "|cff999999"..currency.name.."|r"
    end

    if icon ~= nil and icon ~= "" then
       currency.icon = icon
    else
       currency.icon = ICON_QM
    end
  end
end