diff --git a/NHSE.Core/Structures/Villager/PlayerHouse2.cs b/NHSE.Core/Structures/Villager/PlayerHouse2.cs index 17df7e6..093bccb 100644 --- a/NHSE.Core/Structures/Villager/PlayerHouse2.cs +++ b/NHSE.Core/Structures/Villager/PlayerHouse2.cs @@ -58,7 +58,7 @@ public PlayerHouse1 Downgrade() var data = new byte[PlayerHouse1.SIZE]; Data.Slice(0x0, 0x120).CopyTo(data, 0); // HouseLevel -> EventFlag for (int i = 0; i < MaxRoom; i++) - ((PlayerRoom2)GetRoom(i)).Downgrade().Data.CopyTo(data, 0x120 + i * PlayerRoom2.SIZE); // RoomList + ((PlayerRoom2)GetRoom(i)).Downgrade().Data.CopyTo(data, 0x120 + i * PlayerRoom1.SIZE); // RoomList Data.Slice(0x289F8, 0x30).CopyTo(data, 0x263D0); // PlayerList -> Cockroach return new PlayerHouse1(data); } diff --git a/NHSE.Core/Structures/Villager/PlayerRoom2.cs b/NHSE.Core/Structures/Villager/PlayerRoom2.cs index 255543b..d1c6c82 100644 --- a/NHSE.Core/Structures/Villager/PlayerRoom2.cs +++ b/NHSE.Core/Structures/Villager/PlayerRoom2.cs @@ -54,7 +54,7 @@ public s_e13a81f4 _cfb139b9 public PlayerRoom1 Downgrade() { var result = new byte[PlayerRoom1.SIZE]; - Data.CopyTo(result, 0); + Array.Copy(Data, result, PlayerRoom1.SIZE); return new PlayerRoom1(result); } } diff --git a/NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs b/NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs index 7627bd7..9ea93f3 100644 --- a/NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs +++ b/NHSE.WinForms/Subforms/Map/MiscDumpHelper.cs @@ -151,7 +151,7 @@ public static bool LoadHouse(MainSaveOffsets offsets, IReadOnlyList 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 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; diff --git a/NHSE.WinForms/Subforms/Map/PlayerHouseEditor.cs b/NHSE.WinForms/Subforms/Map/PlayerHouseEditor.cs index 0606174..8025989 100644 --- a/NHSE.WinForms/Subforms/Map/PlayerHouseEditor.cs +++ b/NHSE.WinForms/Subforms/Map/PlayerHouseEditor.cs @@ -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);