diff --git a/.vs/MHFQuestToMH2Dos/DesignTimeBuild/.dtbcache.v2 b/.vs/MHFQuestToMH2Dos/DesignTimeBuild/.dtbcache.v2 index 3e19b01..0a96450 100644 Binary files a/.vs/MHFQuestToMH2Dos/DesignTimeBuild/.dtbcache.v2 and b/.vs/MHFQuestToMH2Dos/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/258af690-d08c-4b3e-89cb-2b17e09d73f4.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/258af690-d08c-4b3e-89cb-2b17e09d73f4.vsidx deleted file mode 100644 index 5a16b83..0000000 Binary files a/.vs/MHFQuestToMH2Dos/FileContentIndex/258af690-d08c-4b3e-89cb-2b17e09d73f4.vsidx and /dev/null differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/3065ff7b-d888-4a62-8ddb-4c590d937f45.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/3065ff7b-d888-4a62-8ddb-4c590d937f45.vsidx new file mode 100644 index 0000000..3c604d6 Binary files /dev/null and b/.vs/MHFQuestToMH2Dos/FileContentIndex/3065ff7b-d888-4a62-8ddb-4c590d937f45.vsidx differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/5fa92854-8543-48ed-8731-70281b87afa8.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/5fa92854-8543-48ed-8731-70281b87afa8.vsidx new file mode 100644 index 0000000..489a852 Binary files /dev/null and b/.vs/MHFQuestToMH2Dos/FileContentIndex/5fa92854-8543-48ed-8731-70281b87afa8.vsidx differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/7af01ce2-9e1d-4bd4-9dac-5e1bbfe7583e.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/7af01ce2-9e1d-4bd4-9dac-5e1bbfe7583e.vsidx deleted file mode 100644 index 8e26033..0000000 Binary files a/.vs/MHFQuestToMH2Dos/FileContentIndex/7af01ce2-9e1d-4bd4-9dac-5e1bbfe7583e.vsidx and /dev/null differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/9d94dbfa-a993-4367-abee-57a9b76f4098.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/9d94dbfa-a993-4367-abee-57a9b76f4098.vsidx new file mode 100644 index 0000000..61d37f9 Binary files /dev/null and b/.vs/MHFQuestToMH2Dos/FileContentIndex/9d94dbfa-a993-4367-abee-57a9b76f4098.vsidx differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/cf7f26f8-c8a5-47cb-bbe5-3d6cd0c7630c.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/cf7f26f8-c8a5-47cb-bbe5-3d6cd0c7630c.vsidx deleted file mode 100644 index 27f2e4d..0000000 Binary files a/.vs/MHFQuestToMH2Dos/FileContentIndex/cf7f26f8-c8a5-47cb-bbe5-3d6cd0c7630c.vsidx and /dev/null differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/eb4785e7-5e01-45b2-b97a-3397288e8eed.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/eb4785e7-5e01-45b2-b97a-3397288e8eed.vsidx deleted file mode 100644 index 1f1bb56..0000000 Binary files a/.vs/MHFQuestToMH2Dos/FileContentIndex/eb4785e7-5e01-45b2-b97a-3397288e8eed.vsidx and /dev/null differ diff --git a/.vs/MHFQuestToMH2Dos/FileContentIndex/edb99419-6f79-44a8-a384-52cb82459d22.vsidx b/.vs/MHFQuestToMH2Dos/FileContentIndex/edb99419-6f79-44a8-a384-52cb82459d22.vsidx new file mode 100644 index 0000000..c157f49 Binary files /dev/null and b/.vs/MHFQuestToMH2Dos/FileContentIndex/edb99419-6f79-44a8-a384-52cb82459d22.vsidx differ diff --git a/.vs/MHFQuestToMH2Dos/v17/.futdcache.v2 b/.vs/MHFQuestToMH2Dos/v17/.futdcache.v2 index a1c0b2b..0e578ea 100644 Binary files a/.vs/MHFQuestToMH2Dos/v17/.futdcache.v2 and b/.vs/MHFQuestToMH2Dos/v17/.futdcache.v2 differ diff --git a/.vs/MHFQuestToMH2Dos/v17/.suo b/.vs/MHFQuestToMH2Dos/v17/.suo index 42c1947..20ef170 100644 Binary files a/.vs/MHFQuestToMH2Dos/v17/.suo and b/.vs/MHFQuestToMH2Dos/v17/.suo differ diff --git a/.vs/ProjectEvaluation/mhfquesttomh2dos.metadata.v5.2 b/.vs/ProjectEvaluation/mhfquesttomh2dos.metadata.v5.2 index a75c488..8356f21 100644 Binary files a/.vs/ProjectEvaluation/mhfquesttomh2dos.metadata.v5.2 and b/.vs/ProjectEvaluation/mhfquesttomh2dos.metadata.v5.2 differ diff --git a/.vs/ProjectEvaluation/mhfquesttomh2dos.projects.v5.2 b/.vs/ProjectEvaluation/mhfquesttomh2dos.projects.v5.2 index 2a054f4..898d8ae 100644 Binary files a/.vs/ProjectEvaluation/mhfquesttomh2dos.projects.v5.2 and b/.vs/ProjectEvaluation/mhfquesttomh2dos.projects.v5.2 differ diff --git a/HexHelper.cs b/HexHelper.cs index 6226471..6940c3f 100644 --- a/HexHelper.cs +++ b/HexHelper.cs @@ -21,6 +21,23 @@ namespace MHFQuestToMH2Dos return target; } + /// + /// 读取byte[]数据 + /// + /// + /// + /// + /// + public static byte[] ReadBytes(byte[] src, int lenght, int offset = 0) + { + byte[] data = new byte[lenght]; + for (int i = 0; i < lenght; i++) + { + data[i] = src[offset + i]; + } + return data; + } + /** * byte[]转换int byte高位在前 */ @@ -104,6 +121,7 @@ namespace MHFQuestToMH2Dos return str; } + /** * 写入int到byte[] byte高位在前 */ diff --git a/LoadToSaveTemplate.cs b/LoadToSaveTemplate.cs new file mode 100644 index 0000000..87a058d --- /dev/null +++ b/LoadToSaveTemplate.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MHFQuestToMH2Dos +{ + + public class MapAreaData + { + public MapAreaData(int Count) + { + targetDatas = new TargetData[Count]; + areaPosDatas = new List(); + } + public TargetData[] targetDatas; + public List areaPosDatas; + } + + public class TargetData + { + public TargetData(List data) + { + targetData = data; + } + public List targetData; + } + + + public static class LoadToSaveTemplate + { + public static Dictionary DictMapAreaData = new Dictionary(); + public static Dictionary DictMapIDFileName = new Dictionary(); + public static Dictionary DictMapIDFullFileName = new Dictionary(); + public static bool LoadMapTemplateAreaData(byte[] src,string FileName,string FullFileName) + { + byte[] target; + + int _QuestTargetMapID; + //地图数据 + MapAreaData mapAreaData; + try + { + target = HexHelper.CopyByteArr(src);//加载数据 + + //从前4字节取出指针 定位任务信息位置 + int _QuestInfoPtr = HexHelper.bytesToInt(target, 4, 0x00); + Log.HexTips(0x00, "开始读取任务头部信息,指针->{0}", _QuestInfoPtr); + + //任务目的地MapID + _QuestTargetMapID = HexHelper.bytesToInt(target, ModifyQuest.cQuestInfo_TargetMapID_Lenght, _QuestInfoPtr + ModifyQuest.cQuestInfo_TargetMap_Offset); + Log.HexColor(ConsoleColor.Green, _QuestInfoPtr + ModifyQuest.cQuestInfo_TargetMap_Offset, "目的地地图,指针->{0} 【" + MHHelper.Get2MapName(_QuestTargetMapID) + "】", _QuestTargetMapID); + + //区域数量 + int _AreaCount = MHHelper.GetMapAreaCount(_QuestTargetMapID); + Log.Info(MHHelper.Get2MapName(_QuestTargetMapID) + "的地图数量" + _AreaCount); + mapAreaData = new MapAreaData(_AreaCount); + + #region 换区设置 + + //换区设置指针 + int _CAreaSetTopPtr = HexHelper.bytesToInt(target, 4, 0x1C); + Log.HexInfo(0x1C, "换区设置指针->{0}", _CAreaSetTopPtr); + + //读取换区单个区域游标 + int _CAreaSetTop_CurrPtr = _CAreaSetTopPtr; + + for (int i = 0; i < _AreaCount; i++) + { + int _One_CurrPtr = HexHelper.bytesToInt(target, 4, _CAreaSetTop_CurrPtr); + + List datas = new List(); + int Set_TargetIndex = 0; + while (true) + { + if (MHHelper.CheckEnd(target, _One_CurrPtr) + || + HexHelper.bytesToInt(target, 1, _One_CurrPtr) == 0) + { + Log.HexInfo(_One_CurrPtr, "区域设置结束符"); + break; + } + Log.HexInfo(_CAreaSetTop_CurrPtr, "第" + i + "区,第" + Set_TargetIndex + "个目标,换区设置指针->{0}", _One_CurrPtr); + Log.HexTips(_One_CurrPtr, "第" + i + "区,第" + Set_TargetIndex + "个目标,读取数据,长度{0}", 0x34); + datas.Add(HexHelper.ReadBytes(target, 0x34, _One_CurrPtr)); + Set_TargetIndex++; + _One_CurrPtr += 0x34; + } + mapAreaData.targetDatas[i] = new TargetData(datas); + + _CAreaSetTop_CurrPtr += 0x4; + } + #endregion + + #region 区域映射 + //区域映射指针 + int _CAreaPosTopPtr = HexHelper.bytesToInt(target, 4, 0x20); + Log.HexInfo(0x20, "换区映射指针->{0}", _CAreaPosTopPtr); + //读取单个区域映射游标 + int _CAreaPosTop_CurrPtr = _CAreaPosTopPtr; + for (int i = 0; i < _AreaCount; i++) + { + Log.HexTips(_CAreaPosTop_CurrPtr, "第" + i + "区的区域映射,读取数据,长度{0}", 0x20); + mapAreaData.areaPosDatas.Add(HexHelper.ReadBytes(target, 0x20, _CAreaPosTop_CurrPtr)); + _CAreaPosTop_CurrPtr += 0x20; + } + #endregion + + } + catch (Exception ex) + { + Console.WriteLine(ex); + target = null; + return false; + } + + DictMapAreaData[_QuestTargetMapID] = mapAreaData; + DictMapIDFileName[_QuestTargetMapID] = MHHelper.Get2MapName(_QuestTargetMapID) + FileName; + if (DictMapIDFullFileName.ContainsKey(_QuestTargetMapID)) + { + File.Delete(DictMapIDFullFileName[_QuestTargetMapID]); + } + DictMapIDFullFileName[_QuestTargetMapID] = FullFileName; + Log.HexColor(ConsoleColor.Green, _QuestTargetMapID, "成功,缓存地图 编号{0}" + MHHelper.Get2MapName(_QuestTargetMapID) + "的数据", _QuestTargetMapID); + return true; + } + } +} diff --git a/Log.cs b/Log.cs index dcc832a..e3165d7 100644 --- a/Log.cs +++ b/Log.cs @@ -47,5 +47,10 @@ namespace MHFQuestToMH2Dos HexInfo(HexPos, log, arr); Console.ForegroundColor = src_color; } + + public static void Info(string log) + { + Console.WriteLine(log); + } } } diff --git a/MHHelper.cs b/MHHelper.cs index 937ca2b..7f1ee83 100644 --- a/MHHelper.cs +++ b/MHHelper.cs @@ -7,8 +7,19 @@ using System.Threading.Tasks; namespace MHFQuestToMH2Dos { - public class MHHelper + public static class MHHelper { + + /// + /// 地图区域数量 + /// + static List MapAreaCount = new List { 0, 7, 13, 12, 11, 10, 11, 2, 2, 2, 2, 10, 4, 9, 0, 11, 13, 12, 11, 10, 11, 10, 4, 7, 2, 2 }; + + public static int GetMapAreaCount(int MapId) + { + return MapAreaCount[MapId]; + } + public static bool CheckEnd(byte[] data, int Ptr) { return HexHelper.bytesToUInt(data, 2, Ptr) == 0xFFFF; diff --git a/ModifyQuest.cs b/ModifyQuest.cs index 3482776..eaa5024 100644 --- a/ModifyQuest.cs +++ b/ModifyQuest.cs @@ -9,102 +9,102 @@ namespace MHFQuestToMH2Dos public static class ModifyQuest { - const int cMax_MapID = 0x49; - const int cMax_MonsterID = 0x49; - const int cMax_ItemID = 0x031D; + public const int cMax_MapID = 0x49; + public const int cMax_MonsterID = 0x49; + public const int cMax_ItemID = 0x031D; - const int cMax_GuTi = 0xA; - const int cMax_QuestStar = 8; + public const int cMax_GuTi = 0xA; + public const int cMax_QuestStar = 8; - const int cModify_QuestID = 0xEA74; + public const int cModify_QuestID = 0xEA74; /// /// 道具ID超出最大限制时,修改为【不可燃烧的废物】 /// - const int cModify_OutOfItemID = 0x00AE; + public const int cModify_OutOfItemID = 0x00AE; /// /// Dos中无意义数据 /// - const int cNon0x00For2DosPtr = 19; + public const int cNon0x00For2DosPtr = 19; /// /// MHF任务信息偏移 /// - const int cQuestMHFOffset = 12; + public const int cQuestMHFOffset = 12; /// /// 2Dos任务信息偏移 /// - const int cQuest2DosOffset = 8; + public const int cQuest2DosOffset = 8; /// /// 任务信息需偏移长度 /// - const int cQuestMhfToDosSetLenght = 64; + public const int cQuestMhfToDosSetLenght = 64; /// /// 任务信息 指针组 总长度 /// - const int cQuest2DosInfoPtrGourpLenght = 72; + public const int cQuest2DosInfoPtrGourpLenght = 72; /// /// 移动信息指针组 到的指定位置 /// - const int cSetInfoPtrGourpMoveToStarPos = 0x88; + public const int cSetInfoPtrGourpMoveToStarPos = 0x88; /// /// 任务内容 指针组 到的指定位置 /// - const int cQuestContenPtrGourpMoveToStarPos = 0xD0; + public const int cQuestContenPtrGourpMoveToStarPos = 0xD0; /// /// 移动整个任务文本 到的指定位置 /// - const int cQuestTextAllMsgMoveToStarPos = 0xF0; + public const int cQuestTextAllMsgMoveToStarPos = 0xF0; /// /// 移动整个任务文本 到的指定的截止位置 /// - const int cQuestTextAllMsgMoveToEndPos = 0x1Ff; + public const int cQuestTextAllMsgMoveToEndPos = 0x1Ff; /// /// 任务_类型 偏移 /// - const int cQuestInfo_Type_Offset = 0; + public const int cQuestInfo_Type_Offset = 0; /// /// 任务_类型 长度 /// - const int cQuestInfo_Type_Lenght = 1; + public const int cQuestInfo_Type_Lenght = 1; /// /// 任务_星级 偏移 /// - const int cQuestInfo_Star_Offset = 4; + public const int cQuestInfo_Star_Offset = 4; /// /// 任务_星级 长度 /// - const int cQuestInfo_Star_Lenght = 2; + public const int cQuestInfo_Star_Lenght = 2; /// /// 任务_类型 偏移 /// - const int cQuestInfo_TargetMap_Offset = 32; + public const int cQuestInfo_TargetMap_Offset = 32; /// /// 任务_类型 长度 /// - const int cQuestInfo_TargetMapID_Lenght = 1; + public const int cQuestInfo_TargetMapID_Lenght = 1; /// /// 任务_类型 偏移 /// - const int cQuestInfo_QuestID_Offset = 42; + public const int cQuestInfo_QuestID_Offset = 42; /// /// 任务_类型 长度 /// - const int cQuestInfo_QuestID_Lenght = 2; + public const int cQuestInfo_QuestID_Lenght = 2; public static bool ModifyQuset(byte[] src, out byte[] target) { diff --git a/PosFile2Dos/m03008n2.mib b/PosFile2Dos/m03008n2.mib new file mode 100644 index 0000000..7c29a12 Binary files /dev/null and b/PosFile2Dos/m03008n2.mib differ diff --git a/PosFile2Dos/m10101d2.mib b/PosFile2Dos/m10101d2.mib new file mode 100644 index 0000000..91e1f1d Binary files /dev/null and b/PosFile2Dos/m10101d2.mib differ diff --git a/PosFile2Dos/m10101n2.mib b/PosFile2Dos/m10101n2.mib new file mode 100644 index 0000000..625be1f Binary files /dev/null and b/PosFile2Dos/m10101n2.mib differ diff --git a/PosFile2Dos/m12078n2.mib b/PosFile2Dos/m12078n2.mib new file mode 100644 index 0000000..7dd2595 Binary files /dev/null and b/PosFile2Dos/m12078n2.mib differ diff --git a/PosFile2Dos/m15006d2.mib b/PosFile2Dos/m15006d2.mib new file mode 100644 index 0000000..ad4d3ca Binary files /dev/null and b/PosFile2Dos/m15006d2.mib differ diff --git a/PosFile2Dos/m15006n2.mib b/PosFile2Dos/m15006n2.mib new file mode 100644 index 0000000..77d56a7 Binary files /dev/null and b/PosFile2Dos/m15006n2.mib differ diff --git a/PosFile2Dos/m15014d2.mib b/PosFile2Dos/m15014d2.mib new file mode 100644 index 0000000..4d28a93 Binary files /dev/null and b/PosFile2Dos/m15014d2.mib differ diff --git a/PosFile2Dos/m15014n2.mib b/PosFile2Dos/m15014n2.mib new file mode 100644 index 0000000..648edd5 Binary files /dev/null and b/PosFile2Dos/m15014n2.mib differ diff --git a/PosFile2Dos/m15017n2.mib b/PosFile2Dos/m15017n2.mib new file mode 100644 index 0000000..5ea51f2 Binary files /dev/null and b/PosFile2Dos/m15017n2.mib differ diff --git a/PosFile2Dos/m15020n2.mib b/PosFile2Dos/m15020n2.mib new file mode 100644 index 0000000..4628f64 Binary files /dev/null and b/PosFile2Dos/m15020n2.mib differ diff --git a/PosFile2Dos/m15021n2.mib b/PosFile2Dos/m15021n2.mib new file mode 100644 index 0000000..c30b63a Binary files /dev/null and b/PosFile2Dos/m15021n2.mib differ diff --git a/PosFile2Dos/m15022d2.mib b/PosFile2Dos/m15022d2.mib new file mode 100644 index 0000000..54576ce Binary files /dev/null and b/PosFile2Dos/m15022d2.mib differ diff --git a/PosFile2Dos/m15022n2.mib b/PosFile2Dos/m15022n2.mib new file mode 100644 index 0000000..e24debd Binary files /dev/null and b/PosFile2Dos/m15022n2.mib differ diff --git a/PosFile2Dos/m15023d2.mib b/PosFile2Dos/m15023d2.mib new file mode 100644 index 0000000..99ec4bf Binary files /dev/null and b/PosFile2Dos/m15023d2.mib differ diff --git a/PosFile2Dos/m15023n2.mib b/PosFile2Dos/m15023n2.mib new file mode 100644 index 0000000..fbad7cb Binary files /dev/null and b/PosFile2Dos/m15023n2.mib differ diff --git a/PosFile2Dos/m15024d2.mib b/PosFile2Dos/m15024d2.mib new file mode 100644 index 0000000..2417b3f Binary files /dev/null and b/PosFile2Dos/m15024d2.mib differ diff --git a/PosFile2Dos/m15024n2.mib b/PosFile2Dos/m15024n2.mib new file mode 100644 index 0000000..1fdf113 Binary files /dev/null and b/PosFile2Dos/m15024n2.mib differ diff --git a/PosFile2Dos/m15025d2.mib b/PosFile2Dos/m15025d2.mib new file mode 100644 index 0000000..aeda944 Binary files /dev/null and b/PosFile2Dos/m15025d2.mib differ diff --git a/PosFile2Dos/m15025n2.mib b/PosFile2Dos/m15025n2.mib new file mode 100644 index 0000000..2672795 Binary files /dev/null and b/PosFile2Dos/m15025n2.mib differ diff --git a/PosFile2Dos/m20006d2.mib b/PosFile2Dos/m20006d2.mib new file mode 100644 index 0000000..b8543ef Binary files /dev/null and b/PosFile2Dos/m20006d2.mib differ diff --git a/PosFile2Dos/m20006n2.mib b/PosFile2Dos/m20006n2.mib new file mode 100644 index 0000000..86ff524 Binary files /dev/null and b/PosFile2Dos/m20006n2.mib differ diff --git a/PosFile2Dos/m20010d2.mib b/PosFile2Dos/m20010d2.mib new file mode 100644 index 0000000..f0d7e67 Binary files /dev/null and b/PosFile2Dos/m20010d2.mib differ diff --git a/PosFile2Dos/m20010n2.mib b/PosFile2Dos/m20010n2.mib new file mode 100644 index 0000000..b663bee Binary files /dev/null and b/PosFile2Dos/m20010n2.mib differ diff --git a/PosFile2Dos/m25001d2.mib b/PosFile2Dos/m25001d2.mib new file mode 100644 index 0000000..601a124 Binary files /dev/null and b/PosFile2Dos/m25001d2.mib differ diff --git a/PosFile2Dos/m25001n2.mib b/PosFile2Dos/m25001n2.mib new file mode 100644 index 0000000..b3244a2 Binary files /dev/null and b/PosFile2Dos/m25001n2.mib differ diff --git a/Program.cs b/Program.cs index 991d112..7d96260 100644 --- a/Program.cs +++ b/Program.cs @@ -8,7 +8,8 @@ namespace MHFQuestToMH2Dos const string InDir = "Input"; const string OutDir = "Out"; - const string Ver = "0.2.1"; + const string PosFile2DosDir = "PosFile2Dos"; + const string Ver = "0.3.0"; static void Main(string[] args) { @@ -30,8 +31,42 @@ namespace MHFQuestToMH2Dos return; } - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + if (!Directory.Exists(loc + PosFile2DosDir)) + { + Console.WriteLine("Templete文件不存在"); + Console.ReadLine(); + return; + } + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + + string[] tempfiles = FileHelper.GetDirFile(loc + PosFile2DosDir); + int index_temp = 0; + int errcount_temp = 0; + for (int i = 0; i < tempfiles.Length; i++) + { + string FileName = tempfiles[i].Substring(tempfiles[i].LastIndexOf("\\")); + + if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin")) + { + continue; + } + index_temp++; + + Console.WriteLine($">>>>>>>>>>>>>>读取 第{index_temp}个模板文件 {FileName}<<<<<<<<<<<<<<<<<<<"); + FileHelper.LoadFile(tempfiles[i], out byte[] data); + if (LoadToSaveTemplate.LoadMapTemplateAreaData(data, FileName, tempfiles[i])) + { + Console.WriteLine($">>>>>>>>>>>>>>成功读取 第{index_temp}个,"+ FileName); + } + else + { + errcount_temp++; + Console.WriteLine($">>>>>>>>>>>>>>成功失败 第{index_temp}个"); + } + } + + Console.WriteLine($"原数据读取完毕"); string[] files = FileHelper.GetDirFile(loc + InDir); Console.WriteLine($"共{files.Length}个文件,是否处理? (y/n)");