akarnokd / ThePlanetCrafterMods

BepInEx+Harmony mods for the Unity/Steam game The Planet Crafter
Apache License 2.0
52 stars 29 forks source link

CFNC dequeue empty crash #93

Closed akarnokd closed 6 months ago

akarnokd commented 6 months ago

The moment I enable CFNC in the test world Chill4 at the base, I get this:

InvalidOperationException: Queue empty.
  at System.Collections.Generic.Queue`1[T].Dequeue () [0x00016] in <95ed0683fe0f4f0eb6282d82b174a62f>:0 
  at (wrapper dynamic-method) SpaceCraft.InventoriesHandler.DMD<SpaceCraft.InventoriesHandler::RetrieveInventoryClientRpc>(SpaceCraft.InventoriesHandler,int,int,int[],int[],bool,Unity.Netcode.ClientRpcParams)
  at SpaceCraft.InventoriesHandler.__rpc_handler_405585326 (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.__RpcParams rpcParams) [0x000f7] in <2138c6c0d31c4bd9a73340b4a83fa8b7>:0 
  at (wrapper delegate-invoke) <Module>.invoke_void_NetworkBehaviour_FastBufferReader___RpcParams(Unity.Netcode.NetworkBehaviour,Unity.Netcode.FastBufferReader,Unity.Netcode.__RpcParams)
  at Unity.Netcode.RpcMessageHelpers.Handle (Unity.Netcode.NetworkContext& context, Unity.Netcode.RpcMetadata& metadata, Unity.Netcode.FastBufferReader& payload, Unity.Netcode.__RpcParams& rpcParams) [0x00059] in <404afaaf59b84927bf1f81ff35049113>:0 
Rethrow as Exception: Unhandled RPC exception!

UnityEngine.DebugLogHandler:Internal_LogException_Injected(Exception, IntPtr)
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
Unity.Netcode.RpcMessageHelpers:Handle(NetworkContext&, RpcMetadata&, FastBufferReader&, __RpcParams&)
Unity.Netcode.ClientRpcMessage:Handle(NetworkContext&)
Unity.Netcode.NetworkBehaviour:__endSendClientRpc(FastBufferWriter&, UInt32, ClientRpcParams, RpcDelivery)
SpaceCraft.InventoriesHandler:DMD<SpaceCraft.InventoriesHandler::RetrieveInventoryClientRpc>(InventoriesHandler, Int32, Int32, Int32[], Int32[], Boolean, ClientRpcParams)
SpaceCraft.InventoriesHandler:GetOrCreateNewInventoryServerRpc(Boolean, Int32, Int32, Int32, Int32[], Int32[], ServerRpcParams)
SpaceCraft.InventoriesHandler:__rpc_handler_1173953823(NetworkBehaviour, FastBufferReader, __RpcParams)
Unity.Netcode.RpcMessageHelpers:Handle(NetworkContext&, RpcMetadata&, FastBufferReader&, __RpcParams&)
Unity.Netcode.ServerRpcMessage:Handle(NetworkContext&)
Unity.Netcode.NetworkBehaviour:__endSendServerRpc(FastBufferWriter&, UInt32, ServerRpcParams, RpcDelivery)
SpaceCraft.InventoriesHandler:GetOrCreateNewInventoryServerRpc(Boolean, Int32, Int32, Int32, Int32[], Int32[], ServerRpcParams)
SpaceCraft.InventoriesHandler:GetOrCreateNewInventoryServerRpc(Int32, ServerRpcParams)
SpaceCraft.InventoriesHandler:__rpc_handler_1127442151(NetworkBehaviour, FastBufferReader, __RpcParams)
Unity.Netcode.RpcMessageHelpers:Handle(NetworkContext&, RpcMetadata&, FastBufferReader&, __RpcParams&)
Unity.Netcode.ServerRpcMessage:Handle(NetworkContext&)
Unity.Netcode.NetworkMessageManager:ReceiveMessage(FastBufferReader, NetworkContext&, NetworkMessageManager)
Unity.Netcode.NetworkMessageManager:HandleMessage(NetworkMessageHeader&, FastBufferReader, UInt64, Single, Int32)
Unity.Netcode.NetworkMessageManager:ProcessIncomingMessageQueue()
Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage)
Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage)
Unity.Netcode.<>c:<CreateLoopSystem>b__0_0()
akarnokd commented 6 months ago

It was a vanilla bug, caused by calling one ServerRpc method from within another ServerRpc method, messing up the call state. Fixed in 1.005-dev-04.