public void write(Writer writer) { using (var stream = new MemoryStream()) { using (var cwriter = new Writer(stream)) { cwriter.Write(signature); cwriter.Write(0x00); // data size (temp) int loop = 0; while (loop++ < 2) { if (loop == 2) { cwriter.Write(stream.ToArray().Length - 4); // data size (real) } cwriter.Write((ushort)rows.Count); cwriter.Write((byte)columns.Count); for (int i = 0; i < columns.Count; i++) { columns[i].write(cwriter); } for (int i = 0; i < rows.Count; i++) { rows[i].write(cwriter); } if (loop == 1) { cwriter.seek(4, SeekOrigin.Begin); } } } writer.writeCompressedRaw(stream.ToArray()); } writer.Close(); }
public void write(Writer writer) { using (var stream = new MemoryStream()) { using (var cwriter = new Writer(stream)) { int bufferSize = 0; byte[] frameBuffer = new byte[1]; float averageSize = 0; int packedFrameCount = 0; using (var frameStream = new MemoryStream()) { using (var fwriter = new Writer(frameStream)) { foreach (ReplayEntry frame in frames) { int frameSize = frame.pack(fwriter, isPacked); bufferSize += frameSize; if (frames.Count > 1) { uint frameCount = (uint)frames.Count; float avg = averageSize; float sizef = frameSize; averageSize = ((avg * packedFrameCount) + sizef) / (packedFrameCount + 1); } else { averageSize = frameSize; } packedFrameCount++; } } frameBuffer = frameStream.ToArray(); } if (!isPacked) { bufferSize = 28 * (frames.Count + 2); } cwriter.Write(signature); cwriter.Write(gameVer); cwriter.writeBool32(isPacked ? true : false); cwriter.writeBool32(frames.Count >= 1 ? true : false); cwriter.Write(frames.Count); cwriter.Write(startingFrame); cwriter.Write(zoneID); cwriter.Write(act); cwriter.Write(characterID); cwriter.writeBool32(isPlusLayout ? true : false); cwriter.Write(oscillation); cwriter.Write(bufferSize); cwriter.Write(averageSize); cwriter.Write(unknown); cwriter.Write(frameBuffer); } writer.writeCompressedRaw(stream.ToArray()); } writer.Close(); }