This commit is contained in:
sin365 2023-03-23 22:10:57 +08:00
parent c34789da45
commit 8988853ecb
2 changed files with 29 additions and 12 deletions

View File

@ -29,7 +29,7 @@ namespace MHFQuestToMH2Dos
target[i] = src[i]; target[i] = src[i];
} }
//清除无意义数据 //清除对于2Dos来说 无意义数据
target[fixindex_1] = 0x00; target[fixindex_1] = 0x00;
string IntPtrHex = ""; string IntPtrHex = "";
@ -46,24 +46,33 @@ namespace MHFQuestToMH2Dos
IntPtrHex += target[i].ToString("X"); IntPtrHex += target[i].ToString("X");
} }
//从前4字节取出指针 定位任务信息位置
long PtrIndex = HexHelper.HexaToDecimal(IntPtrHex); long PtrIndex = HexHelper.HexaToDecimal(IntPtrHex);
//MHF偏移12的位置
long MoveStarPtr = PtrIndex + Offset; long MoveStarPtr = PtrIndex + Offset;
//目标2Dos偏移8的位置
long targetStarPtr = PtrIndex + Offset_2nd;
//取出原始数据
byte[] temp = new byte[moveLenght]; byte[] temp = new byte[moveLenght];
for (int i = 0; i < moveLenght; i++) for (int i = 0; i < moveLenght; i++)
{ {
temp[i] = target[MoveStarPtr + i]; temp[i] = target[MoveStarPtr + i];
target[MoveStarPtr + i] = 0x00;
} }
long targetStarPtr = PtrIndex + Offset_2nd; //清理原始数据
for (int i = 0; i < moveLenght; i++)
{
target[MoveStarPtr + i] = 0x00;
}
//将temp数据往前位移4字节
for (int i = 0; i < moveLenght; i++) for (int i = 0; i < moveLenght; i++)
{ {
target[targetStarPtr + i] = temp[i]; target[targetStarPtr + i] = temp[i];
} }
return true; return true;
} }
catch (Exception ex) catch (Exception ex)

View File

@ -26,23 +26,31 @@
string[] files = FileHelper.GetDirFile(loc + InDir); string[] files = FileHelper.GetDirFile(loc + InDir);
int index= 0; int index= 0;
int errcount = 0;
for(int i = 0;i < files.Length;i++) for(int i = 0;i < files.Length;i++)
{ {
string FileName = files[0].Substring(files[0].LastIndexOf("\\")); string FileName = files[i].Substring(files[i].LastIndexOf("\\"));
if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin")) if (!FileName.ToLower().Contains(".mib") && !FileName.ToLower().Contains(".bin"))
{ {
return; return;
} }
index++; index++;
FileHelper.LoadFile(files[i], out byte[] data); FileHelper.LoadFile(files[i], out byte[] data);
ModifyQuest.ModifyFile(data, out byte[] targetdata); if (ModifyQuest.ModifyFile(data, out byte[] targetdata))
{
string newfileName = FileName + "_unpack"; string newfileName = FileName + "_unpack";
string outstring = loc + OutDir + "\\" + newfileName; string outstring = loc + OutDir + "\\" + newfileName;
FileHelper.SaveFile(outstring, targetdata); FileHelper.SaveFile(outstring, targetdata);
Console.WriteLine($"已处理第{index}个:{outstring}"); Console.WriteLine($"成功已处理 第{index}个:{outstring}");
}
else
{
errcount++;
Console.WriteLine($"处理失败 第{index}个:{files[i]}");
}
} }
Console.WriteLine($"需处理{files.Length}个文件"); Console.WriteLine($"需处理{files.Length}个文件,其中{errcount}个失败");
Console.ReadLine(); Console.ReadLine();
} }
} }