任务数据

This commit is contained in:
sin365 2023-04-04 18:28:24 +08:00
parent f17c334fec
commit 15a8da3216
10 changed files with 167 additions and 2 deletions

Binary file not shown.

View File

@ -137,6 +137,42 @@ namespace MHFQuestToMH2Dos
srcdata[startoffset + i] = targetVal[i]; srcdata[startoffset + i] = targetVal[i];
} }
/**
* byte[]byte[] byte高位在前
*/
public static void ModifyDataToBytes(byte[] srcdata, byte[] targetVal, int startoffset)
{
//抹去数据
for (int i = 0; i < targetVal.Length; i++)
srcdata[startoffset + i] = 0x00;
for (int i = 0; i < targetVal.Length && i < targetVal.Length; i++)
srcdata[startoffset + i] = targetVal[i];
}
/**
*
*/
public static bool CheckDataEquals(byte[] srcdata, byte[] targetVal, int startoffset)
{
byte[] temp = new byte[targetVal.Length];
for (int i = 0; i < targetVal.Length && i < targetVal.Length; i++)
temp[i] = srcdata[startoffset + i];
if (!Array.Equals(targetVal, temp))
{
for (int i = 0; i < targetVal.Length; i++)
{
Console.WriteLine($"{(targetVal[i] != temp[i] ? "" : "")} target{targetVal[i]} src{temp[i]}");
}
}
return Array.Equals(targetVal, temp);
}
/// <summary> /// <summary>
/// 另一种16进制转10进制的处理方式Multiplier参与*16的循环很巧妙对Multiplier的处理很推荐逻辑统一 /// 另一种16进制转10进制的处理方式Multiplier参与*16的循环很巧妙对Multiplier的处理很推荐逻辑统一
/// </summary> /// </summary>

View File

@ -70,6 +70,12 @@ namespace MHFQuestToMH2Dos
{ {
int _One_CurrPtr = HexHelper.bytesToInt(target, 4, _CAreaSetTop_CurrPtr); int _One_CurrPtr = HexHelper.bytesToInt(target, 4, _CAreaSetTop_CurrPtr);
if (_One_CurrPtr == 0x0)
{
Log.HexInfo(_CAreaSetTop_CurrPtr, "区域设置"+i+"指针为0跳过");
break;
}
List<byte[]> datas = new List<byte[]>(); List<byte[]> datas = new List<byte[]>();
int Set_TargetIndex = 0; int Set_TargetIndex = 0;
while (true) while (true)

View File

@ -125,6 +125,9 @@ namespace MHFQuestToMH2Dos
if (ModifyQuestRewardItem(target, out byte[] out_ModifyQuestRewardItem)) if (ModifyQuestRewardItem(target, out byte[] out_ModifyQuestRewardItem))
target = out_ModifyQuestRewardItem; target = out_ModifyQuestRewardItem;
if (FixMapAreaData(target, out byte[] out_FixMapAreaData))
target = out_FixMapAreaData;
return true; return true;
} }
@ -606,5 +609,126 @@ namespace MHFQuestToMH2Dos
Console.WriteLine(ex); target = null; return false; Console.WriteLine(ex); target = null; return false;
} }
} }
public static bool FixMapAreaData(byte[] src,out byte[] target)
{
int _QuestTargetMapID;
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 srcData2Dos = LoadToSaveTemplate.DictMapAreaData[_QuestTargetMapID];
#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);
if (_One_CurrPtr == 0x0)
{
Log.HexInfo(_CAreaSetTop_CurrPtr, "区域设置" + i + "指针为0跳过");
break;
}
if (srcData2Dos.targetDatas.Length <= i)
{
Log.HexWar(_One_CurrPtr, "第" + i + "区 区域设置,比2Dos区数超限。");
break;
}
int Set_TargetIndex = 0;
while (true)
{
if (MHHelper.CheckEnd(target, _One_CurrPtr)
||
HexHelper.bytesToInt(target, 1, _One_CurrPtr) == 0)
{
Log.HexInfo(_One_CurrPtr, "区域设置结束符");
break;
}
if (srcData2Dos.targetDatas.Length <= i)
{
Log.HexWar(_One_CurrPtr, "第" + i + "区,第" + Set_TargetIndex + "个目标,比2Dos目标数超限。");
break;
}
byte[] srcOneData = srcData2Dos.targetDatas[i].targetData[Set_TargetIndex];
if (!HexHelper.CheckDataEquals(target, srcOneData, _One_CurrPtr))
{
Log.HexWar(_One_CurrPtr, "第" + i + "区,第" + Set_TargetIndex + "个目标数据和2Dos差异长度{0}", srcOneData.Length);
}
HexHelper.ModifyDataToBytes(target, srcOneData, _One_CurrPtr);
Log.HexTips(_One_CurrPtr, "第" + i + "区,第" + Set_TargetIndex + "个目标更换为2Dos数据长度{0}", srcOneData.Length);
Set_TargetIndex++;
_One_CurrPtr += 0x34;
}
_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++)
{
if (srcData2Dos.targetDatas.Length <= i)
{
Log.HexWar(_CAreaPosTop_CurrPtr, "第" + i + "区 换区映射,比2Dos区数超限。");
break;
}
byte[] srcOneData = srcData2Dos.areaPosDatas[i];
if (!HexHelper.CheckDataEquals(target, srcOneData, _CAreaPosTop_CurrPtr))
{
Log.HexWar(_CAreaPosTop_CurrPtr, "第" + i + "区的区域映射数据和2Dos差异读取数据,长度{0}", srcOneData.Length);
}
HexHelper.ModifyDataToBytes(target, srcOneData, _CAreaPosTop_CurrPtr);
Log.HexTips(_CAreaPosTop_CurrPtr, "第" + i + "区的区域映射更换为2Dos数据读取数据,长度{0}", srcOneData.Length);
_CAreaPosTop_CurrPtr += 0x20;
}
#endregion
}
catch (Exception ex)
{
Console.WriteLine(ex);
target = null;
return false;
}
return true;
}
} }
} }

View File

@ -66,12 +66,11 @@ namespace MHFQuestToMH2Dos
} }
} }
Console.WriteLine($"原数据读取完毕"); Console.WriteLine($"-----------原数据读取完毕-----------");
string[] files = FileHelper.GetDirFile(loc + InDir); string[] files = FileHelper.GetDirFile(loc + InDir);
Console.WriteLine($"共{files.Length}个文件,是否处理? (y/n)"); Console.WriteLine($"共{files.Length}个文件,是否处理? (y/n)");
string yn = Console.ReadLine(); string yn = Console.ReadLine();
if (yn.ToLower() != "y") if (yn.ToLower() != "y")
return; return;