shagu / pfUI

A User Interface Replacement for World of Warcraft: Vanilla & TBC
https://shagu.org/pfUI
MIT License
332 stars 116 forks source link

Consolidate GetPlayerBuff() into a standard api method so that it's 1st parameter 'buffId' will be 1-based like TBC #1290

Open dsidirop opened 1 month ago

dsidirop commented 1 month ago

Current code:

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.

github-actions[bot] commented 3 days ago

This issue is stale because it has been open for 30 days with no activity.