Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C_Item.ConfirmNoRefundOnUse() is sometimes protected and sometimes usable. #698

Open
KyrosKrane opened this issue Dec 20, 2024 · 0 comments

Comments

@KyrosKrane
Copy link

Summary:

When a user purchases an item from a vendor, and that item is still refundable, and the user tries to use that item, the game will pop up a confirmation dialog. Clicking Okay on the dialog ultimately calls C_Item.ConfirmNoRefundOnUse(). Addons can automate the confirmation by calling the same function. However, the function will sometimes work without errors and sometimes issue a protected error.

There is no way for an addon to know in advance whether the C_Item.ConfirmNoRefundOnUse() call will be protected or permitted. The event triggered and dialog displayed are both identical. The event does not have a payload that could identify the protection state.

There is no way for an addon to test whether the use of this call with a specific item will cause an error, nor is there a reasonable way to catch and suppress the protection error. This means that if an addon tries to automate handling this dialog, the user could unpredictably get a protection error, leading to a bad user experience.

It is also worth considering if there is an actual benefit in protecting this function.

Reproduction steps:

Both scenarios assume a character that has not learned the mentioned item. Both scenarios assume no addons are installed, although in a real usage example, the final /run step of each scenario would normally be replaced by an addon responding to the event in step 4.

Scenario 1: No error

  1. Purchase the item Preserved Deep-Dweller's Staff from Aeden Braesmeld in Hallowfall.
  2. Note that the item has text indicating it is still refundable.
  3. Right click the item in your bag to use it.
  4. The game fires the event USE_NO_REFUND_CONFIRM
  5. The event causes a static popup of type USE_NO_REFUND_CONFIRM to appear.
  6. In the chat box, execute this command to simulate clicking Okay to learn the item. This invokes the dialog's :OnAccept() function, which ultimately calls C_Item.ConfirmNoRefundOnUse().
    /run StaticPopupDialogs["USE_NO_REFUND_CONFIRM"]:OnAccept()

Result: Doing this via /run or in an addon works correctly and without error.

Scenario 2: Error

  1. Purchase the item Alchemy Lab, Level 2 from Sparz Boltwist or Rezlak in your Draenor garrison.
  2. Note that the item has text indicating it is still refundable.
  3. Right click the item in your bag to use it.
  4. The game fires the event USE_NO_REFUND_CONFIRM
  5. The event causes a static popup of type USE_NO_REFUND_CONFIRM to appear.
  6. In the chat box, execute this command to simulate clicking Okay to learn the item. This invokes the dialog's :OnAccept() function, which ultimately calls C_Item.ConfirmNoRefundOnUse().
    /run StaticPopupDialogs["USE_NO_REFUND_CONFIRM"]:OnAccept()

Result: Doing this via /run or in an addon generates an error (e.g., from /run: "[ADDON_ACTION_FORBIDDEN] AddOn '*** ForceTaint_Strong ***' tried to call the protected function 'ConfirmNoRefundOnUse()'."

Full sample error:

1x [ADDON_ACTION_FORBIDDEN] AddOn '*** ForceTaint_Strong ***' tried to call the protected function 'ConfirmNoRefundOnUse()'.
[string "@!BugGrabber/BugGrabber.lua"]:485: in function <!BugGrabber/BugGrabber.lua:485>
[string "=[C]"]: in function `ConfirmNoRefundOnUse'
[string "@Blizzard_StaticPopup_Frame/Mainline/StaticPopup.lua"]:1903: in function `OnAccept'
[string "StaticPopupDialogs["USE_NO_REFUND_CONFIRM"]:OnAccept()"]:1: in main chunk
[string "=[C]"]: in function `RunScript'
[string "@Blizzard_ChatFrameBase/Mainline/ChatFrame.lua"]:2304: in function `?'
[string "@Blizzard_ChatFrameBase/Mainline/ChatFrame.lua"]:5492: in function <Blizzard_ChatFrameBase/Mainline/ChatFrame.lua:5438>
[string "=[C]"]: in function `ChatEdit_ParseText'
[string "@Blizzard_ChatFrameBase/Mainline/ChatFrame.lua"]:5144: in function <Blizzard_ChatFrameBase/Mainline/ChatFrame.lua:5143>
[string "=[C]"]: ?
[string "=[C]"]: in function `ChatEdit_SendText'
[string "@Blizzard_ChatFrameBase/Mainline/ChatFrame.lua"]:5180: in function `ChatEdit_OnEnterPressed'
[string "*ChatFrame.xml:140_OnEnterPressed"]:1: in function <[string "*ChatFrame.xml:140_OnEnterPressed"]:1>

Locals:
_ = Frame {
}
event = "ADDON_ACTION_FORBIDDEN"
events = <table> {
}

Suggested resolutions:

  1. The function C_Item.ConfirmNoRefundOnUse() is always permitted.
  2. The function C_Item.ConfirmNoRefundOnUse() is always protected.
  3. The event USE_NO_REFUND_CONFIRM is modified to add a payload that informs the listening addon whether the function will be permitted or protected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant