public void write(Writer writer) { switch (type) { case VariableTypes.UINT8: writer.Write(value_uint8); break; case VariableTypes.UINT16: writer.Write(value_uint16); break; case VariableTypes.UINT32: writer.Write(value_uint32); break; case VariableTypes.INT8: writer.Write(value_int8); break; case VariableTypes.INT16: writer.Write(value_int16); break; case VariableTypes.INT32: writer.Write(value_int32); break; case VariableTypes.ENUM: writer.Write(value_enum); break; case VariableTypes.BOOL: writer.writeBool32(value_bool); break; case VariableTypes.STRING: writer.writeRSDKUTF16String(value_string); break; case VariableTypes.VECTOR2: writer.Write(value_vector2.x); writer.Write(value_vector2.y); break; case VariableTypes.UNKNOWN: writer.Write(value_unknown); break; case VariableTypes.COLOR: value_color.write(writer); break; } }
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(); }