private void SaveReplicable(StreamClientData clientData) { VRage.Library.Collections.BitStream str = new VRage.Library.Collections.BitStream(); str.ResetWrite(); Instance.Serialize(str); str.ResetRead(); int numObjectBits = str.BitLength; byte[] uncompressedData = new byte[str.ByteLength]; unsafe { fixed(byte *dataPtr = uncompressedData) { str.SerializeMemory(dataPtr, numObjectBits); } } str.Dispose(); clientData.CurrentPart = 0; clientData.ObjectData = MemoryCompressor.Compress(uncompressedData); clientData.UncompressedSize = numObjectBits; clientData.RemainingBits = clientData.ObjectData.Length * 8; }
private void CreateReplicable(int uncompressedSize) { byte[] ret = new byte[m_recievedBytes]; int offset = 0; foreach (var part in m_recivedParts) { Buffer.BlockCopy(part.Value, 0, ret, offset, part.Value.Length); offset += part.Value.Length; } byte[] decompressed = MemoryCompressor.Decompress(ret); VRage.Library.Collections.BitStream str = new VRage.Library.Collections.BitStream(); str.ResetWrite(); unsafe { fixed(byte *dataPtr = decompressed) { str.SerializeMemory(dataPtr, uncompressedSize); } } str.ResetRead(); Instance.LoadDone(str); str.Dispose(); if (m_recivedParts != null) { m_recivedParts.Clear(); } m_recivedParts = null; m_recievedBytes = 0; }