Closed Manka-Muakido closed 4 months ago
first of all:
but i "fixed" or at last i think i fixed, the error at last did not happen anymore
first the log i made:
[HarmonyPrefix]
[HarmonyPatch(typeof(NetworkBehaviour), "__beginSendClientRpc")]
static bool Patch_NetworkBehaviour___beginSendClientRpc(ref FastBufferWriter __result)
{
logger.LogDebug("overrideBufferSizeInRpc: " + overrideBufferSizeInRpc.ToString());
logger.LogDebug("stackSize.Value: " + stackSize?.Value.ToString());
logger.LogDebug("stackSize.Value > 1: " + (stackSize.Value > 1).ToString());
//overrideBufferSizeInRpc = stackSize.Value > 1;
if (overrideBufferSizeInRpc)
{
var n = networkBufferScaling.Value * 1L * stackSize.Value + 65536;
if (n > 128L * 1024 * 1024 || n < 65536L)
{
n = -1L;
}
__result = new FastBufferWriter(1024, Unity.Collections.Allocator.Temp, (int)n);
return false;
}
return true;
}
output:
ModPlanetLoaded (2): akarnokd.theplanetcraftermods.uishowrocketcount
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: True
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
OverflowException: Writing past the end of the buffer
at SpaceCraft.InventoriesHandler.DirtyInventoryClientRpc (System.Int32 size, System.Int32 inventoryId, System.Int32[] content, System.Int32[] contentIds, System.Boolean containsGeneticTraits, Unity.Netcode.ClientRpcParams clientRpcParams) [0x0023b] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.DirtyInventory (System.Int32 inventoryId, System.UInt64 clientEditing, System.Boolean ignoreEditingClient) [0x00120] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.TransferAllItemsServerRpc (System.Int32 fromInventoryId, System.Int32 toInventoryId, Unity.Netcode.ServerRpcParams serverRpcParams) [0x00194] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.__rpc_handler_509846034 (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.__RpcParams rpcParams) [0x00052] in <87933cf5dadd4ce88b89709520a3779c>: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 <b7ef9d5b63bf4f659cb8fdbdff2c8d4e>:0
for some reason in the process the stack becomes <2 in
[HarmonyPrefix]
[HarmonyPatch(typeof(InventoriesHandler), "RetrieveInventoryClientRpc")]
static void Patch_InventoriesHandler_RetrieveInventoryClientRpc_Pre()
{
overrideBufferSizeInRpc = stackSize.Value > 1;
}
but by the log:
[Info :(UI) Show Rocket Counts] Counting rockets
ModPlanetLoaded (2): akarnokd.theplanetcraftermods.uishowrocketcount
[Debug :(Cheat) Inventory Stacking] Patch_InventoriesHandler_RetrieveInventoryClientRpc_Pre: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: True
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] Patch_InventoriesHandler_RetrieveInventoryClientRpc_Pre: True
[Debug :(Cheat) Inventory Stacking] Patch_InventoriesHandler_RetrieveInventoryClientRpc_Post: False
[Debug :(Cheat) Inventory Stacking] Patch_InventoriesHandler_RetrieveInventoryClientRpc_Post: False
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
[Debug :(Cheat) Inventory Stacking] overrideBufferSizeInRpc: False
[Debug :(Cheat) Inventory Stacking] stackSize.Value: 999
[Debug :(Cheat) Inventory Stacking] stackSize.Value > 1: True
OverflowException: Writing past the end of the buffer
at SpaceCraft.InventoriesHandler.DirtyInventoryClientRpc (System.Int32 size, System.Int32 inventoryId, System.Int32[] content, System.Int32[] contentIds, System.Boolean containsGeneticTraits, Unity.Netcode.ClientRpcParams clientRpcParams) [0x0023b] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.DirtyInventory (System.Int32 inventoryId, System.UInt64 clientEditing, System.Boolean ignoreEditingClient) [0x00120] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.TransferAllItemsServerRpc (System.Int32 fromInventoryId, System.Int32 toInventoryId, Unity.Netcode.ServerRpcParams serverRpcParams) [0x00194] in <87933cf5dadd4ce88b89709520a3779c>:0
at SpaceCraft.InventoriesHandler.__rpc_handler_509846034 (Unity.Netcode.NetworkBehaviour target, Unity.Netcode.FastBufferReader reader, Unity.Netcode.__RpcParams rpcParams) [0x00052] in <87933cf5dadd4ce88b89709520a3779c>: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 <b7ef9d5b63bf4f659cb8fdbdff2c8d4e>:0
Rethrow as Exception: Unhandled RPC exception!
code:
[HarmonyPrefix]
[HarmonyPatch(typeof(InventoriesHandler), "RetrieveInventoryClientRpc")]
static void Patch_InventoriesHandler_RetrieveInventoryClientRpc_Pre()
{
overrideBufferSizeInRpc = stackSize.Value > 1;
logger.LogDebug("Patch_InventoriesHandler_RetrieveInventoryClientRpc_Pre: " + overrideBufferSizeInRpc.ToString());
}
[HarmonyPostfix]
[HarmonyPatch(typeof(InventoriesHandler), "RetrieveInventoryClientRpc")]
static void Patch_InventoriesHandler_RetrieveInventoryClientRpc_Post()
{
overrideBufferSizeInRpc = false;
logger.LogDebug("Patch_InventoriesHandler_RetrieveInventoryClientRpc_Post: " + overrideBufferSizeInRpc.ToString());
}
this guy is the problem:
[HarmonyPostfix]
[HarmonyPatch(typeof(InventoriesHandler), "RetrieveInventoryClientRpc")]
static void Patch_InventoriesHandler_RetrieveInventoryClientRpc_Post()
{
overrideBufferSizeInRpc = false;
}
anyway:
so i just set by the method again(commented line)....probably not right....but hey.......it work.....i think "fixed"
[HarmonyPrefix]
[HarmonyPatch(typeof(NetworkBehaviour), "__beginSendClientRpc")]
static bool Patch_NetworkBehaviour___beginSendClientRpc(ref FastBufferWriter __result)
{
overrideBufferSizeInRpc = stackSize.Value > 1;
//could be stackSize.Value > 1 but...the var already here so....
if (overrideBufferSizeInRpc)
{
var n = networkBufferScaling.Value * 1L * stackSize.Value + 65536;
if (n > 128L * 1024 * 1024 || n < 65536L)
{
n = -1L;
}
__result = new FastBufferWriter(1024, Unity.Collections.Allocator.Temp, (int)n);
return false;
}
return true;
}
well it fixed the problem but after any transfer using that button i cant interact with anything anymore, must exit and load the game again, but idk if is because of this mod.....but its better than the exception
Thanks for the report.
Fixed in v1.0.1.19 (v488+), but only for the dev branch.
save: Custom-1.json config:
when clicking in container button to "loot all"
error:
after this error any other transfer works anymore, need to close and open the game again