1. Better bug check
2. Fixed a mistyped ID-Item mapping
This commit is contained in:
parent
ea35663332
commit
a684fea1af
@ -17,12 +17,12 @@ Global
|
|||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.ActiveCfg = Debug|x86
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.Build.0 = Debug|x86
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.ActiveCfg = Release|x86
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.Build.0 = Release|x86
|
{80372081-2D34-424B-93E2-89D5815BF3E8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
40
MHSEC-G/MHSEC-G/BugCheck.cs
Normal file
40
MHSEC-G/MHSEC-G/BugCheck.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace MHSEC_G
|
||||||
|
{
|
||||||
|
public class BugCheck
|
||||||
|
{
|
||||||
|
public enum ErrorCode
|
||||||
|
{
|
||||||
|
// Facility Model
|
||||||
|
MODEL_INVALID_FILE_SIZE = 0x1,
|
||||||
|
MODEL_READ_BYTE_OVERFLOW = 0x2,
|
||||||
|
MODEL_WRITE_BYTE_OVERFLOW = 0x3,
|
||||||
|
MODEL_READ_UINT16_OVERFLOW = 0x4,
|
||||||
|
MODEL_WRITE_UINT16_OVERFLOW = 0x5,
|
||||||
|
MODEL_READ_UINT32_OVERFLOW = 0x6,
|
||||||
|
MODEL_WRITE_UINT32_OVERFLOW = 0x7,
|
||||||
|
MODEL_WRITE_UNICODE_OVERFLOW = 0x8,
|
||||||
|
|
||||||
|
// Faciltiy ViewModel
|
||||||
|
VIEWMODEL_NULL_SAVE = 0x11,
|
||||||
|
|
||||||
|
// Faciltiy Item
|
||||||
|
ITEM_NO_CORRESPONDENCE = 0x21,
|
||||||
|
ITEM_MAPPING_CORRUPTED = 0x22,
|
||||||
|
ITEM_MAPPING_DNE = 0x23,
|
||||||
|
|
||||||
|
}
|
||||||
|
public static void bug_check(ErrorCode error_code, string error_message)
|
||||||
|
{
|
||||||
|
MessageBoxResult result = MessageBox.Show("Error code: 0x" + ((int)error_code).ToString("X4") + "\nMessage: " + error_message, "MHSEC-G Bug Check",
|
||||||
|
MessageBoxButton.OK, MessageBoxImage.Stop);
|
||||||
|
if (result == MessageBoxResult.OK)
|
||||||
|
{
|
||||||
|
System.Windows.Forms.Application.Exit();
|
||||||
|
}
|
||||||
|
Environment.Exit((int)error_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using MHSEC_G.Annotations;
|
using MHSEC_G.Annotations;
|
||||||
@ -14,12 +15,18 @@ namespace MHSEC_G
|
|||||||
private static readonly uint OFFSETR_ITEM_ID = 0x0;
|
private static readonly uint OFFSETR_ITEM_ID = 0x0;
|
||||||
private static readonly uint OFFSETR_ITEM_COUNT = 0x2;
|
private static readonly uint OFFSETR_ITEM_COUNT = 0x2;
|
||||||
private static readonly uint OFFSETA_ITEM_BOX_END = 0x2EE7;
|
private static readonly uint OFFSETA_ITEM_BOX_END = 0x2EE7;
|
||||||
|
public static readonly uint OFFSETA_FIRST_KEY_ITEM = 0x17B0;
|
||||||
|
|
||||||
private static readonly string ID_MAPPING_FILE_NAME = "idmap.txt";
|
private static readonly string ID_MAPPING_FILE_NAME = "idmap.txt";
|
||||||
private static readonly Dictionary<uint, uint> OFFSET_ID_MAPPING = new Dictionary<uint, uint>();
|
private static readonly Dictionary<uint, uint> OFFSET_ID_MAPPING = new Dictionary<uint, uint>();
|
||||||
private static readonly Dictionary<uint, string> OFFSET_NAME_MAPPING = new Dictionary<uint, string>();
|
private static readonly Dictionary<uint, string> OFFSET_NAME_MAPPING = new Dictionary<uint, string>();
|
||||||
|
|
||||||
private readonly uint _offset;
|
private readonly uint _offset;
|
||||||
|
|
||||||
|
public uint offset
|
||||||
|
{
|
||||||
|
get { return _offset; }
|
||||||
|
}
|
||||||
private readonly Model _model;
|
private readonly Model _model;
|
||||||
|
|
||||||
public string name
|
public string name
|
||||||
@ -91,7 +98,9 @@ namespace MHSEC_G
|
|||||||
{
|
{
|
||||||
if (item_id != OFFSET_ID_MAPPING[offset])
|
if (item_id != OFFSET_ID_MAPPING[offset])
|
||||||
{
|
{
|
||||||
throw new SystemException("Item offset and ID do not correspond.");
|
// correct to the correct id
|
||||||
|
// BugCheck.bug_check(BugCheck.ErrorCode.ITEM_NO_CORRESPONDENCE, "Item offset " + offset.ToString("X") + " and item ID " + item_id.ToString("X") + " do not correspond.");
|
||||||
|
Model.write_uint16_le(model.save_file, offset + OFFSETR_ITEM_ID, OFFSET_ID_MAPPING[offset]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +113,15 @@ namespace MHSEC_G
|
|||||||
public static void read_item_mappings()
|
public static void read_item_mappings()
|
||||||
{
|
{
|
||||||
string line;
|
string line;
|
||||||
System.IO.StreamReader file = new System.IO.StreamReader(ID_MAPPING_FILE_NAME);
|
System.IO.StreamReader file = null;
|
||||||
|
|
||||||
|
if (!File.Exists(ID_MAPPING_FILE_NAME))
|
||||||
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.ITEM_MAPPING_DNE,
|
||||||
|
"Cannot find mapping file " + ID_MAPPING_FILE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
file = new System.IO.StreamReader(ID_MAPPING_FILE_NAME);
|
||||||
while ((line = file.ReadLine()) != null)
|
while ((line = file.ReadLine()) != null)
|
||||||
{
|
{
|
||||||
if (line.Length == 0)
|
if (line.Length == 0)
|
||||||
@ -112,7 +129,9 @@ namespace MHSEC_G
|
|||||||
|
|
||||||
string[] eachline = line.Split('\t');
|
string[] eachline = line.Split('\t');
|
||||||
if (eachline.Length != 3)
|
if (eachline.Length != 3)
|
||||||
throw new SystemException("Item mapping file is corrupted.");
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.ITEM_MAPPING_CORRUPTED, "Invalid mapping file line:\n" + line);
|
||||||
|
}
|
||||||
|
|
||||||
OFFSET_ID_MAPPING.Add(UInt32.Parse(eachline[0], System.Globalization.NumberStyles.HexNumber), UInt32.Parse(eachline[1], System.Globalization.NumberStyles.HexNumber));
|
OFFSET_ID_MAPPING.Add(UInt32.Parse(eachline[0], System.Globalization.NumberStyles.HexNumber), UInt32.Parse(eachline[1], System.Globalization.NumberStyles.HexNumber));
|
||||||
OFFSET_NAME_MAPPING.Add(UInt32.Parse(eachline[0], System.Globalization.NumberStyles.HexNumber), eachline[2]);
|
OFFSET_NAME_MAPPING.Add(UInt32.Parse(eachline[0], System.Globalization.NumberStyles.HexNumber), eachline[2]);
|
||||||
|
@ -13,6 +13,22 @@
|
|||||||
<FileAlignment>512</FileAlignment>
|
<FileAlignment>512</FileAlignment>
|
||||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<PublishUrl>publish\</PublishUrl>
|
||||||
|
<Install>true</Install>
|
||||||
|
<InstallFrom>Disk</InstallFrom>
|
||||||
|
<UpdateEnabled>false</UpdateEnabled>
|
||||||
|
<UpdateMode>Foreground</UpdateMode>
|
||||||
|
<UpdateInterval>7</UpdateInterval>
|
||||||
|
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
|
||||||
|
<UpdatePeriodically>false</UpdatePeriodically>
|
||||||
|
<UpdateRequired>false</UpdateRequired>
|
||||||
|
<MapFileExtensions>true</MapFileExtensions>
|
||||||
|
<ApplicationRevision>0</ApplicationRevision>
|
||||||
|
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
|
||||||
|
<IsWebBootstrapper>false</IsWebBootstrapper>
|
||||||
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
|
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -23,6 +39,7 @@
|
|||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
@ -32,24 +49,7 @@
|
|||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
|
||||||
<OutputPath>bin\x86\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<PlatformTarget>x86</PlatformTarget>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
@ -72,6 +72,7 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="BugCheck.cs" />
|
||||||
<Compile Include="Character.cs" />
|
<Compile Include="Character.cs" />
|
||||||
<Compile Include="EggFragment.cs" />
|
<Compile Include="EggFragment.cs" />
|
||||||
<Compile Include="Item.cs" />
|
<Compile Include="Item.cs" />
|
||||||
@ -109,7 +110,9 @@
|
|||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
<None Include="app.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
@ -119,6 +122,23 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="idmap.txt" />
|
<Resource Include="idmap.txt" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<BootstrapperPackage Include=".NETFramework,Version=v4.0">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Microsoft .NET Framework 4 %28x86 and x64%29</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>.NET Framework 3.5 SP1</ProductName>
|
||||||
|
<Install>false</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
<BootstrapperPackage Include="Microsoft.Windows.Installer.4.5">
|
||||||
|
<Visible>False</Visible>
|
||||||
|
<ProductName>Windows Installer 4.5</ProductName>
|
||||||
|
<Install>true</Install>
|
||||||
|
</BootstrapperPackage>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
@ -12,7 +12,7 @@ namespace MHSEC_G
|
|||||||
{
|
{
|
||||||
private ViewModel view_model;
|
private ViewModel view_model;
|
||||||
private readonly byte[] dummy_data = new byte[Model.SAVE_FILE_SIZE];
|
private readonly byte[] dummy_data = new byte[Model.SAVE_FILE_SIZE];
|
||||||
private const string Version = "0.1";
|
private const string Version = "0.11";
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -35,10 +35,10 @@ namespace MHSEC_G
|
|||||||
if (buffer.Length != Model.SAVE_FILE_SIZE)
|
if (buffer.Length != Model.SAVE_FILE_SIZE)
|
||||||
{
|
{
|
||||||
System.Windows.Forms.MessageBox.Show(
|
System.Windows.Forms.MessageBox.Show(
|
||||||
"Wrong save file size! Expected: " + Model.SAVE_FILE_SIZE + ".",
|
"Wrong save file size! Expected: " + Model.SAVE_FILE_SIZE + " Got: " + buffer.Length,
|
||||||
"Error",
|
"Error",
|
||||||
MessageBoxButtons.OK,
|
MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Asterisk);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -64,7 +64,7 @@ namespace MHSEC_G
|
|||||||
List<Item> items = view_model.items;
|
List<Item> items = view_model.items;
|
||||||
for (uint i = 0; i < items.Count; i++)
|
for (uint i = 0; i < items.Count; i++)
|
||||||
{
|
{
|
||||||
if (items.ElementAt((int)i).id == 1227)
|
if (items.ElementAt((int)i).offset >= Item.OFFSETA_FIRST_KEY_ITEM)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
items.ElementAt((int)i).count = 986;
|
items.ElementAt((int)i).count = 986;
|
||||||
@ -76,7 +76,7 @@ namespace MHSEC_G
|
|||||||
List<Item> items = view_model.items;
|
List<Item> items = view_model.items;
|
||||||
for (uint i = 0; i < items.Count; i++)
|
for (uint i = 0; i < items.Count; i++)
|
||||||
{
|
{
|
||||||
if (items.ElementAt((int) i).id == 1227)
|
if (items.ElementAt((int)i).offset >= Item.OFFSETA_FIRST_KEY_ITEM)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (items.ElementAt((int)i).count != 0)
|
if (items.ElementAt((int)i).count != 0)
|
||||||
|
@ -17,8 +17,10 @@ namespace MHSEC_G
|
|||||||
|
|
||||||
public Model(byte[] save_file)
|
public Model(byte[] save_file)
|
||||||
{
|
{
|
||||||
if(save_file.Length != SAVE_FILE_SIZE)
|
if (save_file.Length != SAVE_FILE_SIZE)
|
||||||
throw new SystemException("Invalid save file size.");
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_INVALID_FILE_SIZE, "Invalid file size.\nExpected: " + SAVE_FILE_SIZE + " Got: " + save_file.Length);
|
||||||
|
}
|
||||||
_save_file = save_file;
|
_save_file = save_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,21 +35,25 @@ namespace MHSEC_G
|
|||||||
arr[offset] = (byte)(val&0xFF);
|
arr[offset] = (byte)(val&0xFF);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new SystemException("Buffer overflowed - Offset " + offset);
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_BYTE_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static uint byte_to_uint16_le(byte[] arr, uint offset)
|
public static uint byte_to_uint16_le(byte[] arr, uint offset)
|
||||||
{
|
{
|
||||||
if (arr.Length < offset + 2)
|
if (arr.Length < offset + 2)
|
||||||
throw new SystemException("Buffer overflowed - Offset " + offset);
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_READ_UINT16_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
|
}
|
||||||
return byte_to_uint(arr[offset]) | (byte_to_uint(arr[offset + 1]) << 8);
|
return byte_to_uint(arr[offset]) | (byte_to_uint(arr[offset + 1]) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write_uint16_le(byte[] arr, uint offset, uint val)
|
public static void write_uint16_le(byte[] arr, uint offset, uint val)
|
||||||
{
|
{
|
||||||
if (arr.Length < offset + 2)
|
if (arr.Length < offset + 2)
|
||||||
throw new SystemException("Buffer overflowed - Offset " + offset);
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_UINT16_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
|
}
|
||||||
arr[offset] = (byte) (val & 0xFF);
|
arr[offset] = (byte) (val & 0xFF);
|
||||||
arr[offset + 1] = (byte) ((val >> 8) & 0xFF);
|
arr[offset + 1] = (byte) ((val >> 8) & 0xFF);
|
||||||
}
|
}
|
||||||
@ -55,7 +61,9 @@ namespace MHSEC_G
|
|||||||
public static uint byte_to_uint32_le(byte[] arr, uint offset)
|
public static uint byte_to_uint32_le(byte[] arr, uint offset)
|
||||||
{
|
{
|
||||||
if (arr.Length < offset + 4)
|
if (arr.Length < offset + 4)
|
||||||
throw new SystemException("Buffer overflowed - Offset " + offset);
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_READ_UINT32_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
|
}
|
||||||
return byte_to_uint(arr[offset]) | (byte_to_uint(arr[offset + 1]) << 8) |
|
return byte_to_uint(arr[offset]) | (byte_to_uint(arr[offset + 1]) << 8) |
|
||||||
(byte_to_uint(arr[offset + 2]) << 16) | (byte_to_uint(arr[offset + 3]) << 24);
|
(byte_to_uint(arr[offset + 2]) << 16) | (byte_to_uint(arr[offset + 3]) << 24);
|
||||||
}
|
}
|
||||||
@ -63,7 +71,9 @@ namespace MHSEC_G
|
|||||||
public static void write_uint32_le(byte[] arr, uint offset, uint val)
|
public static void write_uint32_le(byte[] arr, uint offset, uint val)
|
||||||
{
|
{
|
||||||
if (arr.Length < offset + 4)
|
if (arr.Length < offset + 4)
|
||||||
throw new SystemException("Buffer overflowed - Offset " + offset);
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_UINT32_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
|
}
|
||||||
arr[offset] = (byte) (val & 0xFF);
|
arr[offset] = (byte) (val & 0xFF);
|
||||||
arr[offset + 1] = (byte) ((val >> 8) & 0xFF);
|
arr[offset + 1] = (byte) ((val >> 8) & 0xFF);
|
||||||
arr[offset + 2] = (byte) ((val >> 16) & 0xFF);
|
arr[offset + 2] = (byte) ((val >> 16) & 0xFF);
|
||||||
@ -95,7 +105,9 @@ namespace MHSEC_G
|
|||||||
public static void write_unicode_string(byte[] arr, uint offset, string str, uint length)
|
public static void write_unicode_string(byte[] arr, uint offset, string str, uint length)
|
||||||
{
|
{
|
||||||
if (length < str.Length || arr.Length < offset + length)
|
if (length < str.Length || arr.Length < offset + length)
|
||||||
throw new SystemException("Unicode string write - potential buffer overflow.");
|
{
|
||||||
|
BugCheck.bug_check(BugCheck.ErrorCode.MODEL_WRITE_UNICODE_OVERFLOW, "Buffer overflowed.\nBound " + arr.Length + " Offset " + offset);
|
||||||
|
}
|
||||||
|
|
||||||
Array.Clear(arr, (int) offset, (int)length*2);
|
Array.Clear(arr, (int) offset, (int)length*2);
|
||||||
for (uint i = 0; i < str.Length; i ++)
|
for (uint i = 0; i < str.Length; i ++)
|
||||||
|
@ -205,12 +205,12 @@ namespace MHSEC_G
|
|||||||
|
|
||||||
public string name
|
public string name
|
||||||
{
|
{
|
||||||
get { return Model.read_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, 10); }
|
get { return Model.read_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, LIMIT_MONSTER_NAME); }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value.Length <= 10 && value.Length > 0)
|
if (value.Length <= 10 && value.Length > 0)
|
||||||
{
|
{
|
||||||
Model.write_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, value, 10);
|
Model.write_unicode_string(_model.save_file, _offset + OFFSETR_MONSTER_NAME, value, LIMIT_MONSTER_NAME);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -8,7 +8,7 @@ using System.Windows;
|
|||||||
// set of attributes. Change these attribute values to modify the information
|
// set of attributes. Change these attribute values to modify the information
|
||||||
// associated with an assembly.
|
// associated with an assembly.
|
||||||
[assembly: AssemblyTitle("MHSEC-G")]
|
[assembly: AssemblyTitle("MHSEC-G")]
|
||||||
[assembly: AssemblyDescription("")]
|
[assembly: AssemblyDescription("Monster Hunter Stories Save Editor")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("MHSEC-G")]
|
[assembly: AssemblyProduct("MHSEC-G")]
|
||||||
@ -51,5 +51,5 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.0")]
|
[assembly: AssemblyVersion("0.1.1.0")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
[assembly: AssemblyFileVersion("0.1.1.0")]
|
||||||
|
42
MHSEC-G/MHSEC-G/Properties/Resources.Designer.cs
generated
42
MHSEC-G/MHSEC-G/Properties/Resources.Designer.cs
generated
@ -8,10 +8,10 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace MHSEC_G.Properties
|
namespace MHSEC_G.Properties {
|
||||||
{
|
using System;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -22,48 +22,40 @@ namespace MHSEC_G.Properties
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class Resources
|
internal class Resources {
|
||||||
{
|
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal Resources()
|
internal Resources() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the cached ResourceManager instance used by this class.
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Resources.ResourceManager ResourceManager
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
{
|
get {
|
||||||
get
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
{
|
|
||||||
if ((resourceMan == null))
|
|
||||||
{
|
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MHSEC_G.Properties.Resources", typeof(Resources).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MHSEC_G.Properties.Resources", typeof(Resources).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Overrides the current thread's CurrentUICulture property for all
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
/// resource lookups using this strongly typed resource class.
|
/// resource lookups using this strongly typed resource class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
internal static global::System.Globalization.CultureInfo Culture
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return resourceCulture;
|
return resourceCulture;
|
||||||
}
|
}
|
||||||
set
|
set {
|
||||||
{
|
|
||||||
resourceCulture = value;
|
resourceCulture = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
MHSEC-G/MHSEC-G/Properties/Settings.Designer.cs
generated
22
MHSEC-G/MHSEC-G/Properties/Settings.Designer.cs
generated
@ -8,21 +8,17 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace MHSEC_G.Properties
|
namespace MHSEC_G.Properties {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||||
{
|
|
||||||
|
|
||||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||||
|
|
||||||
public static Settings Default
|
public static Settings Default {
|
||||||
{
|
get {
|
||||||
get
|
|
||||||
{
|
|
||||||
return defaultInstance;
|
return defaultInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,10 @@ namespace MHSEC_G
|
|||||||
|
|
||||||
public ViewModel(byte[] save)
|
public ViewModel(byte[] save)
|
||||||
{
|
{
|
||||||
if (save == null || save.Length != Model.SAVE_FILE_SIZE)
|
if (save == null)
|
||||||
{
|
{
|
||||||
throw new SystemException("Invalid save file size.");
|
BugCheck.bug_check(BugCheck.ErrorCode.VIEWMODEL_NULL_SAVE, "The save file reference is NULL.");
|
||||||
}
|
}
|
||||||
|
|
||||||
_model = new Model(save);
|
_model = new Model(save);
|
||||||
_character = new Character(_model);
|
_character = new Character(_model);
|
||||||
_items = Item.read_all_items(_model);
|
_items = Item.read_all_items(_model);
|
||||||
|
3
MHSEC-G/MHSEC-G/app.config
Normal file
3
MHSEC-G/MHSEC-G/app.config
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user