Stanzilla / WoWUIBugs

World of Warcraft UI Bug Tracker
153 stars 7 forks source link

[DF/TWW] GetServerExpansionLevel() sometimes returns 0 #586

Open exochron opened 1 week ago

exochron commented 1 week ago

I've noticed that the function GetServerExpansionLevel() can sometimes return 0. For me that only happens during the first Login of a freshly started Client.

I was able to recreate this in DF and on the TWW PTR. (no beta access >.<) Cata Classic works as expected though.

Demo:

local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN")
frame:SetScript("OnEvent", function()
    print("OnLogin")
    print("ExpansionLevel: ", GetExpansionLevel()) -- -> 9
    print("ServerExpansionLevel: ", GetServerExpansionLevel()) -- -> 0
    C_Timer.After(0, function()
        print("OnNextFrame")
        print("ExpansionLevel: ", GetExpansionLevel()) -- -> 9
        print("ServerExpansionLevel: ", GetServerExpansionLevel()) -- -> 9
    end)
end)

To avoid this bug you can either delay your script a bit (like in the demo) or you could use GetExpansionLevel() as fallback instead.

Nevcairiel commented 1 week ago

All information not being immediately available is not uncommon. Might need a later event, maybe PLAYER_ENTERING_WORLD