From 83169b87383a070278e0d7773b8f803b748360b9 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 24 Dec 2020 23:53:40 -0800 Subject: [PATCH] Bump language version to c#9 --- NHSE.Core/Encryption/Aes128Ctr.cs | 2 +- NHSE.Core/Hashing/FileHashRevision.cs | 420 +++++++++--------- NHSE.Core/NHSE.Core.csproj | 2 +- NHSE.Core/Save/Files/MainSave.cs | 2 +- NHSE.Core/Save/Files/Personal.cs | 4 +- NHSE.Core/Save/Meta/RevisionChecker.cs | 46 +- NHSE.Core/Strings/GameStrings.cs | 2 +- NHSE.Core/Structures/GameLists.cs | 6 +- NHSE.Core/Structures/Item/Item.cs | 2 +- NHSE.Core/Structures/Item/ItemInfo.cs | 2 +- NHSE.Core/Structures/Item/ItemKind.cs | 4 +- NHSE.Core/Structures/Item/ItemSize.cs | 2 +- NHSE.Core/Structures/Item/VillagerItem.cs | 2 +- NHSE.Core/Structures/Map/OutsideAcre.cs | 2 +- NHSE.Core/Structures/Villager/PlayerHouse.cs | 2 +- NHSE.Core/Structures/Villager/Villager1.cs | 2 +- NHSE.Core/Structures/Villager/Villager2.cs | 2 +- .../Structures/Villager/VillagerConverter.cs | 12 +- NHSE.Core/Util/ComboItem.cs | 2 +- NHSE.Core/Util/RandUtil.cs | 2 +- NHSE.Core/Util/ResourceUtil.cs | 6 +- NHSE.Injection/NHSE.Injection.csproj | 4 +- NHSE.Injection/SysBot/SysBot.cs | 4 +- NHSE.Injection/SysBot/USBBot.cs | 2 +- NHSE.Parsing/BCSV/BCSV.cs | 2 +- NHSE.Parsing/BCSV/BCSVEnumDictionary.cs | 2 +- NHSE.Parsing/GameBCSVDumper.cs | 2 +- NHSE.Parsing/GameMSBTDumper.cs | 2 +- NHSE.Parsing/MSBT/BinaryReaderX.cs | 2 +- NHSE.Parsing/MSBT/LBL1.cs | 4 +- NHSE.Parsing/MSBT/MSBT.cs | 4 +- NHSE.Parsing/MSBT/MSBTTextString.cs | 2 +- NHSE.Parsing/MSBT/TXT2.cs | 2 +- NHSE.Parsing/NHSE.Parsing.csproj | 2 +- NHSE.Parsing/ParseConverter.cs | 6 +- NHSE.Sprites/Field/TerrainSprite.cs | 3 +- NHSE.Sprites/Item/ItemSprite.cs | 5 +- NHSE.Sprites/NHSE.Sprites.csproj | 2 +- NHSE.WinForms/Controls/ItemGrid.cs | 2 +- NHSE.WinForms/Controls/ItemGridEditor.cs | 8 +- NHSE.WinForms/NHSE.WinForms.csproj | 2 +- NHSE.WinForms/Subforms/Map/FieldItemEditor.cs | 2 +- .../Subforms/Program/ImageFetcher.cs | 2 +- .../Subforms/SysBot/SysBotController.cs | 2 +- .../Subforms/SysBot/USBBotController.cs | 2 +- NHSE.WinForms/Util/WinFormsTranslator.cs | 6 +- 46 files changed, 297 insertions(+), 305 deletions(-) diff --git a/NHSE.Core/Encryption/Aes128Ctr.cs b/NHSE.Core/Encryption/Aes128Ctr.cs index ca48c9a3..980af34c 100644 --- a/NHSE.Core/Encryption/Aes128Ctr.cs +++ b/NHSE.Core/Encryption/Aes128Ctr.cs @@ -77,7 +77,7 @@ public sealed class CounterModeCryptoTransform : ICryptoTransform { private readonly byte[] _counter; private readonly ICryptoTransform _counterEncryptor; - private readonly Queue _xorMask = new Queue(); + private readonly Queue _xorMask = new(); private readonly SymmetricAlgorithm _symmetricAlgorithm; public CounterModeCryptoTransform(SymmetricAlgorithm symmetricAlgorithm, byte[] key, byte[] counter) diff --git a/NHSE.Core/Hashing/FileHashRevision.cs b/NHSE.Core/Hashing/FileHashRevision.cs index 19069bb3..d1ce7c5b 100644 --- a/NHSE.Core/Hashing/FileHashRevision.cs +++ b/NHSE.Core/Hashing/FileHashRevision.cs @@ -13,46 +13,46 @@ public static class FileHashRevision private const int PHOTO_STUDIO_ISLAND_SIZE = 0x263B4; private const int PROFILE_SIZE = 0x69508; - public static readonly FileHashInfo REV_100 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_100 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", MAIN_SAVE_SIZE, new[] + new("main.dat", MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000108, 0x1D6D4C), - new FileHashRegion(0x1D6E58, 0x323384), - new FileHashRegion(0x4FA2E8, 0x035AC4), - new FileHashRegion(0x52FDB0, 0x03607C), - new FileHashRegion(0x565F38, 0x035AC4), - new FileHashRegion(0x59BA00, 0x03607C), - new FileHashRegion(0x5D1B88, 0x035AC4), - new FileHashRegion(0x607650, 0x03607C), - new FileHashRegion(0x63D7D8, 0x035AC4), - new FileHashRegion(0x6732A0, 0x03607C), - new FileHashRegion(0x6A9428, 0x035AC4), - new FileHashRegion(0x6DEEF0, 0x03607C), - new FileHashRegion(0x715078, 0x035AC4), - new FileHashRegion(0x74AB40, 0x03607C), - new FileHashRegion(0x780CC8, 0x035AC4), - new FileHashRegion(0x7B6790, 0x03607C), - new FileHashRegion(0x7EC918, 0x035AC4), - new FileHashRegion(0x8223E0, 0x03607C), - new FileHashRegion(0x858460, 0x2684D4) + new(0x000108, 0x1D6D4C), + new(0x1D6E58, 0x323384), + new(0x4FA2E8, 0x035AC4), + new(0x52FDB0, 0x03607C), + new(0x565F38, 0x035AC4), + new(0x59BA00, 0x03607C), + new(0x5D1B88, 0x035AC4), + new(0x607650, 0x03607C), + new(0x63D7D8, 0x035AC4), + new(0x6732A0, 0x03607C), + new(0x6A9428, 0x035AC4), + new(0x6DEEF0, 0x03607C), + new(0x715078, 0x035AC4), + new(0x74AB40, 0x03607C), + new(0x780CC8, 0x035AC4), + new(0x7B6790, 0x03607C), + new(0x7EC918, 0x035AC4), + new(0x8223E0, 0x03607C), + new(0x858460, 0x2684D4) }), - new FileHashDetails("personal.dat", PERSONAL_SAVE_SIZE, new[] + new("personal.dat", PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00108, 0x35AC4), - new FileHashRegion(0x35BD0, 0x3607C) + new(0x00108, 0x35AC4), + new(0x35BD0, 0x3607C) }), - new FileHashDetails("postbox.dat", POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4447C) + new(0x000100, 0xB4447C) }), - new FileHashDetails("photo_studio_island.dat", PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x262B0) + new(0x000100, 0x262B0) }), - new FileHashDetails("profile.dat", PROFILE_SIZE, new[] + new("profile.dat", PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x69404) + new(0x000100, 0x69404) }), }); @@ -66,46 +66,46 @@ public static class FileHashRevision private const int REV_110_PHOTO_STUDIO_ISLAND_SIZE = 0x263C0; private const int REV_110_PROFILE_SIZE = 0x69560; - public static readonly FileHashInfo REV_110 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_110 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_110_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_110_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1D6D5C), - new FileHashRegion(0x1D6E70, 0x323C0C), - new FileHashRegion(0x4FAB90, 0x035AFC), - new FileHashRegion(0x530690, 0x0362BC), - new FileHashRegion(0x566A60, 0x035AFC), - new FileHashRegion(0x59C560, 0x0362BC), - new FileHashRegion(0x5D2930, 0x035AFC), - new FileHashRegion(0x608430, 0x0362BC), - new FileHashRegion(0x63E800, 0x035AFC), - new FileHashRegion(0x674300, 0x0362BC), - new FileHashRegion(0x6AA6D0, 0x035AFC), - new FileHashRegion(0x6E01D0, 0x0362BC), - new FileHashRegion(0x7165A0, 0x035AFC), - new FileHashRegion(0x74C0A0, 0x0362BC), - new FileHashRegion(0x782470, 0x035AFC), - new FileHashRegion(0x7B7F70, 0x0362BC), - new FileHashRegion(0x7EE340, 0x035AFC), - new FileHashRegion(0x823E40, 0x0362BC), - new FileHashRegion(0x85A100, 0x26899C) + new(0x000110, 0x1D6D5C), + new(0x1D6E70, 0x323C0C), + new(0x4FAB90, 0x035AFC), + new(0x530690, 0x0362BC), + new(0x566A60, 0x035AFC), + new(0x59C560, 0x0362BC), + new(0x5D2930, 0x035AFC), + new(0x608430, 0x0362BC), + new(0x63E800, 0x035AFC), + new(0x674300, 0x0362BC), + new(0x6AA6D0, 0x035AFC), + new(0x6E01D0, 0x0362BC), + new(0x7165A0, 0x035AFC), + new(0x74C0A0, 0x0362BC), + new(0x782470, 0x035AFC), + new(0x7B7F70, 0x0362BC), + new(0x7EE340, 0x035AFC), + new(0x823E40, 0x0362BC), + new(0x85A100, 0x26899C) }), - new FileHashDetails("personal.dat", REV_110_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_110_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x35AFC), - new FileHashRegion(0x35C10, 0x362BC) + new(0x00110, 0x35AFC), + new(0x35C10, 0x362BC) }), - new FileHashDetails("postbox.dat", REV_110_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_110_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_110_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_110_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x262BC) + new(0x000100, 0x262BC) }), - new FileHashDetails("profile.dat", REV_110_PROFILE_SIZE, new[] + new("profile.dat", REV_110_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); @@ -119,46 +119,46 @@ public static class FileHashRevision private const int REV_120_PHOTO_STUDIO_ISLAND_SIZE = 0x2C9C0; private const int REV_120_PROFILE_SIZE = REV_110_PROFILE_SIZE; - public static readonly FileHashInfo REV_120 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_120 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_120_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_120_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1D6D5C), - new FileHashRegion(0x1D6E70, 0x323EBC), - new FileHashRegion(0x4FAE40, 0x035D2C), - new FileHashRegion(0x530B70, 0x03787C), - new FileHashRegion(0x568500, 0x035D2C), - new FileHashRegion(0x59E230, 0x03787C), - new FileHashRegion(0x5D5BC0, 0x035D2C), - new FileHashRegion(0x60B8F0, 0x03787C), - new FileHashRegion(0x643280, 0x035D2C), - new FileHashRegion(0x678FB0, 0x03787C), - new FileHashRegion(0x6B0940, 0x035D2C), - new FileHashRegion(0x6E6670, 0x03787C), - new FileHashRegion(0x71E000, 0x035D2C), - new FileHashRegion(0x753D30, 0x03787C), - new FileHashRegion(0x78B6C0, 0x035D2C), - new FileHashRegion(0x7C13F0, 0x03787C), - new FileHashRegion(0x7F8D80, 0x035D2C), - new FileHashRegion(0x82EAB0, 0x03787C), - new FileHashRegion(0x866330, 0x26899C) + new(0x000110, 0x1D6D5C), + new(0x1D6E70, 0x323EBC), + new(0x4FAE40, 0x035D2C), + new(0x530B70, 0x03787C), + new(0x568500, 0x035D2C), + new(0x59E230, 0x03787C), + new(0x5D5BC0, 0x035D2C), + new(0x60B8F0, 0x03787C), + new(0x643280, 0x035D2C), + new(0x678FB0, 0x03787C), + new(0x6B0940, 0x035D2C), + new(0x6E6670, 0x03787C), + new(0x71E000, 0x035D2C), + new(0x753D30, 0x03787C), + new(0x78B6C0, 0x035D2C), + new(0x7C13F0, 0x03787C), + new(0x7F8D80, 0x035D2C), + new(0x82EAB0, 0x03787C), + new(0x866330, 0x26899C) }), - new FileHashDetails("personal.dat", REV_120_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_120_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x35D2C), - new FileHashRegion(0x35E40, 0x3787C) + new(0x00110, 0x35D2C), + new(0x35E40, 0x3787C) }), - new FileHashDetails("postbox.dat", REV_120_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_120_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_120_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_120_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x2C8BC) + new(0x000100, 0x2C8BC) }), - new FileHashDetails("profile.dat", REV_120_PROFILE_SIZE, new[] + new("profile.dat", REV_120_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); @@ -172,46 +172,46 @@ public static class FileHashRevision private const int REV_130_PHOTO_STUDIO_ISLAND_SIZE = REV_120_PHOTO_STUDIO_ISLAND_SIZE; private const int REV_130_PROFILE_SIZE = REV_110_PROFILE_SIZE; - public static readonly FileHashInfo REV_130 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_130 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_130_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_130_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1D6D5C), - new FileHashRegion(0x1D6E70, 0x323EEC), - new FileHashRegion(0x4FAE70, 0x035D2C), - new FileHashRegion(0x530BA0, 0x03788C), - new FileHashRegion(0x568540, 0x035D2C), - new FileHashRegion(0x59E270, 0x03788C), - new FileHashRegion(0x5D5c10, 0x035D2C), - new FileHashRegion(0x60B940, 0x03788C), - new FileHashRegion(0x6432E0, 0x035D2C), - new FileHashRegion(0x679010, 0x03788C), - new FileHashRegion(0x6B09B0, 0x035D2C), - new FileHashRegion(0x6E66E0, 0x03788C), - new FileHashRegion(0x71E080, 0x035D2C), - new FileHashRegion(0x753DB0, 0x03788C), - new FileHashRegion(0x78B750, 0x035D2C), - new FileHashRegion(0x7C1480, 0x03788C), - new FileHashRegion(0x7F8E20, 0x035D2C), - new FileHashRegion(0x82EB50, 0x03788C), - new FileHashRegion(0x8663E0, 0x26899C) + new(0x000110, 0x1D6D5C), + new(0x1D6E70, 0x323EEC), + new(0x4FAE70, 0x035D2C), + new(0x530BA0, 0x03788C), + new(0x568540, 0x035D2C), + new(0x59E270, 0x03788C), + new(0x5D5c10, 0x035D2C), + new(0x60B940, 0x03788C), + new(0x6432E0, 0x035D2C), + new(0x679010, 0x03788C), + new(0x6B09B0, 0x035D2C), + new(0x6E66E0, 0x03788C), + new(0x71E080, 0x035D2C), + new(0x753DB0, 0x03788C), + new(0x78B750, 0x035D2C), + new(0x7C1480, 0x03788C), + new(0x7F8E20, 0x035D2C), + new(0x82EB50, 0x03788C), + new(0x8663E0, 0x26899C) }), - new FileHashDetails("personal.dat", REV_130_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_130_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x35D2C), - new FileHashRegion(0x35E40, 0x3788C) + new(0x00110, 0x35D2C), + new(0x35E40, 0x3788C) }), - new FileHashDetails("postbox.dat", REV_130_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_130_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_130_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_130_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x2C8BC) + new(0x000100, 0x2C8BC) }), - new FileHashDetails("profile.dat", REV_130_PROFILE_SIZE, new[] + new("profile.dat", REV_130_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); @@ -225,46 +225,46 @@ public static class FileHashRevision private const int REV_140_PHOTO_STUDIO_ISLAND_SIZE = REV_120_PHOTO_STUDIO_ISLAND_SIZE; private const int REV_140_PROFILE_SIZE = REV_110_PROFILE_SIZE; - public static readonly FileHashInfo REV_140 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_140 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_140_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_140_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1d6d5c), - new FileHashRegion(0x1d6e70, 0x323f2c), - new FileHashRegion(0x4faeb0, 0x035d2c), - new FileHashRegion(0x530be0, 0x03e5dc), - new FileHashRegion(0x56f2d0, 0x035d2c), - new FileHashRegion(0x5a5000, 0x03e5dc), - new FileHashRegion(0x5e36f0, 0x035d2c), - new FileHashRegion(0x619420, 0x03e5dc), - new FileHashRegion(0x657b10, 0x035d2c), - new FileHashRegion(0x68d840, 0x03e5dc), - new FileHashRegion(0x6cbf30, 0x035d2c), - new FileHashRegion(0x701c60, 0x03e5dc), - new FileHashRegion(0x740350, 0x035d2c), - new FileHashRegion(0x776080, 0x03e5dc), - new FileHashRegion(0x7b4770, 0x035d2c), - new FileHashRegion(0x7ea4a0, 0x03e5dc), - new FileHashRegion(0x828b90, 0x035d2c), - new FileHashRegion(0x85e8c0, 0x03e5dc), - new FileHashRegion(0x89cea0, 0x2688ec) + new(0x000110, 0x1d6d5c), + new(0x1d6e70, 0x323f2c), + new(0x4faeb0, 0x035d2c), + new(0x530be0, 0x03e5dc), + new(0x56f2d0, 0x035d2c), + new(0x5a5000, 0x03e5dc), + new(0x5e36f0, 0x035d2c), + new(0x619420, 0x03e5dc), + new(0x657b10, 0x035d2c), + new(0x68d840, 0x03e5dc), + new(0x6cbf30, 0x035d2c), + new(0x701c60, 0x03e5dc), + new(0x740350, 0x035d2c), + new(0x776080, 0x03e5dc), + new(0x7b4770, 0x035d2c), + new(0x7ea4a0, 0x03e5dc), + new(0x828b90, 0x035d2c), + new(0x85e8c0, 0x03e5dc), + new(0x89cea0, 0x2688ec) }), - new FileHashDetails("personal.dat", REV_140_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_140_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x35D2C), - new FileHashRegion(0x35E40, 0x3E5DC) + new(0x00110, 0x35D2C), + new(0x35E40, 0x3E5DC) }), - new FileHashDetails("postbox.dat", REV_140_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_140_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_140_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_140_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x2C8BC) + new(0x000100, 0x2C8BC) }), - new FileHashDetails("profile.dat", REV_140_PROFILE_SIZE, new[] + new("profile.dat", REV_140_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); @@ -278,46 +278,46 @@ public static class FileHashRevision private const int REV_150_PHOTO_STUDIO_ISLAND_SIZE = REV_120_PHOTO_STUDIO_ISLAND_SIZE; private const int REV_150_PROFILE_SIZE = REV_110_PROFILE_SIZE; - public static readonly FileHashInfo REV_150 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_150 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_150_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_150_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1e215c), - new FileHashRegion(0x1e2270, 0x323f6c), - new FileHashRegion(0x5062f0, 0x03693c), - new FileHashRegion(0x53cc30, 0x03f93c), - new FileHashRegion(0x57c680, 0x03693c), - new FileHashRegion(0x5b2fc0, 0x03f93c), - new FileHashRegion(0x5f2a10, 0x03693c), - new FileHashRegion(0x629350, 0x03f93c), - new FileHashRegion(0x668da0, 0x03693c), - new FileHashRegion(0x69f6e0, 0x03f93c), - new FileHashRegion(0x6df130, 0x03693c), - new FileHashRegion(0x715a70, 0x03f93c), - new FileHashRegion(0x7554c0, 0x03693c), - new FileHashRegion(0x78be00, 0x03f93c), - new FileHashRegion(0x7cb850, 0x03693c), - new FileHashRegion(0x802190, 0x03f93c), - new FileHashRegion(0x841be0, 0x03693c), - new FileHashRegion(0x878520, 0x03f93c), - new FileHashRegion(0x8b7e60, 0x2688ec) + new(0x000110, 0x1e215c), + new(0x1e2270, 0x323f6c), + new(0x5062f0, 0x03693c), + new(0x53cc30, 0x03f93c), + new(0x57c680, 0x03693c), + new(0x5b2fc0, 0x03f93c), + new(0x5f2a10, 0x03693c), + new(0x629350, 0x03f93c), + new(0x668da0, 0x03693c), + new(0x69f6e0, 0x03f93c), + new(0x6df130, 0x03693c), + new(0x715a70, 0x03f93c), + new(0x7554c0, 0x03693c), + new(0x78be00, 0x03f93c), + new(0x7cb850, 0x03693c), + new(0x802190, 0x03f93c), + new(0x841be0, 0x03693c), + new(0x878520, 0x03f93c), + new(0x8b7e60, 0x2688ec) }), - new FileHashDetails("personal.dat", REV_150_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_150_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x3693c), - new FileHashRegion(0x36a50, 0x3f93c) + new(0x00110, 0x3693c), + new(0x36a50, 0x3f93c) }), - new FileHashDetails("postbox.dat", REV_150_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_150_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_150_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_150_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x2C8BC) + new(0x000100, 0x2C8BC) }), - new FileHashDetails("profile.dat", REV_150_PROFILE_SIZE, new[] + new("profile.dat", REV_150_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); @@ -331,46 +331,46 @@ public static class FileHashRevision private const int REV_160_PHOTO_STUDIO_ISLAND_SIZE = REV_120_PHOTO_STUDIO_ISLAND_SIZE; private const int REV_160_PROFILE_SIZE = REV_110_PROFILE_SIZE; - public static readonly FileHashInfo REV_160 = new FileHashInfo(new[] + public static readonly FileHashInfo REV_160 = new(new FileHashDetails[] { - new FileHashDetails("main.dat", REV_160_MAIN_SAVE_SIZE, new[] + new("main.dat", REV_160_MAIN_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000110, 0x1e215c), - new FileHashRegion(0x1e2270, 0x32403c), - new FileHashRegion(0x5063c0, 0x03693c), - new FileHashRegion(0x53cd00, 0x04029c), - new FileHashRegion(0x57d0b0, 0x03693c), - new FileHashRegion(0x5b39f0, 0x04029c), - new FileHashRegion(0x5f3da0, 0x03693c), - new FileHashRegion(0x62a6e0, 0x04029c), - new FileHashRegion(0x66aa90, 0x03693c), - new FileHashRegion(0x6a13d0, 0x04029c), - new FileHashRegion(0x6e1780, 0x03693c), - new FileHashRegion(0x7180c0, 0x04029c), - new FileHashRegion(0x758470, 0x03693c), - new FileHashRegion(0x78edb0, 0x04029c), - new FileHashRegion(0x7cf160, 0x03693c), - new FileHashRegion(0x805aa0, 0x04029c), - new FileHashRegion(0x845e50, 0x03693c), - new FileHashRegion(0x87c790, 0x04029c), - new FileHashRegion(0x8bca30, 0x268eac) + new(0x000110, 0x1e215c), + new(0x1e2270, 0x32403c), + new(0x5063c0, 0x03693c), + new(0x53cd00, 0x04029c), + new(0x57d0b0, 0x03693c), + new(0x5b39f0, 0x04029c), + new(0x5f3da0, 0x03693c), + new(0x62a6e0, 0x04029c), + new(0x66aa90, 0x03693c), + new(0x6a13d0, 0x04029c), + new(0x6e1780, 0x03693c), + new(0x7180c0, 0x04029c), + new(0x758470, 0x03693c), + new(0x78edb0, 0x04029c), + new(0x7cf160, 0x03693c), + new(0x805aa0, 0x04029c), + new(0x845e50, 0x03693c), + new(0x87c790, 0x04029c), + new(0x8bca30, 0x268eac) }), - new FileHashDetails("personal.dat", REV_160_PERSONAL_SAVE_SIZE, new[] + new("personal.dat", REV_160_PERSONAL_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x00110, 0x3693c), - new FileHashRegion(0x36a50, 0x4029c) + new(0x00110, 0x3693c), + new(0x36a50, 0x4029c) }), - new FileHashDetails("postbox.dat", REV_160_POSTBOX_SAVE_SIZE, new[] + new("postbox.dat", REV_160_POSTBOX_SAVE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0xB4448C) + new(0x000100, 0xB4448C) }), - new FileHashDetails("photo_studio_island.dat", REV_160_PHOTO_STUDIO_ISLAND_SIZE, new[] + new("photo_studio_island.dat", REV_160_PHOTO_STUDIO_ISLAND_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x2C8BC) + new(0x000100, 0x2C8BC) }), - new FileHashDetails("profile.dat", REV_160_PROFILE_SIZE, new[] + new("profile.dat", REV_160_PROFILE_SIZE, new FileHashRegion[] { - new FileHashRegion(0x000100, 0x6945C) + new(0x000100, 0x6945C) }), }); diff --git a/NHSE.Core/NHSE.Core.csproj b/NHSE.Core/NHSE.Core.csproj index 4d49eb50..6977bf11 100644 --- a/NHSE.Core/NHSE.Core.csproj +++ b/NHSE.Core/NHSE.Core.csproj @@ -2,7 +2,7 @@ net46;netstandard2.0 - 8 + 9 enable diff --git a/NHSE.Core/Save/Files/MainSave.cs b/NHSE.Core/Save/Files/MainSave.cs index 9e83f70e..702257df 100644 --- a/NHSE.Core/Save/Files/MainSave.cs +++ b/NHSE.Core/Save/Files/MainSave.cs @@ -178,7 +178,7 @@ public TurnipStonk Turnips public Museum Museum { - get => new Museum(Data.Slice(Offsets.Museum, Museum.SIZE)); + get => new(Data.Slice(Offsets.Museum, Museum.SIZE)); set => value.Data.CopyTo(Data, Offsets.Museum); } diff --git a/NHSE.Core/Save/Files/Personal.cs b/NHSE.Core/Save/Files/Personal.cs index 027a1341..008fbe2f 100644 --- a/NHSE.Core/Save/Files/Personal.cs +++ b/NHSE.Core/Save/Files/Personal.cs @@ -112,7 +112,7 @@ public AchievementList Achievements set => value.ToBytes().CopyTo(Data, Offsets.CountAchievement); } - public RecipeBook GetRecipeBook() => new RecipeBook(Data.Slice(Offsets.Recipes, RecipeBook.SIZE)); + public RecipeBook GetRecipeBook() => new(Data.Slice(Offsets.Recipes, RecipeBook.SIZE)); public void SetRecipeBook(RecipeBook book) => book.Save(Data, Offsets.Recipes); public short[] GetEventFlagsPlayer() @@ -164,7 +164,7 @@ public GSaveDate ProfileTimestamp public bool ProfileIsMakeVillage { get => Data[Offsets.ProfileIsMakeVillage] != 0; - set => Data[Offsets.ProfileIsMakeVillage] = (byte)(value ? 1 : 0); + set => Data[Offsets.ProfileIsMakeVillage] = value ? 1 : 0; } #endregion diff --git a/NHSE.Core/Save/Meta/RevisionChecker.cs b/NHSE.Core/Save/Meta/RevisionChecker.cs index 6aab3ab2..a753130c 100644 --- a/NHSE.Core/Save/Meta/RevisionChecker.cs +++ b/NHSE.Core/Save/Meta/RevisionChecker.cs @@ -11,33 +11,33 @@ public static class RevisionChecker // Patches where the sizes of individual files changed private static readonly SaveFileSizes[] SizesByRevision = { - new SaveFileSizes(0xAC0938, 0x6BC50, 0x263B4, 0xB44580, 0x69508), // 1.0.0 - new SaveFileSizes(0xAC2AA0, 0x6BED0, 0x263C0, 0xB44590, 0x69560), // 1.1.0 - new SaveFileSizes(0xACECD0, 0x6D6C0, 0x2C9C0, 0xB44590, 0x69560), // 1.2.0 - new SaveFileSizes(0xACED80, 0x6D6D0, 0x2C9C0, 0xB44590, 0x69560), // 1.3.0 - new SaveFileSizes(0xB05790, 0x74420, 0x2C9C0, 0xB44590, 0x69560), // 1.4.0 - new SaveFileSizes(0xB20750, 0x76390, 0x2C9C0, 0xB44590, 0x69560), // 1.5.0 - new SaveFileSizes(0xB258E0, 0x76CF0, 0x2C9C0, 0xB44590, 0x69560), // 1.6.0 + new(0xAC0938, 0x6BC50, 0x263B4, 0xB44580, 0x69508), // 1.0.0 + new(0xAC2AA0, 0x6BED0, 0x263C0, 0xB44590, 0x69560), // 1.1.0 + new(0xACECD0, 0x6D6C0, 0x2C9C0, 0xB44590, 0x69560), // 1.2.0 + new(0xACED80, 0x6D6D0, 0x2C9C0, 0xB44590, 0x69560), // 1.3.0 + new(0xB05790, 0x74420, 0x2C9C0, 0xB44590, 0x69560), // 1.4.0 + new(0xB20750, 0x76390, 0x2C9C0, 0xB44590, 0x69560), // 1.5.0 + new(0xB258E0, 0x76CF0, 0x2C9C0, 0xB44590, 0x69560), // 1.6.0 }; private static readonly FileHeaderInfo[] RevisionInfo = { - new FileHeaderInfo { Major = 0x67, Minor = 0x6F, HeaderRevision = 0, Unk1 = 2, SaveRevision = 0, Unk2 = 2 }, // 1.0.0 - new FileHeaderInfo { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 1, Unk2 = 2 }, // 1.1.0 - new FileHeaderInfo { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 2, Unk2 = 2 }, // 1.1.1 - new FileHeaderInfo { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 3, Unk2 = 2 }, // 1.1.2 - new FileHeaderInfo { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 4, Unk2 = 2 }, // 1.1.3 - new FileHeaderInfo { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 5, Unk2 = 2 }, // 1.1.4 - new FileHeaderInfo { Major = 0x20006, Minor = 0x20008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 6, Unk2 = 2 }, // 1.2.0 - new FileHeaderInfo { Major = 0x20006, Minor = 0x20008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 7, Unk2 = 2 }, // 1.2.1 - new FileHeaderInfo { Major = 0x40002, Minor = 0x40008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 8, Unk2 = 2 }, // 1.3.0 - new FileHeaderInfo { Major = 0x40002, Minor = 0x40008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 9, Unk2 = 2 }, // 1.3.1 - new FileHeaderInfo { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 10, Unk2 = 2 }, // 1.4.0 - new FileHeaderInfo { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 11, Unk2 = 2 }, // 1.4.1 - new FileHeaderInfo { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 12, Unk2 = 2 }, // 1.4.2 - new FileHeaderInfo { Major = 0x60001, Minor = 0x6000C, HeaderRevision = 0, Unk1 = 2, SaveRevision = 13, Unk2 = 2 }, // 1.5.0 - new FileHeaderInfo { Major = 0x60001, Minor = 0x6000C, HeaderRevision = 0, Unk1 = 2, SaveRevision = 14, Unk2 = 2 }, // 1.5.1 - new FileHeaderInfo { Major = 0x70001, Minor = 0x70006, HeaderRevision = 0, Unk1 = 2, SaveRevision = 15, Unk2 = 2 }, // 1.6.0 + new() { Major = 0x67, Minor = 0x6F, HeaderRevision = 0, Unk1 = 2, SaveRevision = 0, Unk2 = 2 }, // 1.0.0 + new() { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 1, Unk2 = 2 }, // 1.1.0 + new() { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 2, Unk2 = 2 }, // 1.1.1 + new() { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 3, Unk2 = 2 }, // 1.1.2 + new() { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 4, Unk2 = 2 }, // 1.1.3 + new() { Major = 0x6D, Minor = 0x78, HeaderRevision = 0, Unk1 = 2, SaveRevision = 5, Unk2 = 2 }, // 1.1.4 + new() { Major = 0x20006, Minor = 0x20008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 6, Unk2 = 2 }, // 1.2.0 + new() { Major = 0x20006, Minor = 0x20008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 7, Unk2 = 2 }, // 1.2.1 + new() { Major = 0x40002, Minor = 0x40008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 8, Unk2 = 2 }, // 1.3.0 + new() { Major = 0x40002, Minor = 0x40008, HeaderRevision = 0, Unk1 = 2, SaveRevision = 9, Unk2 = 2 }, // 1.3.1 + new() { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 10, Unk2 = 2 }, // 1.4.0 + new() { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 11, Unk2 = 2 }, // 1.4.1 + new() { Major = 0x50001, Minor = 0x5000B, HeaderRevision = 0, Unk1 = 2, SaveRevision = 12, Unk2 = 2 }, // 1.4.2 + new() { Major = 0x60001, Minor = 0x6000C, HeaderRevision = 0, Unk1 = 2, SaveRevision = 13, Unk2 = 2 }, // 1.5.0 + new() { Major = 0x60001, Minor = 0x6000C, HeaderRevision = 0, Unk1 = 2, SaveRevision = 14, Unk2 = 2 }, // 1.5.1 + new() { Major = 0x70001, Minor = 0x70006, HeaderRevision = 0, Unk1 = 2, SaveRevision = 15, Unk2 = 2 }, // 1.6.0 }; public static readonly IReadOnlyList SizeInfo = new[] diff --git a/NHSE.Core/Strings/GameStrings.cs b/NHSE.Core/Strings/GameStrings.cs index 13316472..ab3ff56b 100644 --- a/NHSE.Core/Strings/GameStrings.cs +++ b/NHSE.Core/Strings/GameStrings.cs @@ -16,7 +16,7 @@ public sealed class GameStrings : IRemakeString public readonly Dictionary VillagerMap; public readonly Dictionary VillagerDefaultPhraseMap; public readonly List ItemDataSource; - public readonly Dictionary InternalNameTranslation = new Dictionary(); + public readonly Dictionary InternalNameTranslation = new(); public IReadOnlyDictionary BodyParts { get; } public IReadOnlyDictionary BodyColor { get; } diff --git a/NHSE.Core/Structures/GameLists.cs b/NHSE.Core/Structures/GameLists.cs index 948554b6..6bcbd24d 100644 --- a/NHSE.Core/Structures/GameLists.cs +++ b/NHSE.Core/Structures/GameLists.cs @@ -386,7 +386,7 @@ public static class GameLists 07411, // mussel }; - public static readonly HashSet Shells = new HashSet + public static readonly HashSet Shells = new() { 1374, // sea snail 1375, // venus comb @@ -401,7 +401,7 @@ public static class GameLists 12968, // pearl }; - public static readonly HashSet Terraforming = new HashSet + public static readonly HashSet Terraforming = new() { 3075, // path construction permit 3247, // waterscaping permit @@ -417,7 +417,7 @@ public static class GameLists 9771, // custom design path permit }; - public static readonly HashSet NoCheckReceived = new HashSet(Terraforming) + public static readonly HashSet NoCheckReceived = new(Terraforming) { Item.DIYRecipe, diff --git a/NHSE.Core/Structures/Item/Item.cs b/NHSE.Core/Structures/Item/Item.cs index f62e59de..5270a531 100644 --- a/NHSE.Core/Structures/Item/Item.cs +++ b/NHSE.Core/Structures/Item/Item.cs @@ -7,7 +7,7 @@ namespace NHSE.Core [StructLayout(LayoutKind.Explicit, Size = SIZE, Pack = 1)] public class Item : ICopyableItem { - public static readonly Item NO_ITEM = new Item {ItemId = NONE}; + public static readonly Item NO_ITEM = new() {ItemId = NONE}; public const ushort NONE = 0xFFFE; public const ushort EXTENSION = 0xFFFD; public const ushort FieldItemMin = 60_000; diff --git a/NHSE.Core/Structures/Item/ItemInfo.cs b/NHSE.Core/Structures/Item/ItemInfo.cs index 9bd1e2f6..4e4160b7 100644 --- a/NHSE.Core/Structures/Item/ItemInfo.cs +++ b/NHSE.Core/Structures/Item/ItemInfo.cs @@ -52,7 +52,7 @@ public static bool TryGetMaxStackCount(ushort id, out ushort max) return MaxCountByKind.TryGetValue(kind, out max); } - private static readonly Dictionary MaxCountByKind = new Dictionary + private static readonly Dictionary MaxCountByKind = new() { {Kind_Ftr, 00001}, {Kind_RoomWall, 00001}, diff --git a/NHSE.Core/Structures/Item/ItemKind.cs b/NHSE.Core/Structures/Item/ItemKind.cs index 288f16ae..589893ec 100644 --- a/NHSE.Core/Structures/Item/ItemKind.cs +++ b/NHSE.Core/Structures/Item/ItemKind.cs @@ -175,7 +175,7 @@ public enum ItemKind : byte public static class ItemKindExtensions { - private static readonly HashSet Clothing = new HashSet + private static readonly HashSet Clothing = new() { Bottoms_Long, Bottoms_Middle, @@ -198,7 +198,7 @@ public static class ItemKindExtensions Top_Short, }; - private static readonly HashSet Furniture = new HashSet + private static readonly HashSet Furniture = new() { Ftr_1x1_Chair, Ftr_1x1_Floor, diff --git a/NHSE.Core/Structures/Item/ItemSize.cs b/NHSE.Core/Structures/Item/ItemSize.cs index ebe652ce..4ad0f4f6 100644 --- a/NHSE.Core/Structures/Item/ItemSize.cs +++ b/NHSE.Core/Structures/Item/ItemSize.cs @@ -20,7 +20,7 @@ public static class ItemSizeExtensions { public const string EnumPrefix = "S_"; - private static readonly Dictionary Dictionary = new Dictionary + private static readonly Dictionary Dictionary = new() { {ItemSizeType.S_1_0x1_0 , new ItemSize( 2, 2)}, // 1x1 {ItemSizeType.S_2_0x1_0 , new ItemSize( 4, 2)}, // 2x1 diff --git a/NHSE.Core/Structures/Item/VillagerItem.cs b/NHSE.Core/Structures/Item/VillagerItem.cs index 79769bcd..98d5e7b7 100644 --- a/NHSE.Core/Structures/Item/VillagerItem.cs +++ b/NHSE.Core/Structures/Item/VillagerItem.cs @@ -7,7 +7,7 @@ namespace NHSE.Core public sealed class VillagerItem : Item, ICopyableItem { public new const int SIZE = 0x2C; - public new static readonly VillagerItem NO_ITEM = new VillagerItem { ItemId = NONE }; + public new static readonly VillagerItem NO_ITEM = new() { ItemId = NONE }; public uint U08; public uint U0C; diff --git a/NHSE.Core/Structures/Map/OutsideAcre.cs b/NHSE.Core/Structures/Map/OutsideAcre.cs index 8b8c267f..16a194e3 100644 --- a/NHSE.Core/Structures/Map/OutsideAcre.cs +++ b/NHSE.Core/Structures/Map/OutsideAcre.cs @@ -168,7 +168,7 @@ public enum OutsideAcre : ushort public static class CollisionUtil { - public static readonly Dictionary Dict = new Dictionary + public static readonly Dictionary Dict = new() { {00, Color.FromArgb( 70, 120, 64)}, // Grass {01, Color.FromArgb(128, 215, 195)}, // River diff --git a/NHSE.Core/Structures/Villager/PlayerHouse.cs b/NHSE.Core/Structures/Villager/PlayerHouse.cs index de8d8149..8eae2917 100644 --- a/NHSE.Core/Structures/Villager/PlayerHouse.cs +++ b/NHSE.Core/Structures/Villager/PlayerHouse.cs @@ -69,7 +69,7 @@ public Item DoorDecoItemName set => value.ToBytesClass().CopyTo(Data, 0x263D4); } - public bool PlayerHouseFlag { get => Data[0x263DC] != 0; set => Data[0x263DC] = (byte)(value ? 1 : 0); } + public bool PlayerHouseFlag { get => Data[0x263DC] != 0; set => Data[0x263DC] = value ? 1 : 0; } public Item PostItemName { diff --git a/NHSE.Core/Structures/Villager/Villager1.cs b/NHSE.Core/Structures/Villager/Villager1.cs index 18316fa8..fcb8982d 100644 --- a/NHSE.Core/Structures/Villager/Villager1.cs +++ b/NHSE.Core/Structures/Villager/Villager1.cs @@ -112,7 +112,7 @@ public GSaveRoomFloorWall Room public DesignPatternPRO Design { - get => new DesignPatternPRO(Data.Slice(0x12128, DesignPatternPRO.SIZE)); + get => new(Data.Slice(0x12128, DesignPatternPRO.SIZE)); set => value.Data.CopyTo(Data, 0x12128); } diff --git a/NHSE.Core/Structures/Villager/Villager2.cs b/NHSE.Core/Structures/Villager/Villager2.cs index bf55775a..9ffafa8b 100644 --- a/NHSE.Core/Structures/Villager/Villager2.cs +++ b/NHSE.Core/Structures/Villager/Villager2.cs @@ -112,7 +112,7 @@ public GSaveRoomFloorWall Room public DesignPatternPRO Design { - get => new DesignPatternPRO(Data.Slice(0x128a8, DesignPatternPRO.SIZE)); + get => new(Data.Slice(0x128a8, DesignPatternPRO.SIZE)); set => value.Data.CopyTo(Data, 0x128a8); } diff --git a/NHSE.Core/Structures/Villager/VillagerConverter.cs b/NHSE.Core/Structures/Villager/VillagerConverter.cs index c312e90d..c0c46ada 100644 --- a/NHSE.Core/Structures/Villager/VillagerConverter.cs +++ b/NHSE.Core/Structures/Villager/VillagerConverter.cs @@ -25,17 +25,13 @@ public static bool IsVillager(int size) /// True if can be converted, false if no conversion available. public static bool IsCompatible(int size, int expect) { - switch (expect) + return expect switch { // Can convert to any format - case Villager1.SIZE: - case Villager2.SIZE: - return IsVillager(size); - + Villager1.SIZE or Villager2.SIZE => IsVillager(size), // No conversion available - default: - return false; - } + _ => false, + }; } /// diff --git a/NHSE.Core/Util/ComboItem.cs b/NHSE.Core/Util/ComboItem.cs index b2ddd772..35988644 100644 --- a/NHSE.Core/Util/ComboItem.cs +++ b/NHSE.Core/Util/ComboItem.cs @@ -83,7 +83,7 @@ public static void Add(this List storage, IReadOnlyList public static void SortByText(this List arr) => arr.Sort(Comparer); private static readonly FunctorComparer Comparer = - new FunctorComparer((a, b) => string.CompareOrdinal(a.Text, b.Text)); + new((a, b) => string.CompareOrdinal(a.Text, b.Text)); private sealed class FunctorComparer : IComparer { diff --git a/NHSE.Core/Util/RandUtil.cs b/NHSE.Core/Util/RandUtil.cs index 1ad54809..4e462cbb 100644 --- a/NHSE.Core/Util/RandUtil.cs +++ b/NHSE.Core/Util/RandUtil.cs @@ -12,7 +12,7 @@ public static class RandUtil // Multi-thread safe rand, ha public static Random Rand => _local.Value; - private static readonly ThreadLocal _local = new ThreadLocal(() => new Random()); + private static readonly ThreadLocal _local = new(() => new Random()); public static uint Rand32() => Rand32(Rand); public static uint Rand32(Random rnd) => (uint)rnd.Next(1 << 30) << 2 | (uint)rnd.Next(1 << 2); diff --git a/NHSE.Core/Util/ResourceUtil.cs b/NHSE.Core/Util/ResourceUtil.cs index 04e18f66..8d1fca2b 100644 --- a/NHSE.Core/Util/ResourceUtil.cs +++ b/NHSE.Core/Util/ResourceUtil.cs @@ -12,9 +12,9 @@ public static class ResourceUtil { private static readonly Assembly thisAssembly = typeof(ResourceUtil).GetTypeInfo().Assembly; private static readonly string[] manifestResourceNames = thisAssembly.GetManifestResourceNames(); - private static readonly Dictionary resourceNameMap = new Dictionary(); - private static readonly Dictionary stringListCache = new Dictionary(); - private static readonly object getStringListLoadLock = new object(); + private static readonly Dictionary resourceNameMap = new(); + private static readonly Dictionary stringListCache = new(); + private static readonly object getStringListLoadLock = new(); public static string[] GetStringList(string fileName) { diff --git a/NHSE.Injection/NHSE.Injection.csproj b/NHSE.Injection/NHSE.Injection.csproj index 45ec1283..7dd37858 100644 --- a/NHSE.Injection/NHSE.Injection.csproj +++ b/NHSE.Injection/NHSE.Injection.csproj @@ -1,8 +1,8 @@ - + net46;netstandard2.0 - 8 + 9 enable diff --git a/NHSE.Injection/SysBot/SysBot.cs b/NHSE.Injection/SysBot/SysBot.cs index ee94efe9..216a6f8b 100644 --- a/NHSE.Injection/SysBot/SysBot.cs +++ b/NHSE.Injection/SysBot/SysBot.cs @@ -7,10 +7,10 @@ public class SysBot : IRAMReadWriter { public string IP = "192.168.1.65"; public int Port = 6000; - public Socket Connection = new Socket(SocketType.Stream, ProtocolType.Tcp); + public Socket Connection = new(SocketType.Stream, ProtocolType.Tcp); public bool Connected { get; private set; } - private readonly object _sync = new object(); + private readonly object _sync = new(); public void Connect(string ip, int port) { diff --git a/NHSE.Injection/SysBot/USBBot.cs b/NHSE.Injection/SysBot/USBBot.cs index d8037abb..af169dfb 100644 --- a/NHSE.Injection/SysBot/USBBot.cs +++ b/NHSE.Injection/SysBot/USBBot.cs @@ -13,7 +13,7 @@ public class USBBot : IRAMReadWriter public bool Connected { get; private set; } - private readonly object _sync = new object(); + private readonly object _sync = new(); public bool Connect() { diff --git a/NHSE.Parsing/BCSV/BCSV.cs b/NHSE.Parsing/BCSV/BCSV.cs index 4c290bdf..c2415444 100644 --- a/NHSE.Parsing/BCSV/BCSV.cs +++ b/NHSE.Parsing/BCSV/BCSV.cs @@ -8,7 +8,7 @@ namespace NHSE.Parsing { public class BCSV { - public static readonly BCSVEnumDictionary EnumLookup = new BCSVEnumDictionary(Resources.specs_130.Split('\n')); + public static readonly BCSVEnumDictionary EnumLookup = new(Resources.specs_130.Split('\n')); public static bool DecodeColumnNames { private get; set; } = true; public const int MAGIC = 0x42435356; // BCSV diff --git a/NHSE.Parsing/BCSV/BCSVEnumDictionary.cs b/NHSE.Parsing/BCSV/BCSVEnumDictionary.cs index 7de06222..ed568a1e 100644 --- a/NHSE.Parsing/BCSV/BCSVEnumDictionary.cs +++ b/NHSE.Parsing/BCSV/BCSVEnumDictionary.cs @@ -7,7 +7,7 @@ namespace NHSE.Parsing { public class BCSVEnumDictionary { - private readonly Dictionary Lookup = new Dictionary(); + private readonly Dictionary Lookup = new(); public BCSVEnumDictionary(IEnumerable lines) { diff --git a/NHSE.Parsing/GameBCSVDumper.cs b/NHSE.Parsing/GameBCSVDumper.cs index eec5d95d..aa3c2c7d 100644 --- a/NHSE.Parsing/GameBCSVDumper.cs +++ b/NHSE.Parsing/GameBCSVDumper.cs @@ -250,7 +250,7 @@ public static Dictionary GetItemStackDict(string pathBCSV, str // clothing is split out more granularly in ItemKind and would cause errors // since it's not likely to ever be stackable, we can skip // none-type can be skipped and doesn't exist in ItemKind either - List skipLabels = new List + List skipLabels = new() { "TopsDefault", "Tops", diff --git a/NHSE.Parsing/GameMSBTDumper.cs b/NHSE.Parsing/GameMSBTDumper.cs index bd43fb73..27ba4ea9 100644 --- a/NHSE.Parsing/GameMSBTDumper.cs +++ b/NHSE.Parsing/GameMSBTDumper.cs @@ -144,7 +144,7 @@ private static string GetForgerySuffix(string language) }; } - private static readonly Dictionary InternalItemList = new Dictionary + private static readonly Dictionary InternalItemList = new() { {4200, "k.k. slider's guitar (internal)"}, }; diff --git a/NHSE.Parsing/MSBT/BinaryReaderX.cs b/NHSE.Parsing/MSBT/BinaryReaderX.cs index 1c19a651..c47c1e90 100644 --- a/NHSE.Parsing/MSBT/BinaryReaderX.cs +++ b/NHSE.Parsing/MSBT/BinaryReaderX.cs @@ -39,7 +39,7 @@ public string ReadString(int length) public string PeekString(int length = 4) { - List bytes = new List(); + List bytes = new(); long startOffset = BaseStream.Position; for (int i = 0; i < length; i++) diff --git a/NHSE.Parsing/MSBT/LBL1.cs b/NHSE.Parsing/MSBT/LBL1.cs index 21e94f20..f97f5846 100644 --- a/NHSE.Parsing/MSBT/LBL1.cs +++ b/NHSE.Parsing/MSBT/LBL1.cs @@ -7,8 +7,8 @@ public class LBL1 : MSBTSection { public uint NumberOfGroups; - public readonly List Groups = new List(); - public readonly List Labels = new List(); + public readonly List Groups = new(); + public readonly List Labels = new(); public LBL1() : base(string.Empty, Array.Empty()) { diff --git a/NHSE.Parsing/MSBT/MSBT.cs b/NHSE.Parsing/MSBT/MSBT.cs index 19763056..7d610077 100644 --- a/NHSE.Parsing/MSBT/MSBT.cs +++ b/NHSE.Parsing/MSBT/MSBT.cs @@ -8,8 +8,8 @@ namespace NHSE.Parsing public class MSBT { public readonly MSBTHeader Header; - public readonly LBL1 LBL1 = new LBL1(); - public readonly TXT2 TXT2 = new TXT2(); + public readonly LBL1 LBL1 = new(); + public readonly TXT2 TXT2 = new(); public readonly Encoding FileEncoding; public readonly List SectionOrder; public bool HasLabels; diff --git a/NHSE.Parsing/MSBT/MSBTTextString.cs b/NHSE.Parsing/MSBT/MSBTTextString.cs index dd78c94e..c67d70e7 100644 --- a/NHSE.Parsing/MSBT/MSBTTextString.cs +++ b/NHSE.Parsing/MSBT/MSBTTextString.cs @@ -8,7 +8,7 @@ public class MSBTTextString public readonly byte[] Value; public readonly uint Index; - public static readonly MSBTTextString Empty = new MSBTTextString(Array.Empty(), 0); + public static readonly MSBTTextString Empty = new(Array.Empty(), 0); public MSBTTextString(byte[] v, uint i) { diff --git a/NHSE.Parsing/MSBT/TXT2.cs b/NHSE.Parsing/MSBT/TXT2.cs index 0e19041e..ae73b3e7 100644 --- a/NHSE.Parsing/MSBT/TXT2.cs +++ b/NHSE.Parsing/MSBT/TXT2.cs @@ -7,7 +7,7 @@ public class TXT2 : MSBTSection { public uint NumberOfStrings; - public readonly List Strings = new List(); + public readonly List Strings = new(); public TXT2() : base(string.Empty, Array.Empty()) { diff --git a/NHSE.Parsing/NHSE.Parsing.csproj b/NHSE.Parsing/NHSE.Parsing.csproj index 1ab17e70..4f70477b 100644 --- a/NHSE.Parsing/NHSE.Parsing.csproj +++ b/NHSE.Parsing/NHSE.Parsing.csproj @@ -2,7 +2,7 @@ netstandard2.0 - 8 + 9 enable diff --git a/NHSE.Parsing/ParseConverter.cs b/NHSE.Parsing/ParseConverter.cs index 6f4f3854..af91913f 100644 --- a/NHSE.Parsing/ParseConverter.cs +++ b/NHSE.Parsing/ParseConverter.cs @@ -27,17 +27,15 @@ private static string[] ConvertItemList(string path) var max = items.Max(z => z.Index); var result = new string[max + 1]; foreach (var item in items) - { result[item.Index] = item.Name; - } return result; } } public class ParseItem { - public int Index; - public string Name; + public readonly int Index; + public readonly string Name; public ParseItem(string line) { var split = line.Split(new[] { ", " }, 0); diff --git a/NHSE.Sprites/Field/TerrainSprite.cs b/NHSE.Sprites/Field/TerrainSprite.cs index f294de17..b0b4b814 100644 --- a/NHSE.Sprites/Field/TerrainSprite.cs +++ b/NHSE.Sprites/Field/TerrainSprite.cs @@ -11,8 +11,7 @@ public static class TerrainSprite private static readonly Brush Text = Brushes.White; private static readonly Brush Tile = Brushes.Black; private static readonly Brush Plaza = Brushes.RosyBrown; - private static readonly StringFormat BuildingTextFormat = new StringFormat - { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; + private static readonly StringFormat BuildingTextFormat = new() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; private const int PlazaWidth = 6 * 2; private const int PlazaHeight = 5 * 2; diff --git a/NHSE.Sprites/Item/ItemSprite.cs b/NHSE.Sprites/Item/ItemSprite.cs index 7db08caa..7cce4590 100644 --- a/NHSE.Sprites/Item/ItemSprite.cs +++ b/NHSE.Sprites/Item/ItemSprite.cs @@ -14,7 +14,7 @@ public static class ItemSprite // %appdata%/NHSE public static string PlatformAppDataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), nameof(NHSE)); public static string PlatformAppDataImagePath { get; } = Path.Combine(PlatformAppDataPath, "img"); - public static bool SingleSpriteExists { get => Directory.EnumerateFileSystemEntries(PlatformAppDataImagePath).Any(); } + public static bool SingleSpriteExists => Directory.EnumerateFileSystemEntries(PlatformAppDataImagePath).Any(); public static void Initialize(string[] itemNames) { @@ -103,8 +103,7 @@ private static ushort TryGetFieldItemId(ushort id, int length) return remap >= length ? id : remap; } - private static readonly StringFormat Center = new StringFormat - { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; + private static readonly StringFormat Center = new() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center }; private static Bitmap CreateFake(Item item, Font font, int width, int height, Bitmap bmp) { diff --git a/NHSE.Sprites/NHSE.Sprites.csproj b/NHSE.Sprites/NHSE.Sprites.csproj index 2a80a89a..ce9ae3be 100644 --- a/NHSE.Sprites/NHSE.Sprites.csproj +++ b/NHSE.Sprites/NHSE.Sprites.csproj @@ -2,7 +2,7 @@ net46;net5.0 - 8 + 9 enable diff --git a/NHSE.WinForms/Controls/ItemGrid.cs b/NHSE.WinForms/Controls/ItemGrid.cs index 2fa91565..bcf786d9 100644 --- a/NHSE.WinForms/Controls/ItemGrid.cs +++ b/NHSE.WinForms/Controls/ItemGrid.cs @@ -13,7 +13,7 @@ public ItemGrid() InitializeComponent(); } - public readonly List Entries = new List(); + public readonly List Entries = new(); public int Slots { get; private set; } private int sizeW = 32; diff --git a/NHSE.WinForms/Controls/ItemGridEditor.cs b/NHSE.WinForms/Controls/ItemGridEditor.cs index b77d6638..061ca54a 100644 --- a/NHSE.WinForms/Controls/ItemGridEditor.cs +++ b/NHSE.WinForms/Controls/ItemGridEditor.cs @@ -10,7 +10,7 @@ namespace NHSE.WinForms { public partial class ItemGridEditor : UserControl { - private static readonly GridSize Sprites = new GridSize(); + private static readonly GridSize Sprites = new(); private readonly ItemEditor Editor; private readonly IReadOnlyList Items; @@ -65,7 +65,7 @@ private void Slot_MouseWheel(object? sender, MouseEventArgs e) public void Slot_MouseEnter(object? sender, EventArgs e) { - if (!(sender is PictureBox pb)) + if (sender is not PictureBox pb) return; var index = SlotPictureBoxes.IndexOf(pb); var item = GetItem(index); @@ -77,7 +77,7 @@ public void Slot_MouseEnter(object? sender, EventArgs e) public void Slot_MouseLeave(object? sender, EventArgs e) { - if (!(sender is PictureBox)) + if (sender is not PictureBox) return; L_ItemName.Text = string.Empty; HoverTip.RemoveAll(); @@ -265,7 +265,7 @@ private void B_SortAlpha_Click(object sender, EventArgs e) private void B_SortType_Click(object sender, EventArgs e) { var sortedItems = Items.Where(item => item.ItemId != Item.NONE) - .OrderBy(item => ItemInfo.GetItemKind(item)) + .OrderBy(ItemInfo.GetItemKind) .ThenBy(item => GetItemText(item).ToLower()); var sortedItemsCopy = new List(); // to prevent object reference issues diff --git a/NHSE.WinForms/NHSE.WinForms.csproj b/NHSE.WinForms/NHSE.WinForms.csproj index 1eb9cdf9..d0a919b7 100644 --- a/NHSE.WinForms/NHSE.WinForms.csproj +++ b/NHSE.WinForms/NHSE.WinForms.csproj @@ -10,7 +10,7 @@ Animal Crossing - New Horizons Save Editor NHSE.WinForms.Program icon.ico - 8 + 9 enable AnyCPU;x86 diff --git a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs index 51cb105f..3d69171b 100644 --- a/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs +++ b/NHSE.WinForms/Subforms/Map/FieldItemEditor.cs @@ -802,7 +802,7 @@ private void LoadIndex(int index) private void NUD_BuildingType_ValueChanged(object sender, EventArgs e) { - if (Loading || !(sender is NumericUpDown n)) + if (Loading || sender is not NumericUpDown n) return; var b = Map.Buildings[SelectedBuildingIndex]; diff --git a/NHSE.WinForms/Subforms/Program/ImageFetcher.cs b/NHSE.WinForms/Subforms/Program/ImageFetcher.cs index e99a8880..c169534a 100644 --- a/NHSE.WinForms/Subforms/Program/ImageFetcher.cs +++ b/NHSE.WinForms/Subforms/Program/ImageFetcher.cs @@ -13,7 +13,7 @@ namespace NHSE.WinForms public sealed partial class ImageFetcher : Form { private const string Filename = "image.zip"; - private static string ZipFilePath { get => Path.Combine(ItemSprite.PlatformAppDataPath, Filename); } + private static string ZipFilePath => Path.Combine(ItemSprite.PlatformAppDataPath, Filename); private readonly IReadOnlyList AllHosts; diff --git a/NHSE.WinForms/Subforms/SysBot/SysBotController.cs b/NHSE.WinForms/Subforms/SysBot/SysBotController.cs index 7c08b620..e923b182 100644 --- a/NHSE.WinForms/Subforms/SysBot/SysBotController.cs +++ b/NHSE.WinForms/Subforms/SysBot/SysBotController.cs @@ -10,7 +10,7 @@ public class SysBotController public SysBotController(InjectionType type) => Type = type; private readonly InjectionType Type; - public readonly SysBot Bot = new SysBot(); + public readonly SysBot Bot = new(); private readonly Settings Settings = Settings.Default; public string IP => Settings.SysBotIP; diff --git a/NHSE.WinForms/Subforms/SysBot/USBBotController.cs b/NHSE.WinForms/Subforms/SysBot/USBBotController.cs index 0c8b2ee3..796824b5 100644 --- a/NHSE.WinForms/Subforms/SysBot/USBBotController.cs +++ b/NHSE.WinForms/Subforms/SysBot/USBBotController.cs @@ -5,7 +5,7 @@ namespace NHSE.WinForms { public class USBBotController { - public readonly USBBot Bot = new USBBot(); + public readonly USBBot Bot = new(); public bool Connect() { diff --git a/NHSE.WinForms/Util/WinFormsTranslator.cs b/NHSE.WinForms/Util/WinFormsTranslator.cs index c26c92d2..e9ce2bc3 100644 --- a/NHSE.WinForms/Util/WinFormsTranslator.cs +++ b/NHSE.WinForms/Util/WinFormsTranslator.cs @@ -9,7 +9,7 @@ namespace NHSE.WinForms { public static class WinFormsTranslator { - private static readonly Dictionary Context = new Dictionary(); + private static readonly Dictionary Context = new(); internal static void TranslateInterface(this Control form, string lang) => TranslateForm(form, GetContext(lang)); private static string GetTranslationFileNameInternal(string lang) => $"lang_{lang}"; @@ -77,7 +77,7 @@ private static IEnumerable GetTranslationFile(string lang) if (ResourceUtil.IsStringListCached(file, out var result)) return result; var obj = Properties.Resources.ResourceManager.GetObject(file); - if (!(obj is string txt)) + if (obj is not string txt) return Array.Empty(); return ResourceUtil.LoadStringList(file, txt); } @@ -232,7 +232,7 @@ public sealed class TranslationContext public bool AddNew { private get; set; } public bool RemoveUsedKeys { private get; set; } public const char Separator = '='; - private readonly Dictionary Translation = new Dictionary(); + private readonly Dictionary Translation = new(); public TranslationContext(IEnumerable content, char separator = Separator) {