From b203cd782a8211b135b9d8d36aa31417339fb083 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 30 Apr 2020 23:42:34 -0700 Subject: [PATCH] Fix bbs structlayout, Add getter for bulletin --- NHSE.Core/Save/Files/MainSave.cs | 4 +++- NHSE.Core/Structures/Misc/GSaveBBS.cs | 28 ++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/NHSE.Core/Save/Files/MainSave.cs b/NHSE.Core/Save/Files/MainSave.cs index 0be9eaa..817c9e1 100644 --- a/NHSE.Core/Save/Files/MainSave.cs +++ b/NHSE.Core/Save/Files/MainSave.cs @@ -210,5 +210,7 @@ public uint PlazaY } public GSaveTime LastSaved => Data.Slice(Offsets.LastSavedTime, GSaveTime.SIZE).ToStructure(); + + public GSaveBulletinBoard Bulletin => Data.Slice(Offsets.BulletinBoard, GSaveBulletinBoard.SIZE).ToStructure(); } -} \ No newline at end of file +} diff --git a/NHSE.Core/Structures/Misc/GSaveBBS.cs b/NHSE.Core/Structures/Misc/GSaveBBS.cs index 33e3adf..1be27c0 100644 --- a/NHSE.Core/Structures/Misc/GSaveBBS.cs +++ b/NHSE.Core/Structures/Misc/GSaveBBS.cs @@ -5,7 +5,7 @@ #pragma warning disable CS8618, CA1815 namespace NHSE.Core { - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = SIZE, CharSet = CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct GSaveBulletinBoard { public const int SIZE = 0xe0ae8; @@ -14,8 +14,9 @@ public struct GSaveBulletinBoard public bool _3347e149; // @0x4 size 0x1, align 1 public BulletinBoardStock Stock; // @0x8 size 0xe0ad8, align 8 public uint LatestUniqueId; // @0xe0ae0 size 0x4, align 4 - }; + } + [StructLayout(LayoutKind.Sequential, Pack = 8)] public struct BulletinBoardStock { public const int SIZE = 0xe0ad8; @@ -28,17 +29,17 @@ public struct BulletinBoardStock public int[] IndexTable; // @0xe0a60 size 0x4, align 4 } - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = SIZE, CharSet = CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, Pack = 8, CharSet = CharSet.Unicode)] public struct GSaveBBS { public const int SIZE = 0x77d0; public GSaveDate Date; // @0x0 size 0x4, align 2 - [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 240/2)] + [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 240)] public string Body; // @0x4 size 0x1e0, align 2 - [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48/2)] + [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 48)] public string Footer; // @0x1e4 size 0x60, align 2 public Handwriting HandWrite; // @0x244 size 0x7538, align 4 @@ -50,7 +51,7 @@ public struct GSaveBBS public uint UniqueId; // @0x77c8 size 0x4, align 4 } - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = SIZE)] + [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct GSaveDate { public const int SIZE = 4; @@ -60,23 +61,24 @@ public struct GSaveDate public byte Day; } - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = SIZE)] + [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct Handwriting { public const int SIZE = 0x7538; public const int InkCount = 30_000; + public const int PaletteCount = 4; [field: MarshalAs(UnmanagedType.ByValArray, SizeConst = InkCount)] public byte[] Image; - [field: MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)] + [field: MarshalAs(UnmanagedType.ByValArray, SizeConst = PaletteCount)] public byte[] Palette; public uint VerticesNum; } - [StructLayout(LayoutKind.Sequential, Pack = 1, Size = SIZE)] + [StructLayout(LayoutKind.Sequential, Pack = 4)] public struct GSavePlayerId { public const int SIZE = 0x38; @@ -84,27 +86,27 @@ public struct GSavePlayerId public GSavePlayerBaseId BaseId; } - [StructLayout(LayoutKind.Sequential, Pack = 4, Size = SIZE, CharSet = CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)] public struct GSaveLandId { public const int SIZE = 0x1C; public uint Id; - [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x14 / 2)] + [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)] public string Name; public byte IslandRubyType; } - [StructLayout(LayoutKind.Sequential, Pack = 4, Size = SIZE, CharSet = CharSet.Unicode)] + [StructLayout(LayoutKind.Sequential, Pack = 4, CharSet = CharSet.Unicode)] public struct GSavePlayerBaseId { public const int SIZE = 0x1C; public uint Id; - [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 0x14 / 2)] + [field: MarshalAs(UnmanagedType.ByValTStr, SizeConst = 10)] public string Name; public int Gender; // enum