MarioE/InfiniteChests — pull request #7 by Olink (2014-10-11 16:44:23+00:00)
Title: Implement Hack to fix Terraria overloading this plugin when using the loot all button.

When a user uses the loot all option, it sends a shitton of packets, which overload this plugin. It takes roughly 3-5 seconds to handle this load on the server end, on a perfectly underloaded server, so I imagine this can take infinitely longer on production servers. This delay does not get reflected to the user, so they think its been looted as soon as they click the button, so they close the window. Closing the window sends a new packet to the server closing the chest, this sets the players active chest to -1,-1. This causes the queued up chest modification actions to all fail, resulting in duplication in the user inventory and the chest. This can be done almost immediately resultign in 100% duplication or slowly resulting in partial duplication. This pull request adds the following
1) I added a transactions count, so that every time a chest item packet is sent, we increment the transaction count, and everytime we actually attempt to modify the chest due to that action, we decrement.
2) If the user closes the chest before it is done doing the transactions, it no longer sets the players chest to -1,-1. It however sets a flag on the player that when all transactions are complete to set the x,y.
3) If transactions are in progress, the player cannot open any chests that would result in breaking the x,y.
4) When the last transaction is completed, we check the flag and set x,y to -1 should it be set.