Jump to content

Items Deleted

Closed 1.0.5 1.0.6

Zoreeno
Zoreeno

Posted

Hey there. My players reported an issue to me that I was able to replicate on my test server. The issue is that if you have the Bag Of Holding bag completely full and gather mode is enabled it will delete items if you try to drag/drop an item into the BOH from your main inventory. It only happens when gathering is enabled on a full bag. 

I thought maybe i had set something wrong in the config and/or i have another plugin that might be conflicting. So to be sure, I loaded up my test server with all plugins removed except BOH and generated a default config (the only change i made to the default config was set "Enable Gathering Mode" to true (was default on false). The issue still occurs. 

I've provided a clip showing the issue if that helps. 

https://streamable.com/euv1j5

  • Like 2
BlackLightning

Posted

Thanks for reporting. I appreciate you taking the time to record it and test it with no other plugins installed. I'll take a look right now.

  • Like 2
BlackLightning

Posted (edited)

Okay, I think I see what's going on here.

When you drag an item directly onto an item in a bag, the game tries to perform a swap. Let's say you dragged a snowball gun on to a muzzle brake. The first step in the swap is to remove the snowball gun from your inventory, placing it in temporary limbo. The second step is moving the muzzle brake from the bag to your inventory where the snowball gun was previously. Due to gather mode, that instantly moves the muzzle brake back into the bag. The third step is to move the snowball gun into what the game expects to be an empty slot in the bag. Unfortunately, that slot is occupied by the muzzle brake, so the item goes into permanent limbo. Ideally the Rust logic for item swaps would handle that case, but it does not. In the case that the item that was originally in the bag (the muzzle brake) can stack with another item in the bag, then it would get added to one of those stacks, successfully freeing a slot for the item being moved (the snowball gun), but that doesn't happen in your video because none of those items can be stacked. Even if you did configure those items to stack, this issue would still happen if the stack limit had been reached for all stacks of that item.

This is similar to an issue with kit bags which I mitigated a few weeks ago, where if you dragged an item onto the last item in the kit bag to perform a swap (which ideally shouldn't be allowed, bust Rust tries to do anyway), when the item in the kit bag was removed from the bag, the bag would be deleted, and the original item would go into permanent limbo. That issue was resolved by delaying deletion of the kit bag, and at the time, I also fixed the issue where players could swap items, by detecting the unexpected item being added to the kit bag and auto removing (moving it to the parent container).

As for how I can fix this specific bug, one approach would be to have the bag remember the last item that was in it, and to reject gathering that specific item in the same server frame. Doing so will ensure that the slot the item came from is free when Rust tries to move an item there during a swap. I actually experimented with this approach previously, as a Quality of Life feature to make it so you could remove an item from a bag that is in gather mode without it getting pulled back into the bag. I didn't complete that feature because its initial implementation was inconsistent. By that, I mean if the item was moved from a bag to the bag's parent container, it would avoid being pulled back in, as expected, but other bags could still gather it, which generally wasn't desired. I wanted to avoid a potentially inconsistent/confusing experience. Given this item loss bug, I will see if I can add back the partially working implementation of that feature, since it should mitigate this issue.

Edited by BlackLightning
  • Like 1
Zoreeno

Posted

Hey thanks for the quick check and the detailed explanation! That makes perfect sense as to why it's happening. I won't pretend to know anything about coding a plugin of this scale, but would it be easier to write something in that auto disables gather mode when the bag is full? Or could that cause other issues in itself? 

  • Like 1
BlackLightning

Posted

That's an interesting idea. One issue with that approach is that "bag is full" depends on the stack size of every item in the bag. Every time the contents of the bag change, the plugin would have to recalculate whether the bag is full, which could add some performance cost.

I now remember the other reason that I didn't ship the feature for preventing gathering of the last removed item. It didn't work when splitting a stack, since the way splitting works is that it creates a new item with a partial amount and moves that into the container target container (to the inventory). The plugin can't easily determine that the newly created item came from the bag, without more hooks, more overhead, and significantly more potential for conflicting with other plugins.

I just now released v1.0.6 which should fix this issue. Thanks again for reporting!

  • Like 1
Zoreeno

Posted

I figured that having it detect if the bag is full was more complicated that it seems haha. 

I'll give your newest update a quick test before I head to bed and let ya know

  • Like 1
Zoreeno

Posted

Works good. I'll let the players try to break it, but I'm pretty confident that you got. it. Thanks for being so quick to identify and fix the issue. 

  • Like 1
BlackLightning

Posted

No, thank YOU for creating such a detailed report. You investigated the issue your players reported, you determined the exact steps to recreate the issue, you verified it wasn't a plugin conflict, and you recorded a video showing when it does and doesn't happen. That is AMAZING!!

1.4m

Downloads

Total number of downloads.

6.9k

Customers

Total customers served.

102.1k

Files Sold

Total number of files sold.

2m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.