ChaosMarc/PlugY

Playing with multiple local chars via tcp/ip can result in item loss

Closed this issue · 5 comments

Host with A and join with B. Put something in the shared stash with B and leave the game. The stash is still unchanged for A. Leave the game with A -> The item is lost

When you play, Char A & B both have a full copy of THE shard stash file into memory. Every time you have one leave game, the shared stash data in memory will write to file.That's why you lost your item.

1.A & B start the game. Both have a copy of the shard stash file into memory.
2.B put some thing in B's shared stash data in memory and leave game .the item will write to the shared stash file correctly.
3.When A leave game, A's shared stash data(not changed since game start) OVERWRITE the shared stash file.You lost B's item in the shared stash.

yep that's correct. My assumption was that the host is always the last player that leaves. Not exactly sure whose stash will be saved when the host leaves the game when other players are still present. I guess it will be a racing condition problem and will maybe lead to errors as multiple processes try to write to same file simultaneously.

I've already spoken with @markm11 about this and he will look into it. Maybe he can find a way of synchronizing the stash for all local chars.

Well I have spent some time on this and there is no good way to implement this.
The biggest problem is the shared stash. I have tried to create a global stash during runtime that all characters can access. This is not easy because of way plugy handles the shared stash for each client.

The workaround to do this for local tcp/ip games is to handle the same way if you run a true tcp/ip game. Trade items between characters and make sure you give the items to the last character leaving.

That was what I feared but nevertheless thank you very much for confirming it. I will add a warning to the readme and release a new version in a few days

With v14.00 (https://github.com/ChaosMarc/PlugY/releases/tag/v14.00) the shared stash is disabled for MP by default which should prevent accidental item loss