valheimPlus / ValheimPlus

A HarmonyX Mod aimed at improving the gameplay and quality of life of the game Valheim.
http://valheim.plus
GNU Affero General Public License v3.0
967 stars 236 forks source link

[BUG] Chest emptied when auto deposit honey turned on - intermittent issue #675

Open ohrickster opened 2 years ago

ohrickster commented 2 years ago

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

nxPublic commented 2 years ago

Single-player or Multi-player ?

ohrickster commented 2 years ago

I've seen this issue happen on a single-player world (local windows client) and a multi-player dedicated server but have not been able to duplicate it manually. I'm attempting to replicate it by filling a chest with stones and leaving a few slots open for honey deposit to see if it happens again.

On Mon, Feb 7, 2022 at 4:32 AM nX_ @.***> wrote:

Single-player or Multi-player ?

— Reply to this email directly, view it on GitHub https://github.com/valheimPlus/ValheimPlus/issues/675#issuecomment-1031253769, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHCIKM26WRAEASSAJKGUPTTUZ6GTLANCNFSM5NWBWGHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

bgoosen commented 2 years ago

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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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):