//#endif public void SendTileRowCompressed(int xStart, int yStart, short width, short height, bool packChests) { Begin(Packet.SEND_TILE_ROW); var bufferStart = this.bin.BaseStream.Position; using (MemoryStream memoryStream = new MemoryStream()) { using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream)) { binaryWriter.Write(xStart); binaryWriter.Write(yStart); binaryWriter.Write(width); binaryWriter.Write(height); NetMessage.CompressTileBlock_Inner(binaryWriter, xStart, yStart, (int)width, (int)height); int num = this.buf.Length; if ((long)bufferStart + memoryStream.Length > (long)num) { //result = (int)((long)(num - bufferStart) + memoryStream.Length); } else { memoryStream.Position = 0L; MemoryStream memoryStream2 = new MemoryStream(); using (DeflateStream deflateStream = new DeflateStream(memoryStream2, CompressionMode.Compress, true)) { memoryStream.CopyTo(deflateStream); deflateStream.Flush(); deflateStream.Close(); deflateStream.Dispose(); } if (memoryStream.Length <= memoryStream2.Length) { memoryStream.Position = 0L; //buffer[bufferStart] = 0; Byte(0); //memoryStream.Read(buffer, bufferStart, (int)memoryStream.Length); //result = (int)memoryStream.Length + 1; var b = new byte[128]; int read = 0; while ((read = memoryStream.Read(b, 0, b.Length)) > 0) { Byte(b, read); } } else { memoryStream2.Position = 0L; Byte(1); //memoryStream2.Read(buffer, bufferStart, (int)memoryStream2.Length); //memoryStream2.CopyTo(sink); //result = (int)memoryStream2.Length + 1; var b = new byte[128]; int read = 0; while ((read = memoryStream2.Read(b, 0, b.Length)) > 0) { Byte(b, read); } } } } } End(); }