[go: nahoru, domu]

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] Chest emptied when auto deposit honey turned on - intermittent issue #675

Open
ohrickster opened this issue Feb 7, 2022 · 6 comments
Labels
bug Something isn't working in progress development is in progress for bug or feature

Comments

@ohrickster
Copy link
  • OS: Windows Client or Server
  • Valheim Game Version: 0.206.5
  • V+ Mod Version: [Valheim Plus 0.9.9.7]

Twice I have been playing with the configuration of auto-deposit of honey from hives into a nearby chest.
Most of the time this works flawlessly however, I believe when the chest is full, (chests extended) the chest is emptied the next time it is opened. The first time this happened was on a windows server (dedicated headless client) and the second time was a solo windows client.

I had just made serpent stew which requires mushrooms and I know I had mushrooms in that chest. I opened the chest to deposit some more supplies and the only thing left in there was honey.

To Reproduce
I am not sure what is triggering this and I have seen it happen twice but have not been able to manually reproduce it.

Configuration:
https://pastebin.com/dZCPcm3c

Additional context

The only other mod I have installed is the "ore support" mod

@ohrickster ohrickster added the bug Something isn't working label Feb 7, 2022
@nxPublic nxPublic added the in progress development is in progress for bug or feature label Feb 7, 2022
@nxPublic
Copy link
Member
nxPublic commented Feb 7, 2022

Single-player or Multi-player ?

@ohrickster
Copy link
Author
ohrickster commented Feb 7, 2022 via email

@bgoosen
Copy link
bgoosen commented Mar 4, 2022

Just saw something very similar to this happen, for the second time now, with a chest next to a smelter with AutoDeposit and AutoFuel on. The chest and smelter hopper are both at their default size.

Both times, it happened when dropping several stacks of iron scrap. Both times I was hardly paying attention and even second guessed what I was seeing, but this time I was sure I had about 3.5 stacks of ore, and suddenly there was only a half stack of ore between the smelter's hopper and the chest. This was on my friend's server, so not sure of it's details.

We're not using any mods other than Valheim Plus.

@ghost
Copy link
ghost commented Mar 7, 2022

Just saw something very similar to this happen, for the second time now, with a chest next to a smelter with AutoDeposit and AutoFuel on. The chest and smelter hopper are both at their default size.

Both times, it happened when dropping several stacks of iron scrap. Both times I was hardly paying attention and even second guessed what I was seeing, but this time I was sure I had about 3.5 stacks of ore, and suddenly there was only a half stack of ore between the smelter's hopper and the chest. This was on my friend's server, so not sure of it's details.

We're not using any mods other than Valheim Plus.

Same here!

Deposited around 600 Wood in the chest next to our Kiln in order to turn it into Coal.
Wood is gone, but not added up into the Kiln. So all my wood collection went to dust :(

@Astarosa
Copy link
Astarosa commented Feb 15, 2023

Encountered the same issue.

A full chest of meat. All is gone in Narnia and i found 4 honey in. Not the first time it append to me, in every games since i use this mod i have issues like that but i just found why (i had doubts on the auto deposit with the honey).

But i'm not sure if the honey is the source of the problem. I had a similar issue with a stack of BlackMetal who disappear for no reasons in a chest of my foundry. Sure it's relative to the auto fuel / deposit.

Reproduction case for the Honey : Nothing more than what i explain before. The chest was full and a random drop of honey replaced the contents of the chest by 4 honey.

Reproduction case for BlackMetal : i put a part of a stack with a part of an another stack in my not full chest. At the same time the auto fuel took something (in my case coal or silver) and all the new added BlackMetal disappear (not the already present one). Just to precise it's a classic foundry ofc so it can't be fuelled with BlackMetal.

So maybe it's the same bug or it's 2 differents one but there is something with the auto deposit / fuel.

@Grantapher
Copy link
Grantapher commented Feb 15, 2023

Looks like auto-deposit could use a refactor. Chests only allow one person to use them at a time, which likely means there is no conflict resolution on the server for multiple changes at once, and thus the latest change is accepted. Additionally, the entire contents of the chest is written at once, so if a user adds a stack of iron to the chest and the auto deposit does at the same time, whichever is accepted latest is the one that persists. So, either the new inventory with +4 honey is added, or the +30 iron, but not both. This race condition is compounded by the fact that the mod adds one item at a time and updates the server after each item. This doesn't affect most of the uses that only drop one item at a time, but honey drops 4 at a time and this number could be modified by the mod itself. This gives more opportunities for user changes to get clobbered as the window for conflicts is larger.

I've seen this work the opposite way for myself as well, I've taken a stack of iron out of a chest being deposited to and duped a stack of iron on accident.

So, a couple options off the top of my head (I haven't investigated the code too thoroughly, so these may not be feasible if I have a misunderstanding):

  • No changes
    • race conditions between auto deposit and players persist, causing items to disappear when auto-deposit happens at the same time a player interacts with a chest.
  • Allow for dropping multiple items at once into inventory
    • only really affects honey
    • lowers chances for race conditions, but they still can and will happen. So this only mitigates the issue a little.
  • Auto deposit doesn't deposit into chests the player is using.
    • Container.isInUse() and Container.setInUse() exists for this, not sure if they are feasible.
    • Possible behaviors:
      • items could be dropped in the next available chest
        • Could be confusing for players
      • items could be skipped, dropped at the next possible time
        • makes sense for honey, not sure about other single drop use cases like smelter. Would the items just be lost if they are skipped?
      • drop items to ground instead?
        • Also could be confusing for players.
  • Kick player out of chest when auto-deposit happens
    • similar functionality exists for when a player is too far away from a container, the game will kick them out.
    • Annoying to get kicked out of the chest, but is it better than losing an inventory of iron..?
    • May still be race condition-prone, will the player for sure get kicked out of the chest before they deposit items?
    • If someone sets a producer to deposit every second, this could lock people out of the chest until the producer finishes all the items it is working on.
  • Server-side conflict resolution of multiple inventory changes
    • complicated to implement, bug-prone still, likely not feasible. I believe it would require storing more data than is stored currently to track conflicting changes.

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

No branches or pull requests

5 participants