Open shuhaowu opened 4 years ago
That is the single best bug report I have ever seen in my life. Thank you so much for the work you put into documenting all this. I should be able to fix the bug based on your information. I will hopfeully get to it one of the coming weekends.
The multiplayer game crashes for both the guest and host when a guest player holds the easter egg in their inventory overnight. This is caused because the base game for the guest is attempting to serialize
DeepWoodsMod.EasterEggItem
into XML and send it over the network. This fails with the exceptionSystem.InvalidOperationException: There was an error generating the XML document.
, which causes a crash loop on the client (guest) and a freeze on the server (and eventually crashes). Proposed solution is below:Steps to reproduce
Crash logs
Root cause analysis
It appears that DeepWoodsMod attempts to clear all known instances of
EasterEggItem
via the codeEasterEggFunctions.RemoveAllEasterEggsFromGame();
before saving (inCleanupBeforeSave
) and then is restored inRestoreAfterSave
via the codeEasterEggFunctions.RestoreAllEasterEggsInGame();
(footnote1). In multiplayer, if we look at the logs, it appears that the base Stardew Valley attempts to transmit the guest player's state to the host before theevents.GameLoop.Saving
event handlers are called. This means thatRemoveAllEasterEggsFromGame
is not called. The game then will attempt to sendEasterEggItem
over the network via XML (from the client to host), which results in a serialization error.Recommended fix
After speaking with the people on Stardew Valley's modding Discord channel, it appears that this is a known problem with respect to having custom classes extending
StardewValley.Object
.There appears to be several solutions to this problem:
EasterEggItem
does too much.EasterEggItem
, but maybe we could place theEasterEggItem
as a foraging layer object.Unfortunately, I'm not familiar enough with StardewValley modding to complete the fix at this time and I won't have time over the next little while to do this. Also, both of these solutions looks like it will be relatively bigger code changes, which again is something I lack time for, for now.
Appendix: footnote1
Does this mean that EasterEggs will be wiped out if one restarts the game as they're not saved to the save file anywhere?
Appendix: crash log excerpt