From d144c43ca5c47b782cd902766512adbf8a4dd3b4 Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Sat, 18 May 2024 15:35:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E6=8E=A2=E7=B4=A2=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MHFOldShopTools.csproj.user | 6 +++ Program.cs | 95 ++++++++++++++++++++++++++++++++++++- 2 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 MHFOldShopTools.csproj.user diff --git a/MHFOldShopTools.csproj.user b/MHFOldShopTools.csproj.user new file mode 100644 index 0000000..38a2bde --- /dev/null +++ b/MHFOldShopTools.csproj.user @@ -0,0 +1,6 @@ + + + + <_LastSelectedProfileId>F:\Sin365\MHFOldShopTools\Properties\PublishProfiles\FolderProfile.pubxml + + \ No newline at end of file diff --git a/Program.cs b/Program.cs index 32a2861..44668f8 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Text; +using static System.Runtime.InteropServices.JavaScript.JSType; namespace MHFOldShopTools { @@ -35,6 +36,7 @@ namespace MHFOldShopTools Console.WriteLine($"请确保Files目录中已放置解密的MHF-FW5 mhfdat.bin文件,请选择:"); Console.WriteLine($"[1],解析Files目录中bin文件,生成同名txt清单和csv表"); Console.WriteLine($"[2],解析Files目录中csv文件,修改回同名的bin文件中"); + Console.WriteLine($"[3],探索道具数据"); Console.WriteLine($"Please ensure that the decrypted MHF-FW5 mhfdat.bin file is placed in the Files directory. Please select:"); Console.WriteLine($"[1],Parse the .bin file in the Files directory and generate a .txt list and .csv table with the same name"); Console.WriteLine($"[2],Parse the .csv file in the Files directory and modify it back to the .bin file with the same name"); @@ -44,6 +46,8 @@ namespace MHFOldShopTools bflag = 1; else if(yn.ToLower() == "2") bflag = 2; + else if (yn.ToLower() == "3") + bflag = 3; if (bflag != 0) break; @@ -80,7 +84,7 @@ namespace MHFOldShopTools Console.WriteLine($">>>>>>>>>>>>>>处理完毕>>>>>>>>>>>>>>"); } } - else + else if (bflag == 2) { int index = 0; int errcount = 0; @@ -111,6 +115,38 @@ namespace MHFOldShopTools Console.WriteLine($">>>>>>>>>>>>>>处理完毕>>>>>>>>>>>>>>"); } } + else if (bflag == 3) + { + int index = 0; + int errcount = 0; + for (int i = 0; i < files.Length; i++) + { + string FileName = files[i].Substring(files[i].LastIndexOf("\\")); + + if (System.IO.Path.GetExtension(FileName).ToLower() != ".bin") + { + continue; + } + index++; + + Console.WriteLine($">>>>>>>>>>>>>>开始处理 第{index}个文件 {FileName}<<<<<<<<<<<<<<<<<<<"); + FileHelper.LoadFile(files[i], out byte[] data); + + DiscoverItems(data, out List OutInput, out List outPutCsv); + + + //string listfileName = System.IO.Path.GetFileNameWithoutExtension(FileName) + ".txt"; + //string listoutpath = loc + InDir + "\\" + listfileName; + //FileHelper.SaveFile(listoutpath, OutInputString.ToArray()); + + //string csvfileName = System.IO.Path.GetFileNameWithoutExtension(FileName) + ".csv"; + //string csvoutpath = loc + InDir + "\\" + csvfileName; + //FileHelper.SaveFile(csvoutpath, outPutCsv.ToArray()); + + Console.WriteLine($">>>>>>>>>>>>>>处理完毕>>>>>>>>>>>>>>"); + } + + } while (true) { @@ -143,7 +179,7 @@ namespace MHFOldShopTools ItemInfo = $"{"0x" + item.Ptr.ToString("X") + ":"} | {item.ItemID} ({MHHelper.Get2MHFItemName(item.ItemID)}) | {item.Point}点 | {item.Group}({GetShopName(item.Group)}) {item.LevelType}({GetLevelTypeName(item.LevelType)})| [{item.OtherData[0].ToString("X")} {item.OtherData[1].ToString("X")} {item.OtherData[2].ToString("X")} {item.OtherData[3].ToString("X")}]"; OutInput.Add(ItemInfo); - outPutCsv.Add($"{item.ItemID},{item.Point},{item.Group},{item.LevelType}"); + outPutCsv.Add($"{item.ItemID},{item.Point},{item.Group},{item.LevelType},{MHHelper.Get2MHFItemName(item.ItemID)}"); Console.WriteLine(ItemInfo); } @@ -169,6 +205,61 @@ namespace MHFOldShopTools */ } + static void DiscoverItems(byte[] data, out List OutInput, out List outPutCsv) + { + OutInput = new List(); + outPutCsv = new List(); + List items = new List(); + + + int TempPtr = 0x537924; + int ToUpCount = 712; + + int flag = 2; + //顺序 + if (flag == 1) + { + for (int i = 0; i < ToUpCount; i++) + { + items.Add(GetShopItemInfo(data, TempPtr + (1 * i * _singelItemDatalenght))); + } + + for (int i = 0; i < items.Count; i++) + { + ShopItem item = items[i]; + string ItemInfo; + if (item.UnKnow) + ItemInfo = $"{"0x" + item.Ptr.ToString("X") + ":"} | 解析失败"; + else + ItemInfo = $"{"0x" + item.Ptr.ToString("X") + ":"} | {item.ItemID} ({MHHelper.Get2MHFItemName(item.ItemID)}) | {item.Point}点 | {item.Group}({GetShopName(item.Group)}) {item.LevelType}({GetLevelTypeName(item.LevelType)})| [{item.OtherData[0].ToString("X")} {item.OtherData[1].ToString("X")} {item.OtherData[2].ToString("X")} {item.OtherData[3].ToString("X")}]"; + + Console.WriteLine(ItemInfo); + } + } + else //倒叙 + { + { + for (int i = ToUpCount - 1; i >= 0; i--) + { + items.Add(GetShopItemInfo(data, TempPtr + (-1 * i * _singelItemDatalenght))); + } + + for (int i = 0; i < items.Count; i++) + { + ShopItem item = items[i]; + string ItemInfo; + if (item.UnKnow) + ItemInfo = $"{"0x" + item.Ptr.ToString("X") + ":"} | 解析失败"; + else + ItemInfo = $"{"0x" + item.Ptr.ToString("X") + ":"} | {item.ItemID} ({MHHelper.Get2MHFItemName(item.ItemID)}) | {item.Point}点 | {item.Group}({GetShopName(item.Group)}) {item.LevelType}({GetLevelTypeName(item.LevelType)})| [{item.OtherData[0].ToString("X")} {item.OtherData[1].ToString("X")} {item.OtherData[2].ToString("X")} {item.OtherData[3].ToString("X")}]"; + + Console.WriteLine(ItemInfo); + } + } + } + + } + static List LoadStructForCsv(string[] lines) { List itemList = new List();