DeadlyBossMods / DBM-Unified

The heart of DBM. This contains the parts of Core, GUI, and DBT that allow all versions of DBM to function.
11 stars 19 forks source link

Missing function C_AddOns.DoesAddOnExist in wotlk leads to spam message. #388

Closed Cabro closed 10 months ago

Cabro commented 10 months ago

Describe the bug C_AddOns.DoesAddOnExist is not present in wrath, possibly in classic either, and as such, DBM-Core.lua:3662 always returns a message to go get the addon pack for dungeons, even if they are already loaded. IsAddOnLoaded is the function used for wrath (and possibly classic too).

Do you have an error log of what happened? Not existent. There is no error. The way it is coded it doesn't pop error.

To Reproduce Enter dungeon. Observe wrong message to go get dungeon pack.

Screenshots With wrong function: image With correct function: image

Did you try having DeadlyBossMods as the only enabled addon and everything else (especially something like ElvUI) disabled? Not relevant.

Which version of DeadlyBossMods are you using? 3.4.56

Was it working in a previous version? If yes, which was the last good one? NA

Additional context Code is also only checking for vanilla dungeon packs. If you play on wrath, it's not checking for wrath dungeon packs, but only checks for vanilla dungeon packs, which makes no sense. At the very least check for all expansion dungeon packs.

        else--Classic
            if instanceDifficultyBylevel[LastInstanceMapID] and instanceDifficultyBylevel[LastInstanceMapID][2] == 2 and not IsAddOnLoaded("DBM-Party-Vanilla") and not IsAddOnLoaded("DBM-Party-BC") and not IsAddOnLoaded("DBM-Party-WotLK") then
                AddMsg(self, L.MOD_AVAILABLE:format("DBM Dungeon mods"))
            end
        end
MysticalOS commented 10 months ago

"Code is also only checking for vanilla dungeon packs. If you play on wrath, it's not checking for wrath dungeon packs, but only checks for vanilla dungeon packs, which makes no sense." They come installed in same pack. it's a catch all. DBM Dungeons ships with all dungeon packs. unless user is installing them all then going through extra effort to manually delete vanilla modules, which is kind of a waste of time since they are load on demand and not impeding any resources.

MysticalOS commented 10 months ago

Also DoesAddOnExist should work in classic cause core emulates the function. so if it's breaking it's probably just case you removed the vanilla mods?

Cabro commented 10 months ago

I have not removed anything. Just verified a small command if DoesAddOnExist actually exists, and it doesn't. That's why it's returning 'false' on that check at line 3662

MysticalOS commented 10 months ago

it wouldn't exist outside of DBM core. it's local emulation


local cachedAddOns = {}
local C_AddOns = {
    GetAddOnMetadata = C_AddOns.GetAddOnMetadata,
    GetNumAddOns = C_AddOns.GetNumAddOns or GetNumAddOns, ---@diagnostic disable-line:deprecated
    GetAddOnInfo = C_AddOns.GetAddOnInfo or GetAddOnInfo, ---@diagnostic disable-line:deprecated
    LoadAddOn = C_AddOns.LoadAddOn or LoadAddOn, ---@diagnostic disable-line:deprecated
    IsAddOnLoaded = C_AddOns.IsAddOnLoaded or IsAddOnLoaded, ---@diagnostic disable-line:deprecated
    EnableAddOn = C_AddOns.EnableAddOn or EnableAddOn, ---@diagnostic disable-line:deprecated
    GetAddOnEnableState = C_AddOns.GetAddOnEnableState or function(addon, character)
        return GetAddOnEnableState(character, addon) ---@diagnostic disable-line:deprecated
    end,
    DoesAddOnExist = C_AddOns.DoesAddOnExist or function(addon)
        if not cachedAddOns then
            for i = 1, GetNumAddOns() do ---@diagnostic disable-line:deprecated
                cachedAddOns[GetAddOnInfo(i)] = true ---@diagnostic disable-line:deprecated
            end
        end
        return cachedAddOns[addon]
    end,
}```
Cabro commented 10 months ago

I see. I assumed you were using https://warcraft.wiki.gg/wiki/API_C_AddOns.DoesAddOnExist . Mea culpa. However something is off, since it's returning false when it should return true. The message to go get dungeon pack should not be displayed, especially when 1 line above it's the message that the dungeon packs are loaded.

MysticalOS commented 10 months ago

https://github.com/DeadlyBossMods/DBM-Unified/commit/dd7dda9ad07ca082e47e40eba11a9ceb80c91d6a solves one problem for good measure.

I asked @emmericp to look into other issue

Cabro commented 9 months ago

image This is back, sadly