1. Hey i hope someone can help me with the issue im having. Its basically i would like to change the way how the default raid frame sort works.

    So i would like to change the behavior of the following function from the default raid frame Blizzard_CompactRaidFrameManager.lua

     function CRFSort_Group(token1, token2)
         if ( GetNumRaidMembers() > 0 ) then
             local id1 = tonumber(string.sub(token1, 5));
             local id2 = tonumber(string.sub(token2, 5));
             if ( not id1 or not id2 ) then
                 return id1;
             local _, _, subgroup1 = GetRaidRosterInfo(id1);
             local _, _, subgroup2 = GetRaidRosterInfo(id2);
             if ( subgroup1 and subgroup2 and subgroup1 ~= subgroup2 ) then
                 return subgroup1 < subgroup2;
             --Fallthrough: Sort by order in Raid window.
             return id1 < id2;
             if ( token1 == "player" ) then
                 return true;
             elseif ( token2 == "player" ) then
                 return false;
                 return token1 < token2;  --String compare is OK since we don't go above 1 digit for party.

    Is it even possible to override a function or need i listen to a specific api event. Im a web developer and i have some general knowledge in programming but im a newbie in LUA.

    Someone have an idea how i can solve this issue ? I appreciate your detailed help.


    Looking at the code, simply redefining it, then calling CompactRaidFrameContainer_SetFlowSortFunction should work.

    function CRFSort_Group(token1,token2)
        -- your code
    CompactRaidFrameContainer_SetFlowSortFunction(CompactRaidFrameManager.container, CRFSort_Group);

    PS: Indent a block of text to have it show as code.

    Thank you stolenlegacy for your quick reply.

    Sorry for this dumb questions. But if i create a new addon and redefining the function, how can i be sure that my addon gets executed after the blizzard one ?

    And whats the difference between redefining the function or use the Hooking method ?

    Thanks in advance

    Redefining overrides the previous one, preventing its execution. (Actually, it only replaces the memory pointer in the global variable with one to the new functions, so any addons that took a local reference to the old function won't be affected. Blizzard almost never does that though.) Hooking would mean your function is called after the original one with the same arguments.

    To make sure your addon is executed after the Blizzard one, simply using LoadAddOn("Blizzard_CompactRaidFrames") should do the trick.

    Thanks a lot for your detailed explanation.

    I have now created a new addon with this functionality and it works exactly like i want it. (Tested in a two member raid in the city)

    But if i play a battleground with my addon active it throws sometimes a LUA error located in the blizzard scripts. After I researched the internet i think its a problem with some "protected/private" blizzard functions.

    For test purposes i have hooked my custom function with the hooksecurefunc("xx", yy); method and added some print() outputs to make sure all my custom code works well. The behavior now is like you said, the function gets executed but dont override the existing one. I tried this script in a battleground too and all debug outputs are ok and no LUA error anymore.

    So im pretty sure it has somthing to do with the "protected/private" function scope.

    My question is now: Is it even possible to override/redefining a function and maintain the protected/private scope ? Or are there any other solutions for this problem ?

    Thanks in advance

    Hm, I wasn't aware that they were using protected functions for raid frame sorting. In that case, as you noticed, overriding the function will taint the code that calls it.

    All code coming from a non-Blizzard addon is tainted (insecure) by default. There's nothing you can do about that, and it's what hooksecurefunc was made for.

    Thank you again stolenlegacy.

    The problem was that the raid frame needs to update in combat (someone joins or leaves raid) often occured in battlegrounds.

    The method issecurevariable("CompactRaidFrame1") showed me that my own addon is tainting the raid frames. Unfortunately my sort function depends on the possibility to return its values, and thats not the case with hooksecurefunc.

    I think i found a workaround to replace the sort function without allowing WOW to track it as tainting (eventually a bug).

    [Description deleted]

    Um.. You cannot provide a new sort function to the default raid frames without tainting. It's positively impossible, so if you think you've done it, it means you just haven't broken it yet =)

    This is an intentional limitation of the system and won't ever be implemented or relaxed.

    I'm not sure I follow what you did, lucene. Are you saying you managed to somehow allow your own function to run securely? That effectively should not happen. Could you provide your code?

    Thanks for your interest again.

    I dont think its a good idea to post my code in a public place until i know for sure whats up with it.

    I have taken some screenshots, so you can actually see what it does, and why i think it doesnt taint any blizzard code. All screens are taken from the latest MOP Beta 5.0.3

    So basicaly what my addon does: It allows me to sort the first five raid members in my party order (like in a 5 man group). So i have a fixed order for the first five people in my raid and i can use binds like "tar player/party1/party2..." in a matching order. I need this mainly in arenas.

    Dropbox - Screenshots

    1. Addon loaded / custom sort deactivated (Raid leader has position #1) / no tainting
    2. Addon loaded / custom sort activated (Player has position #1) / no tainting
    3. Like pic 1, with open raid frame setting
    4. Like pic 2, with open raid frame setting

    So like you can see i havent changed my raid frame settings and my custom sort is active but the /run print(issecurevariable("CompactRaidFrame1")) macro tells that nothing is taintig the raid frames. I dont get the raid frame curruption bug too.

    In my first tests with just redefining the function i got the raid frame corruption bug and the macro told me that my addon is tainting the frames.

    Am i missing something ? Or are there other ways to find out if i broke something ?

    Regards Lucene

    Yeah this shouldn't be possible, so either its not working the think its working or you've found an exploit. I suggest you post some code so we can see what you're doing.