public override void Write(NetworkWriter writer) { writer.WriteInt32(ChunkX); writer.WriteInt16(ChunkY); writer.WriteInt32(ChunkZ); writer.WriteByte((byte)(Width - 1)); writer.WriteByte((byte)(Height - 1)); writer.WriteByte((byte)(Depth - 1)); var compressed = new MemoryStream(Data.Length); // TODO: use better guess here var zlib = new ZOutputStream(compressed, zlibConst.Z_DEFAULT_COMPRESSION); zlib.Write(Data, 0, Data.Length); zlib.Flush(); zlib.finish(); writer.WriteInt32((int)zlib.TotalOut); writer.Write(compressed.GetBuffer(), 0, (int)zlib.TotalOut); zlib.Close(); compressed.Close(); }
public static void Put(Packet packet, NetworkWriter writer) { writer.Write((byte)packet.Id); packet.Write(writer); writer.Flush(); }