RaiderIO / raiderio-addon

RaiderIO AddOn
https://raider.io/addon
Other
41 stars 22 forks source link

Constant errors after update #143

Closed skwurw closed 4 years ago

skwurw commented 4 years ago

Keep getting the same error when viewing groups in LFG and people outside of groups. Link to error: https://wago.io/xFq3OxGz4 I do use premade group filter and theunderminejournal and even after turning them both off, still get the errors.

Vladinator commented 4 years ago

It appears that another addon or probably a weakaura is editing the dungeon table within RIO that causes the addon to error later.

I think this because I see the dungeon contains properties like index, upgrade, level, short that are not part of the native RIO environment but they are in the error at the bottom. Please try turn off Weakauras temporarily just to see if that helps stop these errors, if not any other addons that are RIO or LFD or keystone related that you use?

skwurw commented 4 years ago

Alright it was weakauras and fond the one causing the issues. Thanks for the reply

Vladinator commented 4 years ago

Glad you did. I am curious which one it is if you want to let me know I'd appreciate it and take a look what it does. 👍

gaveer commented 4 years ago

i would say Dungeon RIO and Classes and might been fix on the 1.0.10 version . try update the Weakaura

skwurw commented 4 years ago

The aura causing the issue is something I have made myself Function here just returns info from RaiderIO.GetProfile in my own way to read it (still learning lua when I was first making this) Did a check and found out the _profile['max_dungeon'].lfd_activity_ids = nil; is what is causing the issue but don't really understand why.

-- Get RadierIO info
local function RIO(name)
    local profile, _profile, timed, score, upgrades, shortName = _, {}, {}, {}, {}, '';
    local curScore,previous,prevScore;
    local faction = UnitFactionGroup('Player') == 'Alliance' and 1 or 2; -- 1 is alliance and 2 is horde
    if (not RaiderIO or not RaiderIO.GetProfile) then -- Check if RaiderIO is found
        return nil; -- Return nil if we don't have RaiderIO
    end

    --Get M+, Max Dungeon upgrades/name/level
    profile = RaiderIO.GetProfile(name,faction);

    if not profile or not profile.mythicKeystoneProfile.hasRenderableData then
        return nil;
    else
        profile = profile.mythicKeystoneProfile;
    end

    upgrades = profile.dungeonUpgrades[profile.maxDungeon.index];
    shortName, maxL = profile.maxDungeon.shortNameLocale, profile.maxDungeonLevel;
    previous = profile.mplusPrevious == nil; -- True or False
    prevScore = (not previous and profile.mplusPrevious.score or nil);
    curScore = profile.mplusCurrent.score;

    --Get timed dungeons
    timed['five'] = profile.keystoneFivePlus;
    timed['ten'] = profile.keystoneTenPlus;
    timed['fifteen'] = profile.keystoneFifteenPlus;
    timed['twenty'] = profile.keystoneTwentyPlus;

    --Get Score and Color
    --If score is lower then 500 and there is a previous score set it to previous score.
    score['value'] = ((curScore < 500 and prevScore > 0) and prevScore or curScore);
    score['color'] = {RaiderIO.GetScoreColor(score['value'])};

    _profile['prev_score'] = {
        ['value'] = prevScore,
        ['color'] = {RaiderIO.GetScoreColor(prevScore)}
    };
    _profile['score'] = score;
    _profile['max_dungeon'] = profile.maxDungeon;
    _profile['max_dungeon']['upgrade'] = repeats('+',upgrades);
    _profile['max_dungeon']['short'] = repeats('+',upgrades)..maxL..' '..shortName;
    _profile['max_dungeon'].level = maxL;
    _profile['max_dungeon'].lfd_activity_ids = nil;
    _profile['timed'] = timed;

    return _profile;
end
Vladinator commented 4 years ago

The reason for this is because the data returned from RaiderIO.GetProfile is a table and it contains a lot of references to shared tables like the dungeon information, to avoid having multiple copies of the same data we reuse existing dungeon table everywhere including in the player profiles. And because lua always makes references to existing tables when you assign variables it means later in the code you edit the shared dungeon table. _profile['max_dungeon'] = profile.maxDungeon; this line doesn't copy but just refer to the existing dungeon from RIO, then you edit it by adding upgrade, short, level and delete lfd_activity_ids and later RIO will need that data and it errors. I can recommend to specifically do something like this if you need data from profile.maxDungeon but to not change it:

_profile.max_dungeon = {
    name = profile.maxDungeon.name, -- copy the name to this new table
    shortName = profile.maxDungeon.shortName, -- copy the short name to this new table
    upgrade = repeats('+',upgrades), -- add custom stuff to this new table:
    short = repeats('+',upgrades)..maxL..' '..shortName,
    level = maxL,
}