ScalarVector1 / DragonLens

Modern, customizable, and community-driven debugging and cheat mod for TModLoader
24 stars 14 forks source link

Subworld Nullref from PlayerManager.PlayerDisconnect #103

Open GabeHasWon opened 3 weeks ago

GabeHasWon commented 3 weeks ago

Relevant line: https://github.com/ScalarVector1/DragonLens/blob/f13c56fa093f1c51c3fe969d27de0794fb7f8029/Content/Tools/Multiplayer/PlayerManager.cs#L52

Replication Steps

This happens every time I join, and stops me from using DragonLens on multiplayer servers in its entirety. The only thing to appear is the log below, which Subworld Library handles poorly or something, causing the softlock.

Error

[13:12:46.068] [Main Thread/WARN] [tML]: Silently Caught Exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at DragonLens.Content.Tools.Multiplayer.PlayerManagerUpdater.PlayerDisconnect() in DragonLens\Content\Tools\Multiplayer\PlayerManager.cs:line 54
   at Terraria.ModLoader.PlayerLoader.PlayerDisconnect(Int32 playerIndex) in tModLoader\Terraria\ModLoader\PlayerLoader.cs:line 1257
   at SubworldLibrary.SubworldSystem.MovePlayerToSubserver(Int32 player, UInt16 id) in SubworldLibrary\SubworldSystem.cs:line 335
   at SubworldLibrary.SubworldLibrary.HandlePacket(BinaryReader reader, Int32 whoAmI) in SubworldLibrary.cs:line 1036
   at Terraria.ModLoader.ModNet.HandleModPacket(BinaryReader reader, Int32 whoAmI, Int32 length) in tModLoader\Terraria\ModLoader\ModNet.cs:line 609
   at Terraria.MessageBuffer.GetData(Int32 start, Int32 length, Int32& messageType) in tModLoader\Terraria\MessageBuffer.cs:line 3880
   at DMD<System.Void Terraria.NetMessage:CheckBytes(System.Int32)>(Int32 bufferIndex)
   at SyncProxy<System.Void Terraria.NetMessage:CheckBytes(System.Int32)>(Int32 )
   at DMD<System.Void Terraria.Netplay:UpdateServerInMainThread()>()
   at SyncProxy<System.Void Terraria.Netplay:UpdateServerInMainThread()>()
   at DMD<System.Void Terraria.Main:DoUpdate(Microsoft.Xna.Framework.GameTime&)>(Main this, GameTime& gameTime)
   at DragonLens.Content.Tools.Gameplay.FastForwardSystem.UpdateExtraTimes(orig_DoUpdate orig, Main self, GameTime& gameTime)
   at Hook<System.Void DragonLens.Content.Tools.Gameplay.FastForwardSystem::UpdateExtraTimes(Terraria.On_Main+orig_DoUpdate,Terraria.Main,Microsoft.Xna.Framework.GameTime&)>(Main , GameTime& )
   at SyncProxy<System.Void Terraria.Main:DoUpdate(Microsoft.Xna.Framework.GameTime&)>(Main , GameTime& )
   at DMD<System.Void Terraria.Main:Update(Microsoft.Xna.Framework.GameTime)>(Main this, GameTime gameTime)
   at PathOfTerraria.Common.UI.Tooltip.Reset(orig_Update orig, Main self, GameTime gameTime)
   at Hook<System.Void PathOfTerraria.Common.UI.Tooltip::Reset(Terraria.On_Main+orig_Update,Terraria.Main,Microsoft.Xna.Framework.GameTime)>(Main , GameTime )
   at SyncProxy<System.Void Terraria.Main:Update(Microsoft.Xna.Framework.GameTime)>(Main , GameTime )
   at Terraria.Main.DedServ_PostModLoad(Boolean& reloadMods)
   at Terraria.Main.DedServ()
   at Terraria.Program.RunGame()
   at Terraria.Program.LaunchGame_(Boolean isServer)
   at Terraria.Program.LaunchGame(String[] args, Boolean monoArgs)
   at Terraria.MonoLaunch.Main_End(String[] args)
   at Terraria.MonoLaunch.<>c__DisplayClass1_0.<Main>b__1()
Antirhinnum commented 3 weeks ago

A similar issue seems to happen without Subworld Library (edit: with just DragonLens) if using a self-hosted server.

If I Host + Play on one Terraria instance and join using another, the server will crash shortly after the second client leaves. If I host a dedicated server and join, the server will crash shortly after the client leaves. Both produce the exact same error:

[10:44:35.201] [Server Loop Thread/WARN] [tML]: Silently Caught Exception: 
System.NullReferenceException: Object reference not set to an instance of an object.
   at DragonLens.Content.Tools.Multiplayer.PlayerManagerUpdater.PlayerDisconnect() in DragonLens\Content\Tools\Multiplayer\PlayerManager.cs:line 54
   at Terraria.ModLoader.PlayerLoader.PlayerDisconnect(Int32 playerIndex) in tModLoader\Terraria\ModLoader\PlayerLoader.cs:line 1257
   at Terraria.Player.Hooks.PlayerDisconnect(Int32 playerIndex) in tModLoader\Terraria\Player.cs:line 269
   at Terraria.NetMessage.SyncOnePlayer(Int32 plr, Int32 toWho, Int32 fromWho) in tModLoader\Terraria\NetMessage.cs:line 2740
   at Terraria.Netplay.UpdateConnectedClients() in tModLoader\Terraria\Netplay.cs:line 307
   at Terraria.Netplay.ServerLoop() in tModLoader\Terraria\Netplay.cs:line 292
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

Relevant line: https://github.com/ScalarVector1/DragonLens/blob/f13c56fa093f1c51c3fe969d27de0794fb7f8029/Content/Tools/Multiplayer/PlayerManager.cs#L54

I haven't tested to see if this is the case in normal multiplayer, but I wouldn't be surprised.