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

[BUG] Withdrawing large quantities of stacked items from the bank causes the server to crash. #336

Closed
src52 opened this issue Jul 30, 2021 · 1 comment · Fixed by #339
Closed
Labels
bug Something isn't working

Comments

@src52
Copy link
Contributor

src52 commented Jul 30, 2021

Describe the bug
When stacked items are withdrawn from the player's bank, a for-loop adds the items to the player's inventory one-by-one. When each new item of the stack is added, the container is updated with this._containerUpdated.next() causing the server to crash if withdrawing large quantities of items due to the large amount of refresh calls.

To Reproduce
Steps to reproduce the behavior:

  1. Open the bank.
  2. Withdraw a large amount of stacked items.
  3. The server becomes unresponsive, (especially if you have items in your inventory that aren't registered with the server. Console gets flooded with item warning messages.)

Expected behavior
A single inventory add/change, instead of X amount of changes for stacked items.

Solution
In bank.plugin.ts:173, remove the for-loop and change playerInventory.add({ itemId: itemIdToAdd, amount: 1 }); to playerInventory.add({ itemId: itemIdToAdd, amount: countToRemove });

@src52 src52 added the bug Something isn't working label Jul 30, 2021
@SchauweM
Copy link
Collaborator

Thanks for reporting this bug @src52! Feel free to make a PR with your proposed solution if you havn't already.

If not, we'll try to apply a fix with your suggested solution ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants