修正一些最大值,和bug

This commit is contained in:
sin365 2023-04-10 16:13:55 +08:00
parent d071e6f692
commit 75d4995f31
5 changed files with 150 additions and 69 deletions

View File

@ -34,6 +34,8 @@ namespace MHFQuestToMH2Dos
public static Dictionary<int, MapAreaData> DictMapAreaData = new Dictionary<int, MapAreaData>(); 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> DictMapIDFileName = new Dictionary<int, string>();
public static Dictionary<int, string> DictMapIDFullFileName = new Dictionary<int, string>(); public static Dictionary<int, string> DictMapIDFullFileName = new Dictionary<int, string>();
public static Dictionary<int, string> DictGutiName = new Dictionary<int, string>();
public static Dictionary<int, string> DictStarName = new Dictionary<int, string>();
public static bool LoadMapTemplateAreaData(byte[] src,string FileName,string FullFileName) public static bool LoadMapTemplateAreaData(byte[] src,string FileName,string FullFileName)
{ {
byte[] target; byte[] target;
@ -133,6 +135,35 @@ namespace MHFQuestToMH2Dos
return true; return true;
} }
public static bool LoadMaxGuti(byte[] src)
{
try
{
byte[] target = HexHelper.CopyByteArr(src);//加载数据
//从前4字节取出指针 定位任务信息位置
int _QuestInfoPtr = HexHelper.bytesToInt(target, 4, 0x00);
//从前4字节取出指针 定位任务信息位置
int _QuestContentPtr = HexHelper.bytesToInt(target, 4, _QuestInfoPtr + 36);
int _QuestNametPtr = HexHelper.bytesToInt(target, 4, _QuestContentPtr);
string QuestName = HexHelper.ReadBytesToString(src, _QuestNametPtr);
//固体值
int _GuTiValue = HexHelper.bytesToInt(target, 4, 0x48);
DictGutiName[_GuTiValue] = QuestName;
//任务星 尝试处理方案
int _QuestStart = HexHelper.bytesToInt(target, 1, _QuestInfoPtr + ModifyQuest.cQuestInfo_Star_Offset);
DictStarName[_QuestStart] = QuestName;
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return false;
}
}
public static Dictionary<string, int> DictTimeTypeCount = new Dictionary<string, int>(); public static Dictionary<string, int> DictTimeTypeCount = new Dictionary<string, int>();
public static void GetModeType(byte[] src,string FileName) public static void GetModeType(byte[] src,string FileName)

5
Log.cs
View File

@ -8,8 +8,10 @@ namespace MHFQuestToMH2Dos
{ {
public static class Log public static class Log
{ {
static bool bShowHex = true;
public static void HexInfo(long HexPos,string log, params long[] arr) public static void HexInfo(long HexPos,string log, params long[] arr)
{ {
if(!bShowHex) return;
log = "0x" + HexPos.ToString("X") + ":" +log; log = "0x" + HexPos.ToString("X") + ":" +log;
if(arr != null) if(arr != null)
{ {
@ -26,6 +28,7 @@ namespace MHFQuestToMH2Dos
public static void HexTips(long HexPos, string log, params long[] arr) public static void HexTips(long HexPos, string log, params long[] arr)
{ {
if (!bShowHex) return;
ConsoleColor src_color = Console.ForegroundColor; ConsoleColor src_color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow; Console.ForegroundColor = ConsoleColor.Yellow;
HexInfo(HexPos, log, arr); HexInfo(HexPos, log, arr);
@ -34,6 +37,7 @@ namespace MHFQuestToMH2Dos
public static void HexWar(long HexPos, string log, params long[] arr) public static void HexWar(long HexPos, string log, params long[] arr)
{ {
if (!bShowHex) return;
ConsoleColor src_color = Console.ForegroundColor; ConsoleColor src_color = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Red; Console.ForegroundColor = ConsoleColor.Red;
HexInfo(HexPos, log, arr); HexInfo(HexPos, log, arr);
@ -42,6 +46,7 @@ namespace MHFQuestToMH2Dos
public static void HexColor(ConsoleColor color,long HexPos, string log, params long[] arr) public static void HexColor(ConsoleColor color,long HexPos, string log, params long[] arr)
{ {
if (!bShowHex) return;
ConsoleColor src_color = Console.ForegroundColor; ConsoleColor src_color = Console.ForegroundColor;
Console.ForegroundColor = color; Console.ForegroundColor = color;
HexInfo(HexPos, log, arr); HexInfo(HexPos, log, arr);

View File

@ -22,11 +22,17 @@ namespace MHFQuestToMH2Dos
public static bool CheckEnd(byte[] data, int Ptr) public static bool CheckEnd(byte[] data, int Ptr)
{ {
if (Ptr < 0)
return true;
if (data.Length <= Ptr + 1)
return true;
return HexHelper.bytesToUInt(data, 2, Ptr) == 0xFFFF; return HexHelper.bytesToUInt(data, 2, Ptr) == 0xFFFF;
} }
public static bool CheckEndWith1Byte(byte[] data, int Ptr) public static bool CheckEndWith1Byte(byte[] data, int Ptr)
{ {
if (data.Length <= Ptr)
return true;
return HexHelper.bytesToUInt(data, 1, Ptr) == 0xFF; return HexHelper.bytesToUInt(data, 1, Ptr) == 0xFF;
} }

View File

@ -14,7 +14,7 @@ namespace MHFQuestToMH2Dos
public const int cMax_ItemID = 0x031D; public const int cMax_ItemID = 0x031D;
public const int cMax_FishID = 0x0017; public const int cMax_FishID = 0x0017;
public const int cMax_GuTi = 0xA; public const int cMax_GuTi = 0x16;
public const int cMax_QuestStar = 8; public const int cMax_QuestStar = 8;
public const int cModify_QuestID = 0xEA74; public const int cModify_QuestID = 0xEA74;
@ -91,13 +91,11 @@ namespace MHFQuestToMH2Dos
/// </summary> /// </summary>
public const int cQuestInfo_Star_Lenght = 2; public const int cQuestInfo_Star_Lenght = 2;
/// <summary> /// <summary>
/// 任务_类型 偏移 /// 任务_类型 偏移
/// </summary> /// </summary>
public const int cQuestInfo_TargetMap_Offset = 32; public const int cQuestInfo_TargetMap_Offset = 32;
/// <summary> /// <summary>
/// 任务_类型 长度 /// 任务_类型 长度
/// </summary> /// </summary>
@ -118,30 +116,39 @@ namespace MHFQuestToMH2Dos
if (ModifyFileOffset(target, out byte[] out_ModifyFileOffset)) if (ModifyFileOffset(target, out byte[] out_ModifyFileOffset))
target = out_ModifyFileOffset; target = out_ModifyFileOffset;
else { return false; }
if (ModifyTextOffset(target, out byte[] out_ModifyTextOffset)) if (ModifyTextOffset(target, out byte[] out_ModifyTextOffset))
target = out_ModifyTextOffset; target = out_ModifyTextOffset;
else { return false; }
if (ModifyQuestMap(target, out byte[] out_ModifyQuestMap)) if (ModifyQuestMap(target, out byte[] out_ModifyQuestMap))
target = out_ModifyQuestMap; target = out_ModifyQuestMap;
else { return false; }
if (ModifyQuestBOSS(target, out byte[] out_ModifyQuestBOSS)) if (ModifyQuestBOSS(target, out byte[] out_ModifyQuestBOSS))
target = out_ModifyQuestBOSS; target = out_ModifyQuestBOSS;
else { return false; }
if (FixMapAreaData(target, out byte[] out_FixMapAreaData)) if (FixMapAreaData(target, out byte[] out_FixMapAreaData))
target = out_FixMapAreaData; target = out_FixMapAreaData;
else { return false; }
if (ModifyQuestRewardItem(target, out byte[] out_ModifyQuestRewardItem)) if (ModifyQuestRewardItem(target, out byte[] out_ModifyQuestRewardItem))
target = out_ModifyQuestRewardItem; target = out_ModifyQuestRewardItem;
else { return false; }
if (FixSuppliesItem(target, out byte[] out_FixSuppliesItem)) if (FixSuppliesItem(target, out byte[] out_FixSuppliesItem))
target = out_FixSuppliesItem; target = out_FixSuppliesItem;
else { return false; }
if (FixItemPoint(target, out byte[] out_FixItemPoint)) if (FixItemPoint(target, out byte[] out_FixItemPoint))
target = out_FixItemPoint; target = out_FixItemPoint;
else { return false; }
if (FixFishGroupPoint(target, out byte[] out_FixFishGroupPoint)) if (FixFishGroupPoint(target, out byte[] out_FixFishGroupPoint))
target = out_FixFishGroupPoint; target = out_FixFishGroupPoint;
else { return false; }
return true; return true;
} }
@ -312,7 +319,15 @@ namespace MHFQuestToMH2Dos
temp[i] = target[_QuestNametPtr + i]; temp[i] = target[_QuestNametPtr + i];
string QuestName = HexHelper.ReadBytesToString(temp); string QuestName = HexHelper.ReadBytesToString(temp);
try
{
Log.HexColor(ConsoleColor.Green, _QuestNametPtr, "任务文本:" + QuestName); ; Log.HexColor(ConsoleColor.Green, _QuestNametPtr, "任务文本:" + QuestName); ;
}
catch(Exception ex)
{
}
Log.HexInfo(cQuestTextAllMsgMoveToStarPos, "清理数据旧位置【任务文本】"); Log.HexInfo(cQuestTextAllMsgMoveToStarPos, "清理数据旧位置【任务文本】");
@ -618,12 +633,15 @@ namespace MHFQuestToMH2Dos
_QuestTargetMapID = HexHelper.bytesToInt(target, ModifyQuest.cQuestInfo_TargetMapID_Lenght, _QuestInfoPtr + ModifyQuest.cQuestInfo_TargetMap_Offset); _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); Log.HexColor(ConsoleColor.Green, _QuestInfoPtr + ModifyQuest.cQuestInfo_TargetMap_Offset, "目的地地图,指针->{0} 【" + MHHelper.Get2MapName(_QuestTargetMapID) + "】", _QuestTargetMapID);
if (LoadToSaveTemplate.DictMapAreaData.ContainsKey(_QuestTargetMapID))
{
//区域数量 //区域数量
int _AreaCount = MHHelper.GetMapAreaCount(_QuestTargetMapID); int _AreaCount = MHHelper.GetMapAreaCount(_QuestTargetMapID);
Log.Info(MHHelper.Get2MapName(_QuestTargetMapID) + "的地图数量" + _AreaCount); Log.Info(MHHelper.Get2MapName(_QuestTargetMapID) + "的地图数量" + _AreaCount);
MapAreaData srcData2Dos = LoadToSaveTemplate.DictMapAreaData[_QuestTargetMapID]; MapAreaData srcData2Dos = LoadToSaveTemplate.DictMapAreaData[_QuestTargetMapID];
#region #region
//换区设置指针 //换区设置指针
@ -702,6 +720,11 @@ namespace MHFQuestToMH2Dos
#endregion #endregion
} }
else
{
Log.HexColor(ConsoleColor.Green, _QuestInfoPtr + ModifyQuest.cQuestInfo_TargetMap_Offset, "目的地地图,在源数据之外");
}
}
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex);
@ -889,10 +912,6 @@ namespace MHFQuestToMH2Dos
for (int i = 0; i < 90; i++) for (int i = 0; i < 90; i++)
{ {
if (i == 44)
{
}
//若遇到结束符或无数据 //若遇到结束符或无数据
if (MHHelper.CheckEnd(target, _ItemPoint_CurrPtr) if (MHHelper.CheckEnd(target, _ItemPoint_CurrPtr)
//|| //||

View File

@ -1,4 +1,5 @@
using System.Text; using System.Text;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace MHFQuestToMH2Dos namespace MHFQuestToMH2Dos
{ {
@ -65,8 +66,27 @@ namespace MHFQuestToMH2Dos
errcount_temp++; errcount_temp++;
//Console.WriteLine($">>>>>>>>>>>>>>成功失败 第{index_temp}个"); //Console.WriteLine($">>>>>>>>>>>>>>成功失败 第{index_temp}个");
} }
//LoadToSaveTemplate.LoadMaxGuti(data);
} }
//int[] gutikeys = LoadToSaveTemplate.DictGutiName.Keys.ToArray();
//gutikeys = gutikeys.OrderBy(w => w).ToArray();
//foreach (var k in gutikeys)
//{
// Log.HexInfo(k, "任务" + LoadToSaveTemplate.DictGutiName[k] + ",固体值{0}", k);
//}
//int[] gutikeys = LoadToSaveTemplate.DictStarName.Keys.ToArray();
//gutikeys = gutikeys.OrderBy(w => w).ToArray();
//foreach (var k in gutikeys)
//{
// Log.HexInfo(k, "任务" + LoadToSaveTemplate.DictStarName[k] + ",星{0}", k);
//}
Console.WriteLine($"-----------原数据读取完毕-----------"); Console.WriteLine($"-----------原数据读取完毕-----------");
string[] files = FileHelper.GetDirFile(loc + InDir); string[] files = FileHelper.GetDirFile(loc + InDir);
@ -103,7 +123,7 @@ namespace MHFQuestToMH2Dos
else else
{ {
errcount++; errcount++;
Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个: 输出到{files[i]}"); Console.WriteLine($">>>>>>>>>>>>>>处理失败 第{index}个");
} }
} }