network fix

This commit is contained in:
2025-12-13 16:39:02 +01:00
parent efa6016fe5
commit cb59d5a918
8 changed files with 119 additions and 43 deletions

View File

@@ -92,36 +92,7 @@ namespace KCM.Packets.Network
return;
byte[] bytes = LoadSaveLoadAtPathHook.saveData;
int chunkSize = 900; // 900 bytes per chunk to fit within packet size limit
List<byte[]> chunks = SplitByteArrayIntoChunks(bytes, chunkSize);
Main.helper.Log("Save Transfer started!");
int sent = 0;
int packetsSent = 0;
for (int i = 0; i < chunks.Count; i++)
{
var chunk = chunks[i];
new SaveTransferPacket()
{
saveSize = bytes.Length,
saveDataChunk = chunk,
chunkId = i,
chunkSize = chunk.Length,
saveDataIndex = sent,
totalChunks = chunks.Count
}.Send(clientId);
Main.helper.Log(" ");
packetsSent++;
sent += chunk.Length;
}
Main.helper.Log($"Sent {packetsSent} save data chunks to client");
KCServer.EnqueueSaveTransfer(clientId, bytes);
}
else
{