读取2Dos每个地图 昼夜的 地图区域设置,用于修正移植任务坐标
This commit is contained in:
parent
f799b7a38a
commit
f17c334fec
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
18
HexHelper.cs
18
HexHelper.cs
@ -21,6 +21,23 @@ namespace MHFQuestToMH2Dos
|
||||
return target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取byte[]数据
|
||||
/// </summary>
|
||||
/// <param name="src"></param>
|
||||
/// <param name="lenght"></param>
|
||||
/// <param name="offset"></param>
|
||||
/// <returns></returns>
|
||||
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高位在前
|
||||
*/
|
||||
|
129
LoadToSaveTemplate.cs
Normal file
129
LoadToSaveTemplate.cs
Normal file
@ -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<byte[]>();
|
||||
}
|
||||
public TargetData[] targetDatas;
|
||||
public List<byte[]> areaPosDatas;
|
||||
}
|
||||
|
||||
public class TargetData
|
||||
{
|
||||
public TargetData(List<byte[]> data)
|
||||
{
|
||||
targetData = data;
|
||||
}
|
||||
public List<byte[]> targetData;
|
||||
}
|
||||
|
||||
|
||||
public static class LoadToSaveTemplate
|
||||
{
|
||||
public static Dictionary<int, MapAreaData> DictMapAreaData = new Dictionary<int, MapAreaData>();
|
||||
public static Dictionary<int, string> DictMapIDFileName = new Dictionary<int, string>();
|
||||
public static Dictionary<int, string> DictMapIDFullFileName = new Dictionary<int, string>();
|
||||
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<byte[]> datas = new List<byte[]>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
5
Log.cs
5
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
13
MHHelper.cs
13
MHHelper.cs
@ -7,8 +7,19 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MHFQuestToMH2Dos
|
||||
{
|
||||
public class MHHelper
|
||||
public static class MHHelper
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 地图区域数量
|
||||
/// </summary>
|
||||
static List<int> MapAreaCount = new List<int> { 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;
|
||||
|
@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// 道具ID超出最大限制时,修改为【不可燃烧的废物】
|
||||
/// </summary>
|
||||
const int cModify_OutOfItemID = 0x00AE;
|
||||
public const int cModify_OutOfItemID = 0x00AE;
|
||||
|
||||
/// <summary>
|
||||
/// Dos中无意义数据
|
||||
/// </summary>
|
||||
const int cNon0x00For2DosPtr = 19;
|
||||
public const int cNon0x00For2DosPtr = 19;
|
||||
/// <summary>
|
||||
/// MHF任务信息偏移
|
||||
/// </summary>
|
||||
const int cQuestMHFOffset = 12;
|
||||
public const int cQuestMHFOffset = 12;
|
||||
/// <summary>
|
||||
/// 2Dos任务信息偏移
|
||||
/// </summary>
|
||||
const int cQuest2DosOffset = 8;
|
||||
public const int cQuest2DosOffset = 8;
|
||||
/// <summary>
|
||||
/// 任务信息需偏移长度
|
||||
/// </summary>
|
||||
const int cQuestMhfToDosSetLenght = 64;
|
||||
public const int cQuestMhfToDosSetLenght = 64;
|
||||
|
||||
/// <summary>
|
||||
/// 任务信息 指针组 总长度
|
||||
/// </summary>
|
||||
const int cQuest2DosInfoPtrGourpLenght = 72;
|
||||
public const int cQuest2DosInfoPtrGourpLenght = 72;
|
||||
/// <summary>
|
||||
/// 移动信息指针组 到的指定位置
|
||||
/// </summary>
|
||||
const int cSetInfoPtrGourpMoveToStarPos = 0x88;
|
||||
public const int cSetInfoPtrGourpMoveToStarPos = 0x88;
|
||||
|
||||
/// <summary>
|
||||
/// 任务内容 指针组 到的指定位置
|
||||
/// </summary>
|
||||
const int cQuestContenPtrGourpMoveToStarPos = 0xD0;
|
||||
public const int cQuestContenPtrGourpMoveToStarPos = 0xD0;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移动整个任务文本 到的指定位置
|
||||
/// </summary>
|
||||
const int cQuestTextAllMsgMoveToStarPos = 0xF0;
|
||||
public const int cQuestTextAllMsgMoveToStarPos = 0xF0;
|
||||
/// <summary>
|
||||
/// 移动整个任务文本 到的指定的截止位置
|
||||
/// </summary>
|
||||
const int cQuestTextAllMsgMoveToEndPos = 0x1Ff;
|
||||
public const int cQuestTextAllMsgMoveToEndPos = 0x1Ff;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务_类型 偏移
|
||||
/// </summary>
|
||||
const int cQuestInfo_Type_Offset = 0;
|
||||
public const int cQuestInfo_Type_Offset = 0;
|
||||
/// <summary>
|
||||
/// 任务_类型 长度
|
||||
/// </summary>
|
||||
const int cQuestInfo_Type_Lenght = 1;
|
||||
public const int cQuestInfo_Type_Lenght = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 任务_星级 偏移
|
||||
/// </summary>
|
||||
const int cQuestInfo_Star_Offset = 4;
|
||||
public const int cQuestInfo_Star_Offset = 4;
|
||||
/// <summary>
|
||||
/// 任务_星级 长度
|
||||
/// </summary>
|
||||
const int cQuestInfo_Star_Lenght = 2;
|
||||
public const int cQuestInfo_Star_Lenght = 2;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务_类型 偏移
|
||||
/// </summary>
|
||||
const int cQuestInfo_TargetMap_Offset = 32;
|
||||
public const int cQuestInfo_TargetMap_Offset = 32;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务_类型 长度
|
||||
/// </summary>
|
||||
const int cQuestInfo_TargetMapID_Lenght = 1;
|
||||
public const int cQuestInfo_TargetMapID_Lenght = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 任务_类型 偏移
|
||||
/// </summary>
|
||||
const int cQuestInfo_QuestID_Offset = 42;
|
||||
public const int cQuestInfo_QuestID_Offset = 42;
|
||||
/// <summary>
|
||||
/// 任务_类型 长度
|
||||
/// </summary>
|
||||
const int cQuestInfo_QuestID_Lenght = 2;
|
||||
public const int cQuestInfo_QuestID_Lenght = 2;
|
||||
|
||||
public static bool ModifyQuset(byte[] src, out byte[] target)
|
||||
{
|
||||
|
BIN
PosFile2Dos/m03008n2.mib
Normal file
BIN
PosFile2Dos/m03008n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m10101d2.mib
Normal file
BIN
PosFile2Dos/m10101d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m10101n2.mib
Normal file
BIN
PosFile2Dos/m10101n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m12078n2.mib
Normal file
BIN
PosFile2Dos/m12078n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15006d2.mib
Normal file
BIN
PosFile2Dos/m15006d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15006n2.mib
Normal file
BIN
PosFile2Dos/m15006n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15014d2.mib
Normal file
BIN
PosFile2Dos/m15014d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15014n2.mib
Normal file
BIN
PosFile2Dos/m15014n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15017n2.mib
Normal file
BIN
PosFile2Dos/m15017n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15020n2.mib
Normal file
BIN
PosFile2Dos/m15020n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15021n2.mib
Normal file
BIN
PosFile2Dos/m15021n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15022d2.mib
Normal file
BIN
PosFile2Dos/m15022d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15022n2.mib
Normal file
BIN
PosFile2Dos/m15022n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15023d2.mib
Normal file
BIN
PosFile2Dos/m15023d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15023n2.mib
Normal file
BIN
PosFile2Dos/m15023n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15024d2.mib
Normal file
BIN
PosFile2Dos/m15024d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15024n2.mib
Normal file
BIN
PosFile2Dos/m15024n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15025d2.mib
Normal file
BIN
PosFile2Dos/m15025d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m15025n2.mib
Normal file
BIN
PosFile2Dos/m15025n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m20006d2.mib
Normal file
BIN
PosFile2Dos/m20006d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m20006n2.mib
Normal file
BIN
PosFile2Dos/m20006n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m20010d2.mib
Normal file
BIN
PosFile2Dos/m20010d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m20010n2.mib
Normal file
BIN
PosFile2Dos/m20010n2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m25001d2.mib
Normal file
BIN
PosFile2Dos/m25001d2.mib
Normal file
Binary file not shown.
BIN
PosFile2Dos/m25001n2.mib
Normal file
BIN
PosFile2Dos/m25001n2.mib
Normal file
Binary file not shown.
37
Program.cs
37
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;
|
||||
}
|
||||
|
||||
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)");
|
||||
|
Loading…
Reference in New Issue
Block a user