spacechase0 / StardewValleyMP

Temporary solution for multiplayer until official multiplayer is released.
MIT License
38 stars 17 forks source link

Client sleeping before host can lead to crash #25

Closed Clorith closed 7 years ago

Clorith commented 8 years ago

I've been unable to isolate the reasoning, but this is a post-1.1 issue.

If the client goes to bed before the host, there's a chance (not every time) that the host will crash.

The indicator is always the same, the bottom half of your character goes transparent (as if mid-animation and there's no sprite for it), and it's only happened when the host picks up an item (like an item on the beach, or quartz on the ground in the mines).

Versions: StardewValleyMP : 0.2.7 SMAPI : 0.0.0 1.1-3

Last errors seen on the host (you have to kill the process, as the game and SMAPI console become unresponsive):

[10:40:01.852 ] (Me) Marius moved to Beach (StardewValley.Locations.Beach)
[10:40:23.836 ] Skippy moved to Mine (StardewValley.GameLocation)
[10:40:28.735 ] Skippy moved to BusStop (StardewValley.Locations.BusStop)
[10:40:37.052 ] Skippy moved to Farm (StardewValley.Farm)
[10:42:37.591 ] Skippy moved to FarmHouse_Skippy (StardewValley.Locations.FarmHouse)
[10:42:44.491 ] [] Skippy is in bed.
[10:42:45.059 ] Got farmer data for client 1
[10:42:45.208 ] Adding: FarmHouse -> FarmHouse_Skippy (StardewValley.Locations.FarmHouse)
[10:42:45.208 ] Adding: Cellar -> Cellar_Skippy (StardewValley.Locations.Cellar)
[10:42:45.238 ] An error occured in the base update loop: System.NullReferenceException: Object reference not set to an instance of an object.
   at StardewValley.FarmerSprite.getAnimationFromIndex(Int32 index, FarmerSprite requester, Int32 interval, Int32 numberOfFrames, Boolean flip, Boolean secondaryArm)
   at StardewValley.FarmerSprite.setCurrentFrame(Int32 which, Int32 offset, Int32 interval, Int32 numFrames, Boolean flip, Boolean secondaryArm)
   at StardewValley.FarmerSprite.setCurrentFrame(Int32 which)
   at StardewValley.Tools.FishingRod.tickUpdate(GameTime time, Farmer who)
   at StardewValley.Farmer.Update(GameTime time, GameLocation location)
   at StardewValley.Game1.UpdateCharacters(GameTime time)
   at StardewValley.Game1.Update(GameTime gameTime)
   at StardewModdingAPI.Inheritance.SGame.Update(GameTime gameTime) in Z:\Projects\SMAPI\src\StardewModdingAPI\Inheritance\SGame.cs:line 790
[10:43:05.240 ] Exception while receiving: System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.Stream.ReadByte()
   at System.IO.BinaryReader.ReadByte()
   at StardewValleyMP.Packets.Packet.readFrom(Stream s) in C:\Users\space\Desktop\SDV-Mods\StardewValleyMP\StardewValleyMP\Packets\Packet.cs:line 76
   at StardewValleyMP.Server.Client.receiveAndQueue() in C:\Users\space\Desktop\SDV-Mods\StardewValleyMP\StardewValleyMP\Server.cs:line 314

I made sure to include the last logged normal events that happened before this as well, hopefully that helps identify the root cause.

spacechase0 commented 8 years ago

Well, that's weird. I'm guessing this is related to #22.

aphadeon commented 7 years ago

This (or something similar) happens when the host is swinging a tool while a client goes to bed. The host will be softlocked. Assuming the injector is active, pushing F8 and typing 'canMove' is a workaround. (otherwise, press F3 to enable debug and press a number (1-6) to warp, which strangely re-enables menu, then hotswapping the equipped tool via menu to a sword, then blocking with the sword which cancels the swinging animation and releases the softlock.)

Sadly, not fixed in current release.

thetesher commented 7 years ago

I'm getting what I believe to be the same error even if the host sleeps before the client. Tested and had the same error on versions 2.10, 2.9, and 2.7 using SMAPI-0.40.1.1-3 on SDV v1.11. Hopefully this is helpful to you:

[09:57:01.142 PM] [] Tesher is in bed.
[09:57:01.142 PM] Default Map:  -> 
[09:57:01.142 PM] Updating NPC Sam
[09:57:01.142 PM] Dating: False -> False
[09:57:01.142 PM] Default Pos: (3456, 512) -> (3456 , 512)
[09:57:01.142 PM] Married: False -> False
[09:57:04.958 PM] [] Lyssers is in bed.
[09:57:05.025 PM] Got farmer data for client 1
[09:57:05.147 PM] Adding: FarmHouse -> FarmHouse_Lyssers (StardewValley.Locations.FarmHouse)
[09:57:05.147 PM] Adding: Cellar -> Cellar_Lyssers (StardewValley.Locations.Cellar)
[09:57:05.336 PM] An error occured in the base update loop: System.NullReferenceException: Object reference not set to an instance of an object.
   at StardewValley.NPC.pathfindToNextScheduleLocation(String startingLocation, Int32 startingX, Int32 startingY, String endingLocation, Int32 endingX, Int32 endingY, Int32 finalFacingDirection, String endBehavior, String endMessage)
   at StardewValley.NPC.parseMasterSchedule(String rawData)
   at StardewValley.NPC.getSchedule(Int32 dayOfMonth)
   at StardewValley.NPC.dayUpdate(Int32 dayOfMonth)
   at StardewValley.Game1.newDayAfterFade()
   at StardewValley.Game1.UpdateOther(GameTime time)
   at StardewValley.Game1.Update(GameTime gameTime)
   at StardewModdingAPI.Inheritance.SGame.Update(GameTime gameTime) in Z:\Projects\SMAPI\src\StardewModdingAPI\Inheritance\SGame.cs:line 790
aphadeon commented 7 years ago

@thetesher, I'd be curious to know if the character Lyssers was married to an NPC when that error occured. Likewise, if they had a child. I'm trying to determine what object (likely an NPC in this case) triggered the error.

thetesher commented 7 years ago

@avarisc No. Neither character is married or has children.

thetesher commented 7 years ago

@avarisc Okay, so the source of my particular problem was an odd one. The character Lyssers had named her dog "Sam" which happened to match the name of one of the NPCs. This was creating error logs upwards of 100MBs mostly consisting of: "received npc update with null: Sam" Changing the dogs name in the client's save file to "Sammy" completely stopped these errors and seems to have corrected the sleeping bug completely for us. Hopefully this is helpful to you.