public static void Main(string[] args) { if (args.Length < 1) { return; } if (!args[0].ToLower().EndsWith(".lrf")) { return; } // this is overkill lmao var file = ReplayFile.Open(args[0]); if (file == null) { return; } var reader = new PacketReader(file.GetReplayStream()); if (!reader.loaded) { return; } new PacketWriter(reader.getPackets(), file).writeJson(args[0]); }
public static ReplayFile Open(string path) { if (!File.Exists(path)) { return(null); } using (Stream input = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)) { ReplayFile replayFile = null; var binaryReader = new BinaryReader(input); var fileVersion = new FileVersion(); fileVersion.fileVersion = binaryReader.ReadUInt32(); if (fileVersion.fileVersion == 2816) { var contractJsonSerializer = new DataContractJsonSerializer(typeof(ReplayFile)); var count = binaryReader.ReadInt32(); var numArray = binaryReader.ReadBytes(count); var json = Encoding.ASCII.GetString(numArray); if (!json.EndsWith("}")) { System.Diagnostics.Debug.WriteLine(json); } MemoryStream memoryStream = new MemoryStream(numArray); replayFile = contractJsonSerializer.ReadObject(memoryStream) as ReplayFile; memoryStream.Close(); replayFile.version = fileVersion; replayFile.path = path; replayFile.dataStart = binaryReader.BaseStream.Position; } input.Close(); return(replayFile); } }
public PacketWriter(List <Packet> packets, ReplayFile replay) { Packets = packets; Replay = replay; }