public IPubFile <ECFRecord> LoadPubFromExplicitFile(string fileName) { var fileBytes = File.ReadAllBytes(fileName); var pub = new ECFFile(); pub.DeserializeFromByteArray(fileBytes, _numberEncoderService); return(pub); }
public async Task <IPubFile> RequestFile(InitFileType fileType) { var request = new PacketBuilder(PacketFamily.Welcome, PacketAction.Agree) .AddChar((byte)fileType) .Build(); var response = await _packetSendService.SendEncodedPacketAndWaitAsync(request); if (!PacketIsValid(response)) { throw new EmptyPacketReceivedException(); } var responseFileType = (InitReply)response.ReadChar(); var extraByte = response.ReadChar(); if (extraByte != 1) { throw new MalformedPacketException("Missing extra single byte in file transfer packet", response); } IPubFile retFile; switch (responseFileType) { case InitReply.ItemFile: retFile = new EIFFile(); break; case InitReply.NpcFile: retFile = new ENFFile(); break; case InitReply.SpellFile: retFile = new ESFFile(); break; case InitReply.ClassFile: retFile = new ECFFile(); break; default: throw new EmptyPacketReceivedException(); } var responseBytes = response.ReadBytes(response.Length - response.ReadPosition) .ToArray(); retFile.DeserializeFromByteArray(responseBytes, _numberEncoderService); return(retFile); }