mirror of
https://github.com/kwsch/NHSE.git
synced 2026-03-26 11:34:44 -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:
parent
e7dd2c131b
commit
2ed928e961
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user