local bid = GetPlayerBuff(PLAYER_BUFF_START_ID+id, type)
local stacks = GetPlayerBuffApplications(bid)
Suggested new approach:
local bid = pfUI.api.GetPlayerBuffX(id, type)
local stacks = GetPlayerBuffApplications(bid)
Note: It goes without saying that 'GetPlayerBuffX()' will NOT change the return value 'buffIndex' and we will leave it as-is for vanilla.
That's because if we also translated the returned value into a 1-based index (like in TBC) we would effectively break the rest of the Vanilla API surface that expects the returned 'buffIndex' to be 0-based in case of success and -1 in case of failure.
[ Unless ofcourse we also wrap all other Vanilla API methods like GetPlayerBuffTimeLeft() and so on ... which is an overkill ]
PS: In the context of this change I'll also make some trivial optimizations by consolidating the calls to GetPlayerBuffX() so that it will be called once when the exact same parameters are passed to it in adjacent rows in the code.
Current code:
Suggested new approach:
Note: It goes without saying that 'GetPlayerBuffX()' will NOT change the return value 'buffIndex' and we will leave it as-is for vanilla.
That's because if we also translated the returned value into a 1-based index (like in TBC) we would effectively break the rest of the Vanilla API surface that expects the returned 'buffIndex' to be 0-based in case of success and -1 in case of failure.
[ Unless ofcourse we also wrap all other Vanilla API methods like GetPlayerBuffTimeLeft() and so on ... which is an overkill ]
PS: In the context of this change I'll also make some trivial optimizations by consolidating the calls to GetPlayerBuffX() so that it will be called once when the exact same parameters are passed to it in adjacent rows in the code.