mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-27 04:19:36 -05:00
Fix loading player house and room dumps (#552)
* Fix loading player house and room dumps * Check converted house/room data lengths rather instead of the imported dunmp's * Fix downgrading player house format
This commit is contained in:
@@ -151,7 +151,7 @@ public static bool LoadHouse(MainSaveOffsets offsets, IReadOnlyList<Player> play
|
||||
var path = ofd.FileName;
|
||||
var expectLength = offsets.PlayerHouseSize;
|
||||
var fi = new FileInfo(path);
|
||||
if (!VillagerHouseConverter.IsCompatible((int)fi.Length, expectLength))
|
||||
if (!PlayerHouseConverter.IsCompatible((int)fi.Length, expectLength))
|
||||
{
|
||||
WinFormsUtil.Error(string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength), path);
|
||||
return false;
|
||||
@@ -159,7 +159,7 @@ public static bool LoadHouse(MainSaveOffsets offsets, IReadOnlyList<Player> play
|
||||
|
||||
var data = File.ReadAllBytes(ofd.FileName);
|
||||
data = PlayerHouseConverter.GetCompatible(data, expectLength);
|
||||
if (fi.Length != expectLength)
|
||||
if (data.Length != expectLength)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength), path);
|
||||
return false;
|
||||
@@ -188,7 +188,7 @@ public static void DumpRoom(IPlayerRoom room, int index)
|
||||
File.WriteAllBytes(sfd.FileName, data);
|
||||
}
|
||||
|
||||
public static bool LoadRoom(MainSaveOffsets offsets, IPlayerRoom room, int index)
|
||||
public static bool LoadRoom(MainSaveOffsets offsets, ref IPlayerRoom room, int index)
|
||||
{
|
||||
using var ofd = new OpenFileDialog
|
||||
{
|
||||
@@ -211,7 +211,7 @@ public static bool LoadRoom(MainSaveOffsets offsets, IPlayerRoom room, int index
|
||||
|
||||
var data = File.ReadAllBytes(ofd.FileName);
|
||||
data = PlayerRoomConverter.GetCompatible(data, offsets.PlayerRoomSize);
|
||||
if (fi.Length != expectLength)
|
||||
if (data.Length != expectLength)
|
||||
{
|
||||
WinFormsUtil.Error(MessageStrings.MsgCanceling, string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expectLength), path);
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user