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:
hp3721
2021-11-20 10:22:11 -06:00
committed by GitHub
parent e7dd2c131b
commit 2ed928e961
4 changed files with 7 additions and 7 deletions

View File

@@ -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;

View File

@@ -302,7 +302,7 @@ private void DeleteTile(Item tile, int x, int y)
private void B_LoadRoom_Click(object sender, EventArgs e)
{
var room = Manager.Room;
MiscDumpHelper.LoadRoom(SAV.Offsets, room, RoomIndex);
MiscDumpHelper.LoadRoom(SAV.Offsets, ref room, RoomIndex);
var house = Houses[Index];
house.SetRoom(RoomIndex, room);