private void YbDropOpenMenu_Click(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.DefaultExt = "*.cfg"; fileDialog.Filter = "Yulgang Info|*.cfg"; Nullable <bool> result = fileDialog.ShowDialog(); if (result == true) { string filename = fileDialog.FileName; DropBuilder.YBBuffer = YBi.Decrypt(File.ReadAllBytes(filename)); DropBuilder.ReadYBData(); } }
private void MenuItem_Click_Open(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.DefaultExt = "YBi.cfg"; fileDialog.Filter = "Yugang Data Info|YBi.cfg"; Nullable <bool> result = fileDialog.ShowDialog(); if (result == true) { DataListBox.Items.Clear(); string filename = fileDialog.FileName; ItemBuilder.YBBuffer = YBi.Decrypt(File.ReadAllBytes(filename)); ItemBuilder.ProcessYBItemData(); RefreshList(); } }
private static void NpcTemplateExport() { List <NpcTemplate> templates = new List <NpcTemplate>(); int BytesOfSeparation = 7860; int ID_Offset = 0x0107b448; var YBiBuffer = YBi.Decrypt(File.ReadAllBytes(DataPath + "YBi.cfg")); List <byte[]> list = new List <byte[]>(); lock (YBiBuffer) { while (BitConverter.ToInt32(YBiBuffer, ID_Offset) != 0) { long itemId = BitConverter.ToInt64(YBiBuffer, ID_Offset); byte[] temp = new byte[BytesOfSeparation]; Buffer.BlockCopy(YBiBuffer, ID_Offset, temp, 0, BytesOfSeparation); list.Add(temp); ID_Offset += BytesOfSeparation; } } lock (list) { try { foreach (byte[] data in list) { lock (data) { using (MemoryStream Stream = new MemoryStream(data)) { byte[] ids = new byte[4]; Stream.Read(ids, 0, ids.Length); byte[] names = new byte[64]; Stream.Read(names, 0, names.Length); Stream.Position += 2; byte[] levels = new byte[2]; Stream.Read(levels, 0, levels.Length); byte[] hps = new byte[4]; Stream.Read(hps, 0, hps.Length); byte[] descs = new byte[1024]; Stream.Read(descs, 0, descs.Length); byte[] choice1 = new byte[4]; Stream.Read(choice1, 0, choice1.Length); byte[] choice2 = new byte[4]; Stream.Read(choice2, 0, choice2.Length); byte[] choice3 = new byte[4]; Stream.Read(choice3, 0, choice3.Length); byte[] choice4 = new byte[4]; Stream.Read(choice4, 0, choice4.Length); int NpcId = BitConverter.ToInt32(ids, 0); string NpcName = Encoding.GetEncoding(EncodingName).GetString(names).Replace("\0", ""); int NpcLevel = BitConverter.ToInt16(levels, 0); int NpcHp = BitConverter.ToInt32(hps, 0); string NpcDesc = Encoding.GetEncoding(EncodingName).GetString(descs).Replace("\0", ""); int NpcChoice1 = BitConverter.ToInt32(choice1, 0); int NpcChoice2 = BitConverter.ToInt32(choice2, 0); int NpcChoice3 = BitConverter.ToInt32(choice3, 0); int NpcChoice4 = BitConverter.ToInt32(choice4, 0); Log.Debug("-----------------------------------------------------"); Log.Debug("NpcId = {0}", NpcId); Log.Debug("NpcName = {0}", NpcName); Log.Debug("NpcLevel = {0}", NpcLevel); Log.Debug("NpcHp = {0}", NpcHp); Log.Debug("NpcDesc = {0}", NpcDesc); Log.Debug("NpcChoice1 = {0}", NpcChoice1); Log.Debug("NpcChoice2 = {0}", NpcChoice2); Log.Debug("NpcChoice3 = {0}", NpcChoice3); Log.Debug("NpcChoice4 = {0}", NpcChoice4); Log.Debug("-----------------------------------------------------"); using (var entity = new PublicDbEntities()) { var dbdata = entity.TBL_XWWL_NPC.Where(v => v.FLD_PID == NpcId).FirstOrDefault(); if (dbdata != null) { NpcTemplate template = new NpcTemplate() { ID = NpcId, Name = NpcName, HealthPoint = NpcHp, Attack = (int)dbdata.FLD_AT, Defense = (int)dbdata.FLD_DF, Npc = (NpcId < 10000 && NpcId > 0) ? 1 : 0, Level = (int)dbdata.FLD_LEVEL, Exp = (int)dbdata.FLD_EXP, Auto = (int)dbdata.FLD_AUTO, Boss = dbdata.FLD_BOSS, }; templates.Add(template); Log.Debug("Npc NpcId = {0} Name = {1}", template.ID, template.Name); } else { Log.Debug("No db data for Npc id = {0}", NpcId); } } } } } } catch (Exception ex) { Log.ErrorException("NpcTemplateExport:", ex); } } /*using (var file = File.Create("Data/npcs.bin")) * { * Serializer.SerializeWithLengthPrefix<List<NpcTemplate>>(file, templates, PrefixStyle.Fixed32); * }*/ }