diff --git a/pkNX.Containers/Container.cs b/pkNX.Containers/Container.cs index 843312cc..c24ee910 100644 --- a/pkNX.Containers/Container.cs +++ b/pkNX.Containers/Container.cs @@ -14,7 +14,7 @@ public static IFileContainer GetContainer(string path, ContainerType t) { return t switch { - ContainerType.GARC => (IFileContainer) new GARC(path), + ContainerType.GARC => new GARC(path), ContainerType.Mini => MiniUtil.GetMini(path), ContainerType.SARC => new SARC(path), ContainerType.Folder => new FolderContainer(path), @@ -32,7 +32,7 @@ public static IFileContainer GetContainer(string path) { var fs = new FileStream(path, FileMode.Open); var container = GetContainer(fs); - if (!(container is LargeContainer)) // not kept + if (container is not LargeContainer) // not kept fs.Dispose(); if (container == null) return null; @@ -47,11 +47,9 @@ public static IFileContainer GetContainer(string path) /// Stream for the binary data public static IFileContainer GetContainer(Stream stream) { -#pragma warning disable IDE0068 // Use recommended dispose pattern var br = new BinaryReader(stream); -#pragma warning restore IDE0068 // Use recommended dispose pattern var container = GetContainer(br); - if (!(container is LargeContainer)) // not kept + if (container is not LargeContainer) // not kept br.Dispose(); return container; } diff --git a/pkNX.Containers/FakeContainer.cs b/pkNX.Containers/FakeContainer.cs index 73d1e73e..bbf3bb74 100644 --- a/pkNX.Containers/FakeContainer.cs +++ b/pkNX.Containers/FakeContainer.cs @@ -30,7 +30,7 @@ public FakeContainer(byte[][] files) public Task GetFiles() => Task.FromResult(Files); public Task GetFile(int file, int subFile = 0) => Task.FromResult(this[file]); public Task SetFile(int file, byte[] value, int subFile = 0) => Task.FromResult(this[file] = value); - public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new Task(() => SaveAll(path, handler, token), token); + public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new(() => SaveAll(path, handler, token), token); public void SaveAll(string path, ContainerHandler handler, CancellationToken token) { diff --git a/pkNX.Containers/FolderContainer.cs b/pkNX.Containers/FolderContainer.cs index 483d9561..4a45b596 100644 --- a/pkNX.Containers/FolderContainer.cs +++ b/pkNX.Containers/FolderContainer.cs @@ -9,9 +9,9 @@ namespace pkNX.Containers { public class FolderContainer : IFileContainer { - private readonly List Paths = new List(); - private readonly List Data = new List(); - private readonly List TrackModify = new List(); + private readonly List Paths = new(); + private readonly List Data = new(); + private readonly List TrackModify = new(); public FolderContainer() { } public FolderContainer(IEnumerable files) => AddFiles(files); @@ -90,7 +90,7 @@ public bool Modified public Task GetFiles() => Task.FromResult(Paths.Select(FileMitm.ReadAllBytes).ToArray()); public Task GetFile(int file, int subFile = 0) => Task.FromResult(this[file]); public Task SetFile(int file, byte[] value, int subFile = 0) => Task.FromResult(this[file] = value); - public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new Task(SaveAll, token); + public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new(SaveAll, token); private void SaveAll() { diff --git a/pkNX.Containers/LargeContainer.cs b/pkNX.Containers/LargeContainer.cs index 91465450..906e3099 100644 --- a/pkNX.Containers/LargeContainer.cs +++ b/pkNX.Containers/LargeContainer.cs @@ -14,9 +14,9 @@ public abstract class LargeContainer : IDisposable, IFileContainer { public virtual int Count => Files.Length; - public Task GetFiles() => new Task(() => { CacheAll(); return Files; }); - public Task GetFile(int file, int subFile = 0) => new Task(() => GetEntry(file, subFile)); - public Task SetFile(int file, byte[] value, int subFile = 0) => new Task(() => SetEntry(file, value, subFile)); + public Task GetFiles() => new(() => { CacheAll(); return Files; }); + public Task GetFile(int file, int subFile = 0) => new(() => GetEntry(file, subFile)); + public Task SetFile(int file, byte[] value, int subFile = 0) => new(() => SetEntry(file, value, subFile)); public string Extension => Path.GetExtension(FilePath); public string FileName => Path.GetFileName(FilePath); @@ -89,12 +89,7 @@ private byte[] GetCachedValue(int i, int subFile) public void CacheAll() { for (int i = 0; i < Files.Length; i++) - { - if (Files[i] == null) - { - Files[i] = GetCachedValue(i, 0); - } - } + Files[i] ??= GetCachedValue(i, 0); Reader = null; Stream.Close(); @@ -113,7 +108,7 @@ public void CancelEdits() public abstract void Dump(string path, ContainerHandler handler); - public async Task SaveAs(string path, ContainerHandler handler, CancellationToken token = new CancellationToken()) + public async Task SaveAs(string path, ContainerHandler handler, CancellationToken token = new()) { bool sameLocation = path == FilePath && Reader != null; var writePath = sameLocation ? Path.GetTempFileName() : path; diff --git a/pkNX.Containers/Mini/Mini.cs b/pkNX.Containers/Mini/Mini.cs index 45c2b6fa..1c2777d2 100644 --- a/pkNX.Containers/Mini/Mini.cs +++ b/pkNX.Containers/Mini/Mini.cs @@ -49,7 +49,7 @@ public void CancelEdits() public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) { - return new Task(() => + return new(() => { byte[] data = MiniUtil.PackMini(Files, Identifier); FileMitm.WriteAllBytes(path, data); diff --git a/pkNX.Containers/Misc/GFPack.cs b/pkNX.Containers/Misc/GFPack.cs index 6afac8f6..b1fc1688 100644 --- a/pkNX.Containers/Misc/GFPack.cs +++ b/pkNX.Containers/Misc/GFPack.cs @@ -265,7 +265,7 @@ private void WriteHeaderTableList(BinaryWriter bw) public Task GetFiles() => Task.FromResult(DecompressedFiles); public Task GetFile(int file, int subFile = 0) => Task.FromResult(this[file]); public Task SetFile(int file, byte[] value, int subFile = 0) => Task.FromResult(this[file] = value); - public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new Task(() => FileMitm.WriteAllBytes(path, Write()), token); + public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new(() => FileMitm.WriteAllBytes(path, Write()), token); public void Dump(string path, ContainerHandler handler) { diff --git a/pkNX.Containers/SingleFileContainer.cs b/pkNX.Containers/SingleFileContainer.cs index 76daf28d..184337d4 100644 --- a/pkNX.Containers/SingleFileContainer.cs +++ b/pkNX.Containers/SingleFileContainer.cs @@ -38,7 +38,7 @@ public void CancelEdits() public Task GetFiles() => Task.FromResult(new[] {this[0]}); public Task GetFile(int file, int subFile = 0) => Task.FromResult(this[0]); public Task SetFile(int file, byte[] value, int subFile = 0) => Task.FromResult(Data = value); - public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new Task(() => Dump(path, handler), token); + public Task SaveAs(string path, ContainerHandler handler, CancellationToken token) => new(() => Dump(path, handler), token); public void Dump(string path, ContainerHandler handler) => FileMitm.WriteAllBytes(path ?? FilePath, Data); } } diff --git a/pkNX.Game/File/GameFileMapping.cs b/pkNX.Game/File/GameFileMapping.cs index d476eb3a..90ffd8cb 100644 --- a/pkNX.Game/File/GameFileMapping.cs +++ b/pkNX.Game/File/GameFileMapping.cs @@ -12,11 +12,11 @@ namespace pkNX.Game /// public class GameFileMapping { - private readonly Dictionary Cache = new Dictionary(); + private readonly Dictionary Cache = new(); private readonly IReadOnlyCollection FileMap; - public readonly ContainerHandler ProgressTracker = new ContainerHandler(); - public readonly CancellationTokenSource TokenSource = new CancellationTokenSource(); + public readonly ContainerHandler ProgressTracker = new(); + public readonly CancellationTokenSource TokenSource = new(); private readonly GameLocation ROM; public GameFileMapping(GameLocation rom) => FileMap = GetMapping((ROM = rom).Game); @@ -74,174 +74,174 @@ public static IReadOnlyCollection GetMapping(GameVersion game #region Games private static readonly GameFileReference[] XY = { - new GameFileReference(005, GameFile.MoveSprites), - new GameFileReference(012, GameFile.Encounters), - new GameFileReference(038, GameFile.TrainerData), - new GameFileReference(039, GameFile.TrainerClass), - new GameFileReference(040, GameFile.TrainerPoke), - new GameFileReference(041, GameFile.MapGameRegion), - new GameFileReference(042, GameFile.MapMatrix), + new(005, GameFile.MoveSprites), + new(012, GameFile.Encounters), + new(038, GameFile.TrainerData), + new(039, GameFile.TrainerClass), + new(040, GameFile.TrainerPoke), + new(041, GameFile.MapGameRegion), + new(042, GameFile.MapMatrix), - new GameFileReference(072, GameFile.GameText0), - new GameFileReference(073, GameFile.GameText1), - new GameFileReference(074, GameFile.GameText2), - new GameFileReference(075, GameFile.GameText3), - new GameFileReference(076, GameFile.GameText4), - new GameFileReference(077, GameFile.GameText5), - new GameFileReference(078, GameFile.GameText6), - new GameFileReference(079, GameFile.GameText7), - new GameFileReference(080, GameFile.StoryText0), - new GameFileReference(081, GameFile.StoryText1), - new GameFileReference(082, GameFile.StoryText2), - new GameFileReference(083, GameFile.StoryText3), - new GameFileReference(084, GameFile.StoryText4), - new GameFileReference(085, GameFile.StoryText5), - new GameFileReference(086, GameFile.StoryText6), - new GameFileReference(087, GameFile.StoryText7), + new(072, GameFile.GameText0), + new(073, GameFile.GameText1), + new(074, GameFile.GameText2), + new(075, GameFile.GameText3), + new(076, GameFile.GameText4), + new(077, GameFile.GameText5), + new(078, GameFile.GameText6), + new(079, GameFile.GameText7), + new(080, GameFile.StoryText0), + new(081, GameFile.StoryText1), + new(082, GameFile.StoryText2), + new(083, GameFile.StoryText3), + new(084, GameFile.StoryText4), + new(085, GameFile.StoryText5), + new(086, GameFile.StoryText6), + new(087, GameFile.StoryText7), - new GameFileReference(104, GameFile.Wallpaper), - new GameFileReference(165, GameFile.TitleScreen), - new GameFileReference(203, GameFile.FacilityPokeNormal), - new GameFileReference(204, GameFile.FacilityTrainerNormal), - new GameFileReference(205, GameFile.FacilityPokeSuper), - new GameFileReference(206, GameFile.FacilityTrainerSuper), - new GameFileReference(212, GameFile.MoveStats), - new GameFileReference(213, GameFile.EggMoves), - new GameFileReference(214, GameFile.Learnsets), - new GameFileReference(215, GameFile.Evolutions), - new GameFileReference(216, GameFile.MegaEvolutions), - new GameFileReference(218, GameFile.PersonalStats), - new GameFileReference(220, GameFile.ItemStats), + new(104, GameFile.Wallpaper), + new(165, GameFile.TitleScreen), + new(203, GameFile.FacilityPokeNormal), + new(204, GameFile.FacilityTrainerNormal), + new(205, GameFile.FacilityPokeSuper), + new(206, GameFile.FacilityTrainerSuper), + new(212, GameFile.MoveStats), + new(213, GameFile.EggMoves), + new(214, GameFile.Learnsets), + new(215, GameFile.Evolutions), + new(216, GameFile.MegaEvolutions), + new(218, GameFile.PersonalStats), + new(220, GameFile.ItemStats), }; private static readonly GameFileReference[] AO = { - new GameFileReference(013, GameFile.Encounters), - new GameFileReference(036, GameFile.TrainerData), - new GameFileReference(037, GameFile.TrainerClass), - new GameFileReference(038, GameFile.TrainerPoke), - new GameFileReference(039, GameFile.MapGameRegion), - new GameFileReference(040, GameFile.MapMatrix), + new(013, GameFile.Encounters), + new(036, GameFile.TrainerData), + new(037, GameFile.TrainerClass), + new(038, GameFile.TrainerPoke), + new(039, GameFile.MapGameRegion), + new(040, GameFile.MapMatrix), - new GameFileReference(071, GameFile.GameText0), - new GameFileReference(072, GameFile.GameText1), - new GameFileReference(073, GameFile.GameText2), - new GameFileReference(074, GameFile.GameText3), - new GameFileReference(075, GameFile.GameText4), - new GameFileReference(076, GameFile.GameText5), - new GameFileReference(077, GameFile.GameText6), - new GameFileReference(078, GameFile.GameText7), - new GameFileReference(079, GameFile.StoryText0), - new GameFileReference(080, GameFile.StoryText1), - new GameFileReference(081, GameFile.StoryText2), - new GameFileReference(082, GameFile.StoryText3), - new GameFileReference(083, GameFile.StoryText4), - new GameFileReference(084, GameFile.StoryText5), - new GameFileReference(085, GameFile.StoryText6), - new GameFileReference(086, GameFile.StoryText7), + new(071, GameFile.GameText0), + new(072, GameFile.GameText1), + new(073, GameFile.GameText2), + new(074, GameFile.GameText3), + new(075, GameFile.GameText4), + new(076, GameFile.GameText5), + new(077, GameFile.GameText6), + new(078, GameFile.GameText7), + new(079, GameFile.StoryText0), + new(080, GameFile.StoryText1), + new(081, GameFile.StoryText2), + new(082, GameFile.StoryText3), + new(083, GameFile.StoryText4), + new(084, GameFile.StoryText5), + new(085, GameFile.StoryText6), + new(086, GameFile.StoryText7), - new GameFileReference(103, GameFile.Wallpaper), - new GameFileReference(152, GameFile.TitleScreen), - new GameFileReference(182, GameFile.FacilityPokeNormal), - new GameFileReference(183, GameFile.FacilityTrainerNormal), - new GameFileReference(184, GameFile.FacilityPokeSuper), - new GameFileReference(185, GameFile.FacilityTrainerSuper), - new GameFileReference(189, GameFile.MoveStats), - new GameFileReference(190, GameFile.EggMoves), - new GameFileReference(191, GameFile.Learnsets), - new GameFileReference(192, GameFile.Evolutions), - new GameFileReference(193, GameFile.MegaEvolutions), - new GameFileReference(195, GameFile.PersonalStats), - new GameFileReference(197, GameFile.ItemStats), + new(103, GameFile.Wallpaper), + new(152, GameFile.TitleScreen), + new(182, GameFile.FacilityPokeNormal), + new(183, GameFile.FacilityTrainerNormal), + new(184, GameFile.FacilityPokeSuper), + new(185, GameFile.FacilityTrainerSuper), + new(189, GameFile.MoveStats), + new(190, GameFile.EggMoves), + new(191, GameFile.Learnsets), + new(192, GameFile.Evolutions), + new(193, GameFile.MegaEvolutions), + new(195, GameFile.PersonalStats), + new(197, GameFile.ItemStats), }; #endregion #region Gen7 private static readonly GameFileReference[] SMDEMO = { - new GameFileReference(011, GameFile.MoveStats), - new GameFileReference(012, GameFile.EggMoves), - new GameFileReference(013, GameFile.Learnsets), - new GameFileReference(014, GameFile.Evolutions), - new GameFileReference(015, GameFile.MegaEvolutions), - new GameFileReference(017, GameFile.PersonalStats), - new GameFileReference(019, GameFile.ItemStats), + new(011, GameFile.MoveStats), + new(012, GameFile.EggMoves), + new(013, GameFile.Learnsets), + new(014, GameFile.Evolutions), + new(015, GameFile.MegaEvolutions), + new(017, GameFile.PersonalStats), + new(019, GameFile.ItemStats), - new GameFileReference(030, GameFile.GameText0), - new GameFileReference(031, GameFile.GameText1), - new GameFileReference(032, GameFile.GameText2), - new GameFileReference(033, GameFile.GameText3), - new GameFileReference(034, GameFile.GameText4), - new GameFileReference(035, GameFile.GameText5), - new GameFileReference(036, GameFile.GameText6), - new GameFileReference(037, GameFile.GameText7), - new GameFileReference(038, GameFile.GameText8), - new GameFileReference(039, GameFile.GameText9), - new GameFileReference(040, GameFile.StoryText0), - new GameFileReference(041, GameFile.StoryText1), - new GameFileReference(042, GameFile.StoryText2), - new GameFileReference(043, GameFile.StoryText3), - new GameFileReference(044, GameFile.StoryText4), - new GameFileReference(045, GameFile.StoryText5), - new GameFileReference(046, GameFile.StoryText6), - new GameFileReference(047, GameFile.StoryText7), - new GameFileReference(048, GameFile.StoryText8), - new GameFileReference(049, GameFile.StoryText9), + new(030, GameFile.GameText0), + new(031, GameFile.GameText1), + new(032, GameFile.GameText2), + new(033, GameFile.GameText3), + new(034, GameFile.GameText4), + new(035, GameFile.GameText5), + new(036, GameFile.GameText6), + new(037, GameFile.GameText7), + new(038, GameFile.GameText8), + new(039, GameFile.GameText9), + new(040, GameFile.StoryText0), + new(041, GameFile.StoryText1), + new(042, GameFile.StoryText2), + new(043, GameFile.StoryText3), + new(044, GameFile.StoryText4), + new(045, GameFile.StoryText5), + new(046, GameFile.StoryText6), + new(047, GameFile.StoryText7), + new(048, GameFile.StoryText8), + new(049, GameFile.StoryText9), - new GameFileReference(076, GameFile.ZoneData), - new GameFileReference(091, GameFile.WorldData), + new(076, GameFile.ZoneData), + new(091, GameFile.WorldData), - new GameFileReference(101, GameFile.TrainerClass), - new GameFileReference(102, GameFile.TrainerData), - new GameFileReference(103, GameFile.TrainerPoke), + new(101, GameFile.TrainerClass), + new(102, GameFile.TrainerData), + new(103, GameFile.TrainerPoke), }; private static readonly GameFileReference[] SM = { - new GameFileReference(011, GameFile.MoveStats), - new GameFileReference(012, GameFile.EggMoves), - new GameFileReference(013, GameFile.Learnsets), - new GameFileReference(014, GameFile.Evolutions), - new GameFileReference(015, GameFile.MegaEvolutions), - new GameFileReference(017, GameFile.PersonalStats), - new GameFileReference(019, GameFile.ItemStats), + new(011, GameFile.MoveStats), + new(012, GameFile.EggMoves), + new(013, GameFile.Learnsets), + new(014, GameFile.Evolutions), + new(015, GameFile.MegaEvolutions), + new(017, GameFile.PersonalStats), + new(019, GameFile.ItemStats), - new GameFileReference(030, GameFile.GameText0), - new GameFileReference(031, GameFile.GameText1), - new GameFileReference(032, GameFile.GameText2), - new GameFileReference(033, GameFile.GameText3), - new GameFileReference(034, GameFile.GameText4), - new GameFileReference(035, GameFile.GameText5), - new GameFileReference(036, GameFile.GameText6), - new GameFileReference(037, GameFile.GameText7), - new GameFileReference(038, GameFile.GameText8), - new GameFileReference(039, GameFile.GameText9), - new GameFileReference(040, GameFile.StoryText0), - new GameFileReference(041, GameFile.StoryText1), - new GameFileReference(042, GameFile.StoryText2), - new GameFileReference(043, GameFile.StoryText3), - new GameFileReference(044, GameFile.StoryText4), - new GameFileReference(045, GameFile.StoryText5), - new GameFileReference(046, GameFile.StoryText6), - new GameFileReference(047, GameFile.StoryText7), - new GameFileReference(048, GameFile.StoryText8), - new GameFileReference(049, GameFile.StoryText9), + new(030, GameFile.GameText0), + new(031, GameFile.GameText1), + new(032, GameFile.GameText2), + new(033, GameFile.GameText3), + new(034, GameFile.GameText4), + new(035, GameFile.GameText5), + new(036, GameFile.GameText6), + new(037, GameFile.GameText7), + new(038, GameFile.GameText8), + new(039, GameFile.GameText9), + new(040, GameFile.StoryText0), + new(041, GameFile.StoryText1), + new(042, GameFile.StoryText2), + new(043, GameFile.StoryText3), + new(044, GameFile.StoryText4), + new(045, GameFile.StoryText5), + new(046, GameFile.StoryText6), + new(047, GameFile.StoryText7), + new(048, GameFile.StoryText8), + new(049, GameFile.StoryText9), - new GameFileReference(077, GameFile.ZoneData), - new GameFileReference(091, GameFile.WorldData), + new(077, GameFile.ZoneData), + new(091, GameFile.WorldData), - new GameFileReference(104, GameFile.TrainerClass), - new GameFileReference(105, GameFile.TrainerData), - new GameFileReference(106, GameFile.TrainerPoke), + new(104, GameFile.TrainerClass), + new(105, GameFile.TrainerData), + new(106, GameFile.TrainerPoke), - new GameFileReference(155, GameFile.EncounterStatic), + new(155, GameFile.EncounterStatic), - new GameFileReference(267, GameFile.Pickup), + new(267, GameFile.Pickup), - new GameFileReference(277, GameFile.FacilityPokeNormal), - new GameFileReference(278, GameFile.FacilityTrainerNormal), - new GameFileReference(279, GameFile.FacilityPokeSuper), - new GameFileReference(280, GameFile.FacilityTrainerSuper), + new(277, GameFile.FacilityPokeNormal), + new(278, GameFile.FacilityTrainerNormal), + new(279, GameFile.FacilityPokeSuper), + new(280, GameFile.FacilityTrainerSuper), }; /// @@ -249,50 +249,50 @@ public static IReadOnlyCollection GetMapping(GameVersion game /// private static readonly GameFileReference[] UU = { - new GameFileReference(011, GameFile.MoveStats), - new GameFileReference(012, GameFile.EggMoves), - new GameFileReference(013, GameFile.Learnsets), - new GameFileReference(014, GameFile.Evolutions), - new GameFileReference(015, GameFile.MegaEvolutions), - new GameFileReference(017, GameFile.PersonalStats), - new GameFileReference(019, GameFile.ItemStats), + new(011, GameFile.MoveStats), + new(012, GameFile.EggMoves), + new(013, GameFile.Learnsets), + new(014, GameFile.Evolutions), + new(015, GameFile.MegaEvolutions), + new(017, GameFile.PersonalStats), + new(019, GameFile.ItemStats), - new GameFileReference(030, GameFile.GameText0), - new GameFileReference(031, GameFile.GameText1), - new GameFileReference(032, GameFile.GameText2), - new GameFileReference(033, GameFile.GameText3), - new GameFileReference(034, GameFile.GameText4), - new GameFileReference(035, GameFile.GameText5), - new GameFileReference(036, GameFile.GameText6), - new GameFileReference(037, GameFile.GameText7), - new GameFileReference(038, GameFile.GameText8), - new GameFileReference(039, GameFile.GameText9), - new GameFileReference(040, GameFile.StoryText0), - new GameFileReference(041, GameFile.StoryText1), - new GameFileReference(042, GameFile.StoryText2), - new GameFileReference(043, GameFile.StoryText3), - new GameFileReference(044, GameFile.StoryText4), - new GameFileReference(045, GameFile.StoryText5), - new GameFileReference(046, GameFile.StoryText6), - new GameFileReference(047, GameFile.StoryText7), - new GameFileReference(048, GameFile.StoryText8), - new GameFileReference(049, GameFile.StoryText9), + new(030, GameFile.GameText0), + new(031, GameFile.GameText1), + new(032, GameFile.GameText2), + new(033, GameFile.GameText3), + new(034, GameFile.GameText4), + new(035, GameFile.GameText5), + new(036, GameFile.GameText6), + new(037, GameFile.GameText7), + new(038, GameFile.GameText8), + new(039, GameFile.GameText9), + new(040, GameFile.StoryText0), + new(041, GameFile.StoryText1), + new(042, GameFile.StoryText2), + new(043, GameFile.StoryText3), + new(044, GameFile.StoryText4), + new(045, GameFile.StoryText5), + new(046, GameFile.StoryText6), + new(047, GameFile.StoryText7), + new(048, GameFile.StoryText8), + new(049, GameFile.StoryText9), - new GameFileReference(077, GameFile.ZoneData), - new GameFileReference(091, GameFile.WorldData), + new(077, GameFile.ZoneData), + new(091, GameFile.WorldData), - new GameFileReference(105, GameFile.TrainerClass), - new GameFileReference(106, GameFile.TrainerData), - new GameFileReference(107, GameFile.TrainerPoke), + new(105, GameFile.TrainerClass), + new(106, GameFile.TrainerData), + new(107, GameFile.TrainerPoke), - new GameFileReference(159, GameFile.EncounterStatic), + new(159, GameFile.EncounterStatic), - new GameFileReference(271, GameFile.Pickup), + new(271, GameFile.Pickup), - new GameFileReference(281, GameFile.FacilityPokeNormal), - new GameFileReference(282, GameFile.FacilityTrainerNormal), - new GameFileReference(283, GameFile.FacilityPokeSuper), - new GameFileReference(284, GameFile.FacilityTrainerSuper), + new(281, GameFile.FacilityPokeNormal), + new(282, GameFile.FacilityTrainerNormal), + new(283, GameFile.FacilityPokeSuper), + new(284, GameFile.FacilityTrainerSuper), }; /// @@ -300,46 +300,46 @@ public static IReadOnlyCollection GetMapping(GameVersion game /// private static readonly GameFileReference[] GG = { - new GameFileReference(GameFile.TrainerData, "bin", "trainer", "trainer_data"), - new GameFileReference(GameFile.TrainerPoke, "bin", "trainer", "trainer_poke"), - new GameFileReference(GameFile.TrainerClass, "bin", "trainer", "trainer_type"), + new(GameFile.TrainerData, "bin", "trainer", "trainer_data"), + new(GameFile.TrainerPoke, "bin", "trainer", "trainer_poke"), + new(GameFile.TrainerClass, "bin", "trainer", "trainer_type"), - new GameFileReference(GameFile.GameText0, 0, "bin", "message", "JPN", "common"), - new GameFileReference(GameFile.GameText1, 1, "bin", "message", "JPN_KANJI", "common"), - new GameFileReference(GameFile.GameText2, 2, "bin", "message", "English", "common"), - new GameFileReference(GameFile.GameText3, 3, "bin", "message", "French", "common"), - new GameFileReference(GameFile.GameText4, 4, "bin", "message", "Italian", "common"), - new GameFileReference(GameFile.GameText5, 5, "bin", "message", "German", "common"), + new(GameFile.GameText0, 0, "bin", "message", "JPN", "common"), + new(GameFile.GameText1, 1, "bin", "message", "JPN_KANJI", "common"), + new(GameFile.GameText2, 2, "bin", "message", "English", "common"), + new(GameFile.GameText3, 3, "bin", "message", "French", "common"), + new(GameFile.GameText4, 4, "bin", "message", "Italian", "common"), + new(GameFile.GameText5, 5, "bin", "message", "German", "common"), // 6 unused lang - new GameFileReference(GameFile.GameText6, 7, "bin", "message", "Spanish", "common"), - new GameFileReference(GameFile.GameText7, 8, "bin", "message", "Korean", "common"), - new GameFileReference(GameFile.GameText8, 9, "bin", "message", "Simp_Chinese", "common"), - new GameFileReference(GameFile.GameText9, 10, "bin", "message", "Trad_Chinese", "common"), + new(GameFile.GameText6, 7, "bin", "message", "Spanish", "common"), + new(GameFile.GameText7, 8, "bin", "message", "Korean", "common"), + new(GameFile.GameText8, 9, "bin", "message", "Simp_Chinese", "common"), + new(GameFile.GameText9, 10, "bin", "message", "Trad_Chinese", "common"), - new GameFileReference(GameFile.StoryText0, 0, "bin", "message", "JPN", "script"), - new GameFileReference(GameFile.StoryText1, 1, "bin", "message", "JPN_KANJI", "script"), - new GameFileReference(GameFile.StoryText2, 2, "bin", "message", "English", "script"), - new GameFileReference(GameFile.StoryText3, 3, "bin", "message", "French", "script"), - new GameFileReference(GameFile.StoryText4, 4, "bin", "message", "Italian", "script"), - new GameFileReference(GameFile.StoryText5, 5, "bin", "message", "German", "script"), + new(GameFile.StoryText0, 0, "bin", "message", "JPN", "script"), + new(GameFile.StoryText1, 1, "bin", "message", "JPN_KANJI", "script"), + new(GameFile.StoryText2, 2, "bin", "message", "English", "script"), + new(GameFile.StoryText3, 3, "bin", "message", "French", "script"), + new(GameFile.StoryText4, 4, "bin", "message", "Italian", "script"), + new(GameFile.StoryText5, 5, "bin", "message", "German", "script"), // 6 unused lang - new GameFileReference(GameFile.StoryText6, 7, "bin", "message", "Spanish", "script"), - new GameFileReference(GameFile.StoryText7, 8, "bin", "message", "Korean", "script"), - new GameFileReference(GameFile.StoryText8, 9, "bin", "message", "Simp_Chinese", "script"), - new GameFileReference(GameFile.StoryText9, 10, "bin", "message", "Trad_Chinese", "script"), + new(GameFile.StoryText6, 7, "bin", "message", "Spanish", "script"), + new(GameFile.StoryText7, 8, "bin", "message", "Korean", "script"), + new(GameFile.StoryText8, 9, "bin", "message", "Simp_Chinese", "script"), + new(GameFile.StoryText9, 10, "bin", "message", "Trad_Chinese", "script"), - new GameFileReference(GameFile.ItemStats, "bin", "pokelib", "item"), - new GameFileReference(GameFile.Evolutions, "bin", "pokelib", "evolution"), - new GameFileReference(GameFile.PersonalStats, "bin", "pokelib", "personal"), - new GameFileReference(GameFile.MegaEvolutions, "bin", "pokelib", "mega_evolution"), - new GameFileReference(GameFile.MoveStats, ContainerType.Mini, "bin", "pokelib", "waza", "waza_data.bin"), - new GameFileReference(GameFile.EncounterStatic, ContainerType.SingleFile, "bin", "script_event_data", "event_encount.bin"), - new GameFileReference(GameFile.EncounterTrade, ContainerType.SingleFile, "bin", "script_event_data", "field_trade_data.bin"), - new GameFileReference(GameFile.EncounterGift, ContainerType.SingleFile, "bin", "script_event_data", "add_poke.bin"), - new GameFileReference(GameFile.Learnsets, ContainerType.GFPack, "bin", "archive", "waza_oboe.gfpak"), + new(GameFile.ItemStats, "bin", "pokelib", "item"), + new(GameFile.Evolutions, "bin", "pokelib", "evolution"), + new(GameFile.PersonalStats, "bin", "pokelib", "personal"), + new(GameFile.MegaEvolutions, "bin", "pokelib", "mega_evolution"), + new(GameFile.MoveStats, ContainerType.Mini, "bin", "pokelib", "waza", "waza_data.bin"), + new(GameFile.EncounterStatic, ContainerType.SingleFile, "bin", "script_event_data", "event_encount.bin"), + new(GameFile.EncounterTrade, ContainerType.SingleFile, "bin", "script_event_data", "field_trade_data.bin"), + new(GameFile.EncounterGift, ContainerType.SingleFile, "bin", "script_event_data", "add_poke.bin"), + new(GameFile.Learnsets, ContainerType.GFPack, "bin", "archive", "waza_oboe.gfpak"), - new GameFileReference(GameFile.WildData1, ContainerType.SingleFile, "bin", "field", "param", "encount", "encount_data_p.bin"), - new GameFileReference(GameFile.WildData2, ContainerType.SingleFile, "bin", "field", "param", "encount", "encount_data_e.bin"), + new(GameFile.WildData1, ContainerType.SingleFile, "bin", "field", "param", "encount", "encount_data_p.bin"), + new(GameFile.WildData2, ContainerType.SingleFile, "bin", "field", "param", "encount", "encount_data_e.bin"), // Cutscenes bin\demo // Models bin\archive\pokemon @@ -351,51 +351,51 @@ public static IReadOnlyCollection GetMapping(GameVersion game /// private static readonly GameFileReference[] SW = { - new GameFileReference(GameFile.TrainerData, "bin", "trainer", "trainer_data"), - new GameFileReference(GameFile.TrainerPoke, "bin", "trainer", "trainer_poke"), - new GameFileReference(GameFile.TrainerClass, "bin", "trainer", "trainer_type"), + new(GameFile.TrainerData, "bin", "trainer", "trainer_data"), + new(GameFile.TrainerPoke, "bin", "trainer", "trainer_poke"), + new(GameFile.TrainerClass, "bin", "trainer", "trainer_type"), - new GameFileReference(GameFile.GameText0, 0, "bin", "message", "JPN", "common"), - new GameFileReference(GameFile.GameText1, 1, "bin", "message", "JPN_KANJI", "common"), - new GameFileReference(GameFile.GameText2, 2, "bin", "message", "English", "common"), - new GameFileReference(GameFile.GameText3, 3, "bin", "message", "French", "common"), - new GameFileReference(GameFile.GameText4, 4, "bin", "message", "Italian", "common"), - new GameFileReference(GameFile.GameText5, 5, "bin", "message", "German", "common"), + new(GameFile.GameText0, 0, "bin", "message", "JPN", "common"), + new(GameFile.GameText1, 1, "bin", "message", "JPN_KANJI", "common"), + new(GameFile.GameText2, 2, "bin", "message", "English", "common"), + new(GameFile.GameText3, 3, "bin", "message", "French", "common"), + new(GameFile.GameText4, 4, "bin", "message", "Italian", "common"), + new(GameFile.GameText5, 5, "bin", "message", "German", "common"), // 6 unused lang - new GameFileReference(GameFile.GameText6, 7, "bin", "message", "Spanish", "common"), - new GameFileReference(GameFile.GameText7, 8, "bin", "message", "Korean", "common"), - new GameFileReference(GameFile.GameText8, 9, "bin", "message", "Simp_Chinese", "common"), - new GameFileReference(GameFile.GameText9, 10, "bin", "message", "Trad_Chinese", "common"), + new(GameFile.GameText6, 7, "bin", "message", "Spanish", "common"), + new(GameFile.GameText7, 8, "bin", "message", "Korean", "common"), + new(GameFile.GameText8, 9, "bin", "message", "Simp_Chinese", "common"), + new(GameFile.GameText9, 10, "bin", "message", "Trad_Chinese", "common"), - new GameFileReference(GameFile.StoryText0, 0, "bin", "message", "JPN", "script"), - new GameFileReference(GameFile.StoryText1, 1, "bin", "message", "JPN_KANJI", "script"), - new GameFileReference(GameFile.StoryText2, 2, "bin", "message", "English", "script"), - new GameFileReference(GameFile.StoryText3, 3, "bin", "message", "French", "script"), - new GameFileReference(GameFile.StoryText4, 4, "bin", "message", "Italian", "script"), - new GameFileReference(GameFile.StoryText5, 5, "bin", "message", "German", "script"), + new(GameFile.StoryText0, 0, "bin", "message", "JPN", "script"), + new(GameFile.StoryText1, 1, "bin", "message", "JPN_KANJI", "script"), + new(GameFile.StoryText2, 2, "bin", "message", "English", "script"), + new(GameFile.StoryText3, 3, "bin", "message", "French", "script"), + new(GameFile.StoryText4, 4, "bin", "message", "Italian", "script"), + new(GameFile.StoryText5, 5, "bin", "message", "German", "script"), // 6 unused lang - new GameFileReference(GameFile.StoryText6, 7, "bin", "message", "Spanish", "script"), - new GameFileReference(GameFile.StoryText7, 8, "bin", "message", "Korean", "script"), - new GameFileReference(GameFile.StoryText8, 9, "bin", "message", "Simp_Chinese", "script"), - new GameFileReference(GameFile.StoryText9, 10, "bin", "message", "Trad_Chinese", "script"), + new(GameFile.StoryText6, 7, "bin", "message", "Spanish", "script"), + new(GameFile.StoryText7, 8, "bin", "message", "Korean", "script"), + new(GameFile.StoryText8, 9, "bin", "message", "Simp_Chinese", "script"), + new(GameFile.StoryText9, 10, "bin", "message", "Trad_Chinese", "script"), - new GameFileReference(GameFile.ItemStats, ContainerType.SingleFile, "bin", "pml", "item", "item.dat"), - new GameFileReference(GameFile.Evolutions, "bin", "pml", "evolution"), - new GameFileReference(GameFile.EggMoves, "bin", "pml", "tamagowaza"), - new GameFileReference(GameFile.PersonalStats, "bin", "pml", "personal"), - new GameFileReference(GameFile.MoveStats, "bin", "pml", "waza"), - new GameFileReference(GameFile.EncounterStatic, ContainerType.SingleFile, "bin", "script_event_data", "event_encount_data.bin"), - new GameFileReference(GameFile.EncounterTrade, ContainerType.SingleFile, "bin", "script_event_data", "field_trade.bin"), - new GameFileReference(GameFile.EncounterGift, ContainerType.SingleFile, "bin", "script_event_data", "add_poke.bin"), - new GameFileReference(GameFile.Learnsets, ContainerType.SingleFile, "bin", "pml", "waza_oboe", "wazaoboe_total.bin"), + new(GameFile.ItemStats, ContainerType.SingleFile, "bin", "pml", "item", "item.dat"), + new(GameFile.Evolutions, "bin", "pml", "evolution"), + new(GameFile.EggMoves, "bin", "pml", "tamagowaza"), + new(GameFile.PersonalStats, "bin", "pml", "personal"), + new(GameFile.MoveStats, "bin", "pml", "waza"), + new(GameFile.EncounterStatic, ContainerType.SingleFile, "bin", "script_event_data", "event_encount_data.bin"), + new(GameFile.EncounterTrade, ContainerType.SingleFile, "bin", "script_event_data", "field_trade.bin"), + new(GameFile.EncounterGift, ContainerType.SingleFile, "bin", "script_event_data", "add_poke.bin"), + new(GameFile.Learnsets, ContainerType.SingleFile, "bin", "pml", "waza_oboe", "wazaoboe_total.bin"), - new GameFileReference(GameFile.FacilityPokeNormal, ContainerType.SingleFile, "bin", "field", "param", "battle_tower", "battle_tower_poke_table.bin"), - new GameFileReference(GameFile.FacilityTrainerNormal, ContainerType.SingleFile, "bin", "field", "param", "battle_tower", "battle_tower_trainer_table.bin"), + new(GameFile.FacilityPokeNormal, ContainerType.SingleFile, "bin", "field", "param", "battle_tower", "battle_tower_poke_table.bin"), + new(GameFile.FacilityTrainerNormal, ContainerType.SingleFile, "bin", "field", "param", "battle_tower", "battle_tower_trainer_table.bin"), - new GameFileReference(GameFile.WildData, ContainerType.SingleFile, "bin", "archive", "field", "resident", "data_table.gfpak"), - new GameFileReference(GameFile.NestData, ContainerType.SingleFile, "bin", "archive", "field", "resident", "data_table.gfpak"), + new(GameFile.WildData, ContainerType.SingleFile, "bin", "archive", "field", "resident", "data_table.gfpak"), + new(GameFile.NestData, ContainerType.SingleFile, "bin", "archive", "field", "resident", "data_table.gfpak"), - new GameFileReference(GameFile.DynamaxDens, ContainerType.SingleFile, "bin", "appli", "chika", "data_table", "underground_exploration_poke.bin"), + new(GameFile.DynamaxDens, ContainerType.SingleFile, "bin", "appli", "chika", "data_table", "underground_exploration_poke.bin"), // Cutscenes bin\demo // Models bin\archive\pokemon diff --git a/pkNX.Game/GameManager.cs b/pkNX.Game/GameManager.cs index 29a1e006..7bba8d55 100644 --- a/pkNX.Game/GameManager.cs +++ b/pkNX.Game/GameManager.cs @@ -113,7 +113,7 @@ public static GameManager GetManager(GameLocation loc, int language) { return loc.Game switch { - GameVersion.GG => (GameManager)new GameManagerGG(loc, language), + GameVersion.GG => new GameManagerGG(loc, language), GameVersion.SW => new GameManagerSWSH(loc, language), GameVersion.SH => new GameManagerSWSH(loc, language), _ => throw new ArgumentException(nameof(loc.Game)) diff --git a/pkNX.Game/GameManagerSWSH.cs b/pkNX.Game/GameManagerSWSH.cs index 4cd8a8d6..03d48b0b 100644 --- a/pkNX.Game/GameManagerSWSH.cs +++ b/pkNX.Game/GameManagerSWSH.cs @@ -9,16 +9,17 @@ namespace pkNX.Game public class GameManagerSWSH : GameManager { public GameManagerSWSH(GameLocation rom, int language) : base(rom, language) { } - private GameVersion ActualGame; + private GameVersion ActualGame = GameVersion.SW; public string TitleID => ActualGame == GameVersion.SW ? Sword : Shield; private const string Sword = "0100ABF008968000"; private const string Shield = "01008DB008C2C000"; + public bool IsSword { get; set; } = true; + protected override void SetMitm() { var basePath = Path.GetDirectoryName(ROM.RomFS); - const bool shield = false; // todo - ActualGame = shield ? GameVersion.SH : GameVersion.SW; + ActualGame = !IsSword ? GameVersion.SH : GameVersion.SW; var redirect = Path.Combine(basePath, TitleID); FileMitm.SetRedirect(basePath, redirect); } diff --git a/pkNX.Game/Misc/SWSHInfo.cs b/pkNX.Game/Misc/SWSHInfo.cs index c7af87ef..37989b57 100644 --- a/pkNX.Game/Misc/SWSHInfo.cs +++ b/pkNX.Game/Misc/SWSHInfo.cs @@ -342,7 +342,7 @@ public static class SWSHInfo { 0x909172718CA9AB5E, "Insular Sea" }, { 0x909175718CA9B077, "Honeycalm Sea" }, { 0x908DEC718CA691D5, "Honeycalm Island" }, - + { 0x525D03DF0309D804, "Fields of Honor" }, { 0xB0621052994A5089, "Fields of Honor (Surfing)" }, { 0x91B1D1436BAF5871, "Fields of Honor (Beach)" }, diff --git a/pkNX.Game/Text/TextManager.cs b/pkNX.Game/Text/TextManager.cs index 76bf33a2..07f79d4c 100644 --- a/pkNX.Game/Text/TextManager.cs +++ b/pkNX.Game/Text/TextManager.cs @@ -11,7 +11,7 @@ public class TextManager private readonly TextConfig Config; private readonly IReadOnlyCollection References; - private readonly Dictionary Cache = new Dictionary(); + private readonly Dictionary Cache = new(); public void ClearCache() => Cache.Clear(); diff --git a/pkNX.Game/Text/TextMapping.cs b/pkNX.Game/Text/TextMapping.cs index 7388010e..825ed7ae 100644 --- a/pkNX.Game/Text/TextMapping.cs +++ b/pkNX.Game/Text/TextMapping.cs @@ -27,149 +27,149 @@ public static IReadOnlyCollection GetMapping(GameVersion game) private static readonly TextReference[] XY = { - new TextReference(005, TextName.Forms), - new TextReference(013, TextName.MoveNames), - new TextReference(015, TextName.MoveFlavor), - new TextReference(017, TextName.Types), - new TextReference(020, TextName.TrainerClasses), - new TextReference(021, TextName.TrainerNames), - new TextReference(022, TextName.TrainerText), - new TextReference(034, TextName.AbilityNames), - new TextReference(047, TextName.Natures), - new TextReference(072, TextName.metlist_00000), - new TextReference(080, TextName.SpeciesNames), - new TextReference(096, TextName.ItemNames), - new TextReference(099, TextName.ItemFlavor), - new TextReference(130, TextName.MaisonTrainerNames), - new TextReference(131, TextName.SuperTrainerNames), - new TextReference(141, TextName.OPowerFlavor), + new(005, TextName.Forms), + new(013, TextName.MoveNames), + new(015, TextName.MoveFlavor), + new(017, TextName.Types), + new(020, TextName.TrainerClasses), + new(021, TextName.TrainerNames), + new(022, TextName.TrainerText), + new(034, TextName.AbilityNames), + new(047, TextName.Natures), + new(072, TextName.metlist_00000), + new(080, TextName.SpeciesNames), + new(096, TextName.ItemNames), + new(099, TextName.ItemFlavor), + new(130, TextName.MaisonTrainerNames), + new(131, TextName.SuperTrainerNames), + new(141, TextName.OPowerFlavor), }; private static readonly TextReference[] AO = { - new TextReference(005, TextName.Forms), - new TextReference(014, TextName.MoveNames), - new TextReference(016, TextName.MoveFlavor), - new TextReference(018, TextName.Types), - new TextReference(021, TextName.TrainerClasses), - new TextReference(022, TextName.TrainerNames), - new TextReference(023, TextName.TrainerText), - new TextReference(037, TextName.AbilityNames), - new TextReference(051, TextName.Natures), - new TextReference(090, TextName.metlist_00000), - new TextReference(098, TextName.SpeciesNames), - new TextReference(114, TextName.ItemNames), - new TextReference(117, TextName.ItemFlavor), - new TextReference(153, TextName.MaisonTrainerNames), - new TextReference(154, TextName.SuperTrainerNames), - new TextReference(165, TextName.OPowerFlavor), + new(005, TextName.Forms), + new(014, TextName.MoveNames), + new(016, TextName.MoveFlavor), + new(018, TextName.Types), + new(021, TextName.TrainerClasses), + new(022, TextName.TrainerNames), + new(023, TextName.TrainerText), + new(037, TextName.AbilityNames), + new(051, TextName.Natures), + new(090, TextName.metlist_00000), + new(098, TextName.SpeciesNames), + new(114, TextName.ItemNames), + new(117, TextName.ItemFlavor), + new(153, TextName.MaisonTrainerNames), + new(154, TextName.SuperTrainerNames), + new(165, TextName.OPowerFlavor), }; private static readonly TextReference[] SMDEMO = { - new TextReference(020, TextName.ItemFlavor), - new TextReference(021, TextName.ItemNames), - new TextReference(026, TextName.SpeciesNames), - new TextReference(030, TextName.metlist_00000), - new TextReference(044, TextName.Forms), - new TextReference(044, TextName.Natures), - new TextReference(046, TextName.AbilityNames), - new TextReference(049, TextName.TrainerText), - new TextReference(050, TextName.TrainerNames), - new TextReference(051, TextName.TrainerClasses), - new TextReference(052, TextName.Types), - new TextReference(054, TextName.MoveFlavor), - new TextReference(055, TextName.MoveNames), + new(020, TextName.ItemFlavor), + new(021, TextName.ItemNames), + new(026, TextName.SpeciesNames), + new(030, TextName.metlist_00000), + new(044, TextName.Forms), + new(044, TextName.Natures), + new(046, TextName.AbilityNames), + new(049, TextName.TrainerText), + new(050, TextName.TrainerNames), + new(051, TextName.TrainerClasses), + new(052, TextName.Types), + new(054, TextName.MoveFlavor), + new(055, TextName.MoveNames), }; private static readonly TextReference[] SM = { - new TextReference(035, TextName.ItemFlavor), - new TextReference(036, TextName.ItemNames), - new TextReference(055, TextName.SpeciesNames), - new TextReference(067, TextName.metlist_00000), - new TextReference(086, TextName.BattleRoyalNames), - new TextReference(087, TextName.Natures), - new TextReference(096, TextName.AbilityNames), - new TextReference(099, TextName.BattleTreeNames), - new TextReference(104, TextName.TrainerText), - new TextReference(105, TextName.TrainerNames), - new TextReference(106, TextName.TrainerClasses), - new TextReference(107, TextName.Types), - new TextReference(112, TextName.MoveFlavor), - new TextReference(113, TextName.MoveNames), - new TextReference(114, TextName.Forms), - new TextReference(116, TextName.SpeciesClassifications), - new TextReference(119, TextName.PokedexEntry1), - new TextReference(120, TextName.PokedexEntry2) + new(035, TextName.ItemFlavor), + new(036, TextName.ItemNames), + new(055, TextName.SpeciesNames), + new(067, TextName.metlist_00000), + new(086, TextName.BattleRoyalNames), + new(087, TextName.Natures), + new(096, TextName.AbilityNames), + new(099, TextName.BattleTreeNames), + new(104, TextName.TrainerText), + new(105, TextName.TrainerNames), + new(106, TextName.TrainerClasses), + new(107, TextName.Types), + new(112, TextName.MoveFlavor), + new(113, TextName.MoveNames), + new(114, TextName.Forms), + new(116, TextName.SpeciesClassifications), + new(119, TextName.PokedexEntry1), + new(120, TextName.PokedexEntry2) }; private static readonly TextReference[] USUM = { - new TextReference(039, TextName.ItemFlavor), - new TextReference(040, TextName.ItemNames), - new TextReference(060, TextName.SpeciesNames), - new TextReference(072, TextName.metlist_00000), - new TextReference(091, TextName.BattleRoyalNames), - new TextReference(092, TextName.Natures), - new TextReference(101, TextName.AbilityNames), - new TextReference(104, TextName.BattleTreeNames), - new TextReference(109, TextName.TrainerText), - new TextReference(110, TextName.TrainerNames), - new TextReference(111, TextName.TrainerClasses), - new TextReference(112, TextName.Types), - new TextReference(117, TextName.MoveFlavor), - new TextReference(118, TextName.MoveNames), - new TextReference(119, TextName.Forms), - new TextReference(121, TextName.SpeciesClassifications), - new TextReference(124, TextName.PokedexEntry1), - new TextReference(125, TextName.PokedexEntry2) + new(039, TextName.ItemFlavor), + new(040, TextName.ItemNames), + new(060, TextName.SpeciesNames), + new(072, TextName.metlist_00000), + new(091, TextName.BattleRoyalNames), + new(092, TextName.Natures), + new(101, TextName.AbilityNames), + new(104, TextName.BattleTreeNames), + new(109, TextName.TrainerText), + new(110, TextName.TrainerNames), + new(111, TextName.TrainerClasses), + new(112, TextName.Types), + new(117, TextName.MoveFlavor), + new(118, TextName.MoveNames), + new(119, TextName.Forms), + new(121, TextName.SpeciesClassifications), + new(124, TextName.PokedexEntry1), + new(125, TextName.PokedexEntry2) }; private static readonly TextReference[] GG = { - new TextReference("iteminfo.dat", TextName.ItemFlavor), - new TextReference("itemname.dat", TextName.ItemNames), - new TextReference("monsname.dat", TextName.SpeciesNames), - new TextReference("place_name.dat", TextName.metlist_00000), - new TextReference("seikaku.dat", TextName.Natures), - new TextReference("tokusei.dat", TextName.AbilityNames), - new TextReference("tokuseiinfo.dat", TextName.AbilityFlavor), - new TextReference("trname.dat", TextName.TrainerNames), - new TextReference("trtype.dat", TextName.TrainerClasses), - new TextReference("trmsg.dat", TextName.TrainerText), - new TextReference("typename.dat", TextName.Types), - new TextReference("wazainfo.dat", TextName.MoveFlavor), - new TextReference("wazaname.dat", TextName.MoveNames), - new TextReference("zkn_form.dat", TextName.Forms), - new TextReference("zkn_type.dat", TextName.SpeciesClassifications), - new TextReference("zukan_comment_A.dat", TextName.PokedexEntry1), + new("iteminfo.dat", TextName.ItemFlavor), + new("itemname.dat", TextName.ItemNames), + new("monsname.dat", TextName.SpeciesNames), + new("place_name.dat", TextName.metlist_00000), + new("seikaku.dat", TextName.Natures), + new("tokusei.dat", TextName.AbilityNames), + new("tokuseiinfo.dat", TextName.AbilityFlavor), + new("trname.dat", TextName.TrainerNames), + new("trtype.dat", TextName.TrainerClasses), + new("trmsg.dat", TextName.TrainerText), + new("typename.dat", TextName.Types), + new("wazainfo.dat", TextName.MoveFlavor), + new("wazaname.dat", TextName.MoveNames), + new("zkn_form.dat", TextName.Forms), + new("zkn_type.dat", TextName.SpeciesClassifications), + new("zukan_comment_A.dat", TextName.PokedexEntry1), }; private static readonly TextReference[] SWSH = { - new TextReference("iteminfo.dat", TextName.ItemFlavor), - new TextReference("itemname.dat", TextName.ItemNames), - new TextReference("monsname.dat", TextName.SpeciesNames), - new TextReference("place_name_indirect.dat", TextName.metlist_00000), - new TextReference("place_name_spe.dat", TextName.metlist_30000), - new TextReference("place_name_out.dat", TextName.metlist_40000), - new TextReference("place_name_per.dat", TextName.metlist_60000), - new TextReference("seikaku.dat", TextName.Natures), - new TextReference("tokusei.dat", TextName.AbilityNames), - new TextReference("tokuseiinfo.dat", TextName.AbilityFlavor), - new TextReference("trname.dat", TextName.TrainerNames), - new TextReference("trtype.dat", TextName.TrainerClasses), - new TextReference("trmsg.dat", TextName.TrainerText), - new TextReference("typename.dat", TextName.Types), - new TextReference("wazainfo.dat", TextName.MoveFlavor), - new TextReference("wazaname.dat", TextName.MoveNames), - new TextReference("zkn_form.dat", TextName.Forms), - new TextReference("zkn_type.dat", TextName.SpeciesClassifications), - new TextReference("zukan_comment_A.dat", TextName.PokedexEntry1), - new TextReference("zukan_comment_B.dat", TextName.PokedexEntry2), - new TextReference("ribbon.dat", TextName.RibbonMark), - new TextReference("poke_memory_feeling.dat", TextName.MemoryFeelings), + new("iteminfo.dat", TextName.ItemFlavor), + new("itemname.dat", TextName.ItemNames), + new("monsname.dat", TextName.SpeciesNames), + new("place_name_indirect.dat", TextName.metlist_00000), + new("place_name_spe.dat", TextName.metlist_30000), + new("place_name_out.dat", TextName.metlist_40000), + new("place_name_per.dat", TextName.metlist_60000), + new("seikaku.dat", TextName.Natures), + new("tokusei.dat", TextName.AbilityNames), + new("tokuseiinfo.dat", TextName.AbilityFlavor), + new("trname.dat", TextName.TrainerNames), + new("trtype.dat", TextName.TrainerClasses), + new("trmsg.dat", TextName.TrainerText), + new("typename.dat", TextName.Types), + new("wazainfo.dat", TextName.MoveFlavor), + new("wazaname.dat", TextName.MoveNames), + new("zkn_form.dat", TextName.Forms), + new("zkn_type.dat", TextName.SpeciesClassifications), + new("zukan_comment_A.dat", TextName.PokedexEntry1), + new("zukan_comment_B.dat", TextName.PokedexEntry2), + new("ribbon.dat", TextName.RibbonMark), + new("poke_memory_feeling.dat", TextName.MemoryFeelings), }; } } \ No newline at end of file diff --git a/pkNX.Randomization/Randomizers/FormRandomizer.cs b/pkNX.Randomization/Randomizers/FormRandomizer.cs index 0db291f3..7342017e 100644 --- a/pkNX.Randomization/Randomizers/FormRandomizer.cs +++ b/pkNX.Randomization/Randomizers/FormRandomizer.cs @@ -16,8 +16,7 @@ public FormRandomizer(PersonalTable t) public int GetRandomForme(int species, bool mega, bool fused, bool alola, bool galar, PersonalInfo[] stats = null) { - if (stats == null) - stats = Personal.Table; + stats ??= Personal.Table; if (stats[species].FormeCount <= 1) return 0; bool IsGen6 = Personal.MaxSpeciesID == 721; diff --git a/pkNX.Randomization/Randomizers/MoveRandomizer.cs b/pkNX.Randomization/Randomizers/MoveRandomizer.cs index a8998e20..0b6e672d 100644 --- a/pkNX.Randomization/Randomizers/MoveRandomizer.cs +++ b/pkNX.Randomization/Randomizers/MoveRandomizer.cs @@ -139,7 +139,7 @@ private static void ReorderMovesPower(IList moves, IReadOnlyList move 141, // Leech Life }; - private static readonly GenericRandomizer first = new GenericRandomizer(firstMoves); + private static readonly GenericRandomizer first = new(firstMoves); public static int GetRandomFirstMoveAny() { diff --git a/pkNX.Randomization/Randomizers/TrainerRandomizer.cs b/pkNX.Randomization/Randomizers/TrainerRandomizer.cs index 965128a1..ed0b57f5 100644 --- a/pkNX.Randomization/Randomizers/TrainerRandomizer.cs +++ b/pkNX.Randomization/Randomizers/TrainerRandomizer.cs @@ -178,11 +178,9 @@ private void RandomizeSpecForm(TrainerPoke7b pk, int type) pk.Form = 0; // allow it to Mega Evolve naturally return; } - else - { - pk.Species = RandSpec.GetRandomSpeciesType(pk.Species, type); - pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, Settings.AllowRandomFusions, true, false, Personal.Table); - } + + pk.Species = RandSpec.GetRandomSpeciesType(pk.Species, type); + pk.Form = RandForm.GetRandomForme(pk.Species, Settings.AllowRandomMegaForms, Settings.AllowRandomFusions, true, false, Personal.Table); } private void TryForceEvolve(IPokeData pk) diff --git a/pkNX.Randomization/Util.cs b/pkNX.Randomization/Util.cs index bff16754..3ff85270 100644 --- a/pkNX.Randomization/Util.cs +++ b/pkNX.Randomization/Util.cs @@ -6,7 +6,7 @@ namespace pkNX.Randomization { public static class Util { - public static Random Random { get; private set; } = new Random(); + public static Random Random { get; private set; } = new(); public static void ReseedRand(int seed) { diff --git a/pkNX.Sprites/FormConverter.cs b/pkNX.Sprites/FormConverter.cs index 0d4eef5f..d2e62e39 100644 --- a/pkNX.Sprites/FormConverter.cs +++ b/pkNX.Sprites/FormConverter.cs @@ -30,18 +30,13 @@ public static int GetTotemBaseForm(int species, int form) public static bool IsValidOutOfBoundsForme(int species, int form, int generation) { - switch ((Species)species) + return (Species) species switch { - case Unown: - return form < (generation == 2 ? 26 : 28); // A-Z : A-Z?! - case Mothim: // Wormadam base form is kept - return form < 3; - case Scatterbug: - case Spewpa: // Vivillon Pre-evolutions - return form < 18; - default: - return false; - } + Unown => form < (generation == 2 ? 26 : 28), // A-Z : A-Z?! + Mothim => form < 3, // Wormadam base form is kept + Scatterbug or Spewpa => form < 18, + _ => false + }; } /// @@ -58,7 +53,7 @@ public static bool HasFormSelection(PersonalInfo pi, int species) return count > 1; } - private static readonly HashSet HasFormeValuesNotIndicatedByPersonal = new HashSet + private static readonly HashSet HasFormeValuesNotIndicatedByPersonal = new() { (int)Unown, (int)Mothim, // Burmy forme carried over, not cleared diff --git a/pkNX.Sprites/ImageUtil.cs b/pkNX.Sprites/ImageUtil.cs index 983f2736..1282852e 100644 --- a/pkNX.Sprites/ImageUtil.cs +++ b/pkNX.Sprites/ImageUtil.cs @@ -21,9 +21,9 @@ public static Bitmap LayerImage(Image baseLayer, Image overLayer, int x, int y) { if (baseLayer is null) return (Bitmap)overLayer; - Bitmap img = new Bitmap(baseLayer); - using (Graphics gr = Graphics.FromImage(img)) - gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height); + Bitmap img = new(baseLayer); + using Graphics gr = Graphics.FromImage(img); + gr.DrawImage(overLayer, x, y, overLayer.Width, overLayer.Height); return img; } diff --git a/pkNX.Sprites/SpriteBuilder.cs b/pkNX.Sprites/SpriteBuilder.cs index ae83aed1..8c3e4717 100644 --- a/pkNX.Sprites/SpriteBuilder.cs +++ b/pkNX.Sprites/SpriteBuilder.cs @@ -63,7 +63,7 @@ private Image GetBaseImage(int species, int form, int gender, bool shiny, bool g return img ?? GetBaseImageFallback(species, form, gender, shiny, gmax, generation); } - private Image GetBaseImageTotem(int species, int form, int gender, bool shiny, bool gmax, int generation) + private Image? GetBaseImageTotem(int species, int form, int gender, bool shiny, bool gmax, int generation) { var baseform = FormConverter.GetTotemBaseForm(species, form); var baseImage = GetBaseImageDefault(species, baseform, gender, shiny, gmax, generation); @@ -72,10 +72,10 @@ private Image GetBaseImageTotem(int species, int form, int gender, bool shiny, b return ImageUtil.ToGrayscale(baseImage); } - private Image GetBaseImageDefault(int species, int form, int gender, bool shiny, bool gmax, int generation) + private Image? GetBaseImageDefault(int species, int form, int gender, bool shiny, bool gmax, int generation) { var file = GetSpriteAll(species, form, gender, shiny, gmax, generation); - return (Image)Resources.ResourceManager.GetObject(file); + return (Image?)Resources.ResourceManager.GetObject(file); } private Image GetBaseImageFallback(int species, int form, int gender, bool shiny, bool gmax, int generation) @@ -88,7 +88,7 @@ private Image GetBaseImageFallback(int species, int form, int gender, bool shiny } // try again without form - var baseImage = (Image)Resources.ResourceManager.GetObject(GetSpriteStringSpeciesOnly(species)); + var baseImage = (Image?)Resources.ResourceManager.GetObject(GetSpriteStringSpeciesOnly(species)); if (baseImage == null) // failed again return Unknown; return ImageUtil.LayerImage(baseImage, Unknown, 0, 0, UnknownFormTransparency); @@ -96,7 +96,7 @@ private Image GetBaseImageFallback(int species, int form, int gender, bool shiny private Image LayerOverImageItem(Image baseImage, int item, int generation) { - Image itemimg = (Image)Resources.ResourceManager.GetObject(GetItemResourceName(item)) ?? Resources.bitem_unk; + Image itemimg = (Image?)Resources.ResourceManager.GetObject(GetItemResourceName(item)) ?? Resources.bitem_unk; if (328 <= item && item <= 419) // gen2/3/4 TM itemimg = Resources.bitem_tm; else if (1130 <= item && item <= 1229) // Gen8 TR diff --git a/pkNX.Sprites/SpriteName.cs b/pkNX.Sprites/SpriteName.cs index 01ff2066..4476c011 100644 --- a/pkNX.Sprites/SpriteName.cs +++ b/pkNX.Sprites/SpriteName.cs @@ -53,7 +53,9 @@ public static string GetResourceStringSprite(int species, int form, int gender, gender = 2; // Cosplay Pikachu gift can only be Female, but personal entries are set to be either Gender } else if (form == 8) + { sb.Append(GGStarter); + } } else if (species == (int)Species.Eevee) { @@ -79,7 +81,7 @@ public static string GetResourceStringSprite(int species, int form, int gender, /// /// Species that show their default Species sprite regardless of current form /// - public static readonly HashSet SpeciesDefaultFormSprite = new HashSet + public static readonly HashSet SpeciesDefaultFormSprite = new() { (int)Species.Mothim, (int)Species.Scatterbug, @@ -94,7 +96,7 @@ public static string GetResourceStringSprite(int species, int form, int gender, /// /// Species that show a Gender specific Sprite /// - public static readonly HashSet SpeciesGenderedSprite = new HashSet + public static readonly HashSet SpeciesGenderedSprite = new() { (int)Species.Pikachu, (int)Species.Hippopotas, diff --git a/pkNX.Sprites/SpriteUtil.cs b/pkNX.Sprites/SpriteUtil.cs index c5d8e9a3..af4d28ca 100644 --- a/pkNX.Sprites/SpriteUtil.cs +++ b/pkNX.Sprites/SpriteUtil.cs @@ -5,14 +5,14 @@ namespace pkNX.Sprites { public static class SpriteUtil { - public static readonly SpriteBuilder3040 SB17 = new SpriteBuilder3040(); - public static readonly SpriteBuilder5668 SB8 = new SpriteBuilder5668(); + public static readonly SpriteBuilder3040 SB17 = new(); + public static readonly SpriteBuilder5668 SB8 = new(); public static SpriteBuilder Spriter { get; set; } = SB17; public static Image GetBallSprite(int ball) { string resource = SpriteName.GetResourceStringBall(ball); - return (Bitmap)Resources.ResourceManager.GetObject(resource) ?? Resources._ball4; // Poké Ball (default) + return (Bitmap?)Resources.ResourceManager.GetObject(resource) ?? Resources._ball4; // Poké Ball (default) } public static Image GetSprite(int species, int form, int gender, int item, bool isegg, bool shiny, bool gmax, int generation = -1) diff --git a/pkNX.Structures/Dumpers/PersonalDumper.cs b/pkNX.Structures/Dumpers/PersonalDumper.cs index 95e7b967..d8df4742 100644 --- a/pkNX.Structures/Dumpers/PersonalDumper.cs +++ b/pkNX.Structures/Dumpers/PersonalDumper.cs @@ -74,7 +74,7 @@ public class PersonalDumper public IReadOnlyList> MoveSpeciesLearn { get; private set; } - public PersonalDumperSettings Settings = new PersonalDumperSettings(); + public PersonalDumperSettings Settings = new(); public List Dump(PersonalTable table) { @@ -104,7 +104,7 @@ public void AddDump(List lines, PersonalTable table, int species, int fo private void AddDump(List lines, PersonalInfo pi, int entry, string name, int species, int form) { - if (pi is PersonalInfoSWSH s && !s.IsPresentInGame) + if (pi is PersonalInfoSWSH {IsPresentInGame: false}) return; var specCode = pi.FormeCount > 1 ? $"{Species[species]}-{form}" : $"{Species[species]}"; diff --git a/pkNX.Structures/EggMove/EggMoves6.cs b/pkNX.Structures/EggMove/EggMoves6.cs index 61c8ecb8..eac40d9b 100644 --- a/pkNX.Structures/EggMove/EggMoves6.cs +++ b/pkNX.Structures/EggMove/EggMoves6.cs @@ -4,7 +4,7 @@ namespace pkNX.Structures { public sealed class EggMoves6 : EggMoves { - private static readonly EggMoves6 None = new EggMoves6(Array.Empty()); + private static readonly EggMoves6 None = new(Array.Empty()); private EggMoves6(int[] moves) : base(moves) { } diff --git a/pkNX.Structures/EggMove/EggMoves7.cs b/pkNX.Structures/EggMove/EggMoves7.cs index 0009879f..683623e5 100644 --- a/pkNX.Structures/EggMove/EggMoves7.cs +++ b/pkNX.Structures/EggMove/EggMoves7.cs @@ -4,7 +4,7 @@ namespace pkNX.Structures { public sealed class EggMoves7 : EggMoves { - private static readonly EggMoves7 None = new EggMoves7(Array.Empty()); + private static readonly EggMoves7 None = new(Array.Empty()); public readonly int FormTableIndex; private EggMoves7(int[] moves, int formIndex = 0) : base(moves) => FormTableIndex = formIndex; diff --git a/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs b/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs index afae9fe4..b3b1b0dd 100644 --- a/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs +++ b/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs @@ -8,7 +8,7 @@ public class EncounterGift6XY : EncounterGift public EncounterGift6XY(byte[] data = null) : base(data ?? new byte[SIZE]) { } public override Species Species { get => (Species)BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } - public int _02 { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); } + public int Unk_02 { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); } public override int Form { get => Data[0x04]; set => Data[0x04] = (byte) value; } public override int Level { get => Data[0x05]; set => Data[0x05] = (byte)value; } public override int Ability { get => (sbyte)Data[0x06]; set => Data[0x06] = (byte)value; } @@ -16,9 +16,9 @@ public class EncounterGift6XY : EncounterGift public override Shiny Shiny { get => (Shiny)Data[0x08]; set => Data[0x08] = (byte)value; } // padding - public int _09 { get => Data[0x09]; set => Data[0x09] = (byte)value; } - public int _0A { get => Data[0x0A]; set => Data[0x0A] = (byte)value; } - public int _0B { get => Data[0x0B]; set => Data[0x0B] = (byte)value; } + public int Unk_09 { get => Data[0x09]; set => Data[0x09] = (byte)value; } + public int Unk_0A { get => Data[0x0A]; set => Data[0x0A] = (byte)value; } + public int Unk_0B { get => Data[0x0B]; set => Data[0x0B] = (byte)value; } public override int HeldItem { get => BitConverter.ToUInt16(Data, 0x0C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } public override FixedGender Gender { get => (FixedGender)Data[0x10]; set => Data[0x10] = (byte)value; } @@ -31,6 +31,6 @@ public class EncounterGift6XY : EncounterGift public override int IV_SPE { get => (sbyte)Data[0x16]; set => Data[0x16] = (byte)value; } // padding - public int Unk17 { get => (sbyte)Data[0x17]; set => Data[0x17] = (byte)value; } + public int Unk_17 { get => (sbyte)Data[0x17]; set => Data[0x17] = (byte)value; } } } \ No newline at end of file diff --git a/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs b/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs index 5f43843a..77d0c970 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs @@ -18,7 +18,7 @@ public class EncounterGift7 : EncounterGift public override int HeldItem { get => BitConverter.ToUInt16(Data, 0x8); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x8); } - public bool IsEgg { get => Data[0xA] == 1; set => Data[0xA] = (byte)(value ? 1 : 0); } + public bool IsEgg { get => Data[0xA] == 1; set => Data[0xA] = value ? 1 : 0; } public int SpecialMove { get => BitConverter.ToUInt16(Data, 0xC); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0xC); } diff --git a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs index de4e04d5..39bd12a1 100644 --- a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs +++ b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleDistributionEncounter8Archive.cs @@ -5,11 +5,14 @@ namespace pkNX.Structures { +#pragma warning disable CA1819 // Properties should not return arrays + [Serializable] public class NestHoleDistributionEncounter8Archive { public NestHoleDistributionEncounter8Table[] Tables { get; set; } } + [Serializable] public class NestHoleDistributionEncounter8Table { public ulong TableID { get; set; } @@ -161,6 +164,7 @@ public string GetSummarySimple() } } + [Serializable] public class NestHoleDistributionEncounter8 { public int EntryIndex { get; set; } @@ -207,4 +211,5 @@ public class NestHoleDistributionEncounter8 public override string ToString() => $"[{MinRank},{MaxRank}] {(Species)Species}-{AltForm}"; } +#pragma warning restore CA1819 // Properties should not return arrays } diff --git a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleReward8Archive.cs b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleReward8Archive.cs index 85bed46f..03130fe1 100644 --- a/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleReward8Archive.cs +++ b/pkNX.Structures/Encounter/Gen8/FlatNest/NestHoleReward8Archive.cs @@ -1,10 +1,9 @@ -using System.Runtime.InteropServices.ComTypes; -using System.Collections.Generic; -using System.ComponentModel; +using System.ComponentModel; using Newtonsoft.Json; namespace pkNX.Structures { +#pragma warning disable CA1819 // Properties should not return arrays public class NestHoleReward8Archive { public NestHoleReward8Table[] Tables { get; set; } @@ -41,4 +40,5 @@ public class NestHoleReward8 : INestHoleReward public override string ToString() => $"{EntryID:0} - {ItemID:0000}"; } +#pragma warning restore CA1819 // Properties should not return arrays } diff --git a/pkNX.Structures/Encounter/Gen8/FlatWild/EncounterTableUtil.cs b/pkNX.Structures/Encounter/Gen8/FlatWild/EncounterTableUtil.cs index b502975f..0f500da6 100644 --- a/pkNX.Structures/Encounter/Gen8/FlatWild/EncounterTableUtil.cs +++ b/pkNX.Structures/Encounter/Gen8/FlatWild/EncounterTableUtil.cs @@ -10,9 +10,8 @@ public static class EncounterTable8Util public static byte[][] GetBytes(IReadOnlyDictionary zone_loc, EncounterArchive8 t) { var result = new List(); - for (int i = 0; i < t.EncounterTables.Length; i++) + foreach (var zone in t.EncounterTables) { - var zone = t.EncounterTables[i]; var entry = GetZoneBytes(zone, zone_loc); if (entry.Length != 0) result.Add(entry); diff --git a/pkNX.Structures/Evolution/EvolutionSet6.cs b/pkNX.Structures/Evolution/EvolutionSet6.cs index 25e2431d..685c3b8a 100644 --- a/pkNX.Structures/Evolution/EvolutionSet6.cs +++ b/pkNX.Structures/Evolution/EvolutionSet6.cs @@ -12,7 +12,7 @@ public class EvolutionSet6 : EvolutionSet private const int ENTRY_SIZE = 6; private const int ENTRY_COUNT = 8; public const int SIZE = ENTRY_COUNT * ENTRY_SIZE; - private static readonly HashSet argEvos = new HashSet { 6, 8, 16, 17, 18, 19, 20, 21, 22, 29, 30, 32, 33, 34 }; + private static readonly HashSet argEvos = new() { 6, 8, 16, 17, 18, 19, 20, 21, 22, 29, 30, 32, 33, 34 }; public EvolutionSet6(byte[] data) { diff --git a/pkNX.Structures/Evolution/EvolutionSet7.cs b/pkNX.Structures/Evolution/EvolutionSet7.cs index 836ce0ac..d4aae2b9 100644 --- a/pkNX.Structures/Evolution/EvolutionSet7.cs +++ b/pkNX.Structures/Evolution/EvolutionSet7.cs @@ -18,7 +18,7 @@ public EvolutionSet7(byte[] data) private static EvolutionMethod GetEvo(byte[] data, int offset) { - return new EvolutionMethod + return new() { Method = (EvolutionType)BitConverter.ToUInt16(data, offset + 0), Argument = BitConverter.ToUInt16(data, offset + 2), diff --git a/pkNX.Structures/Evolution/EvolutionSet8.cs b/pkNX.Structures/Evolution/EvolutionSet8.cs index 5e11d83a..9594f53f 100644 --- a/pkNX.Structures/Evolution/EvolutionSet8.cs +++ b/pkNX.Structures/Evolution/EvolutionSet8.cs @@ -18,7 +18,7 @@ public EvolutionSet8(byte[] data) private static EvolutionMethod GetEvo(byte[] data, int offset) { - return new EvolutionMethod + return new() { Method = (EvolutionType)BitConverter.ToUInt16(data, offset + 0), Argument = BitConverter.ToUInt16(data, offset + 2), diff --git a/pkNX.Structures/Evolution/Extensions.cs b/pkNX.Structures/Evolution/Extensions.cs index b5b956ce..35aad2ad 100644 --- a/pkNX.Structures/Evolution/Extensions.cs +++ b/pkNX.Structures/Evolution/Extensions.cs @@ -7,7 +7,7 @@ namespace pkNX.Structures { public static partial class Extensions { - private static readonly Dictionary ArgType = new Dictionary + private static readonly Dictionary ArgType = new() { [None] = NoArg, [LevelUpFriendship] = NoArg, diff --git a/pkNX.Structures/GameUtil.cs b/pkNX.Structures/GameUtil.cs index 42ff25b0..d79080cc 100644 --- a/pkNX.Structures/GameUtil.cs +++ b/pkNX.Structures/GameUtil.cs @@ -155,75 +155,48 @@ public static bool Contains(this GameVersion g1, GameVersion g2) if (g1 == g2 || g1 == Any) return true; - if (g1 == g2 || g1 == Any) - return true; - - switch (g1) + return g1 switch { - case RB: - return g2 == RD || g2 == BU || g2 == GN; - case Stadium: - case EventsGBGen1: - case VCEvents: - case RBY: - return RB.Contains(g2) || g2 == YW; - case Gen1: - return RBY.Contains(g2) || g2 == Stadium || g2 == EventsGBGen1 || g2 == VCEvents; + RB => g2 is RD or BU or GN, + RBY or Stadium => RB.Contains(g2) || g2 == YW, + Gen1 => RBY.Contains(g2) || g2 == Stadium, - case GS: return g2 == GD || g2 == SV; - case Stadium2: - case EventsGBGen2: - case GSC: - return GS.Contains(g2) || g2 == C; - case Gen2: - return GSC.Contains(g2) || g2 == Stadium2 || g2 == EventsGBGen2; - case GBCartEraOnly: - return g2 == Stadium || g2 == Stadium2 || g2 == EventsGBGen1 || g2 == EventsGBGen2; + GS => g2 is GD or SV, + GSC or Stadium2 => GS.Contains(g2) || g2 == C, + Gen2 => GSC.Contains(g2) || g2 == Stadium2, - case RS: return g2 == R || g2 == S; - case RSE: - return RS.Contains(g2) || g2 == E; - case FRLG: return g2 == FR || g2 == LG; - case COLO: - case XD: return g2 == CXD; - case CXD: return g2 == COLO || g2 == XD; - case RSBOX: return RS.Contains(g2) || g2 == E || FRLG.Contains(g2); - case Gen3: - return RSE.Contains(g2) || FRLG.Contains(g2) || CXD.Contains(g2) || g2 == RSBOX; + RS => g2 is R or S, + RSE => RS.Contains(g2) || g2 == E, + FRLG => g2 is FR or LG, + COLO or XD => g2 == CXD, + CXD => g2 is COLO or XD, + RSBOX => RS.Contains(g2) || g2 == E || FRLG.Contains(g2), + Gen3 => RSE.Contains(g2) || FRLG.Contains(g2) || CXD.Contains(g2) || g2 == RSBOX, - case DP: return g2 == D || g2 == P; - case HGSS: return g2 == HG || g2 == SS; - case DPPt: - return DP.Contains(g2) || g2 == Pt; - case BATREV: return DP.Contains(g2) || g2 == Pt || HGSS.Contains(g2); - case Gen4: - return DPPt.Contains(g2) || HGSS.Contains(g2) || g2 == BATREV; + DP => g2 is D or P, + HGSS => g2 is HG or SS, + DPPt => DP.Contains(g2) || g2 == Pt, + BATREV => DP.Contains(g2) || g2 == Pt || HGSS.Contains(g2), + Gen4 => DPPt.Contains(g2) || HGSS.Contains(g2) || g2 == BATREV, - case BW: return g2 == B || g2 == W; - case B2W2: return g2 == B2 || g2 == W2; - case Gen5: - return BW.Contains(g2) || B2W2.Contains(g2); + BW => g2 is B or W, + B2W2 => g2 is B2 or W2, + Gen5 => BW.Contains(g2) || B2W2.Contains(g2), - case XY: return g2 == X || g2 == Y; - case ORAS: return g2 == OR || g2 == AS; - case Gen6: - return XY.Contains(g2) || ORAS.Contains(g2); + XY => g2 is X or Y, + ORAS => g2 is OR or AS, - case SM: - return g2 == SN || g2 == MN; - case USUM: - return g2 == US || g2 == UM; - case GG: - return g2 == GP || g2 == GE || g2 == GO; - case Gen7: - return SM.Contains(g2) || USUM.Contains(g2) || GG.Contains(g2); + Gen6 => XY.Contains(g2) || ORAS.Contains(g2), + SM => g2 is SN or MN, + USUM => g2 is US or UM, + GG => g2 is GP or GE, + Gen7 => SM.Contains(g2) || USUM.Contains(g2), + Gen7b => GG.Contains(g2) || GO == g2, - case Gen8: - case SWSH: - return g2 == SW || g2 == SH; - - default: return false; - } + SWSH => g2 is SW or SH, + Gen8 => SWSH.Contains(g2), + _ => false, + }; } /// diff --git a/pkNX.Structures/GameVersion.cs b/pkNX.Structures/GameVersion.cs index 5e2a3335..f87809a9 100644 --- a/pkNX.Structures/GameVersion.cs +++ b/pkNX.Structures/GameVersion.cs @@ -139,7 +139,7 @@ public enum GameVersion #endregion /// - /// Pokémon GO (Unused) + /// Pokémon GO (GO -> Lets Go transfers) /// GO = 34, @@ -217,7 +217,7 @@ public enum GameVersion RB, /// - /// Pokémon Red/Blue/Yello identifier. + /// Pokémon Red/Blue/Yellow identifier. /// /// /// @@ -342,9 +342,9 @@ public enum GameVersion /// /// Pokémon Omega Ruby & Alpha Sapphire version group. /// + /// Used to lump data from the associated games as data assets are shared. /// /// - /// Used to lump data from the associated games as data assets are shared. ORAS, /// @@ -356,11 +356,9 @@ public enum GameVersion SM, /// - /// Pokémon Sun & Moon Demo + /// Pokémon Sun & Moon Demo identifier. /// - /// Used to lump data from the associated games as data assets are shared. - /// - /// + /// SMDEMO, /// @@ -372,7 +370,7 @@ public enum GameVersion USUM, /// - /// Pokémon Let's Go (TBD) + /// Pokémon Let's Go Pikachu & Eevee /// /// Used to lump data from the associated games as data assets are shared. /// @@ -428,12 +426,19 @@ public enum GameVersion Gen6, /// - /// Generation 7 Games + /// Generation 7 Games on the Nintendo 3DS /// /// /// Gen7, + /// + /// Generation 7 Games on the Nintendo Switch + /// + /// + /// + Gen7b, + /// /// Generation 8 Games /// @@ -441,40 +446,19 @@ public enum GameVersion Gen8, /// - /// Generation 1/2 Game Boy Cartridge Era Only + /// Pocket Monsters Stadium data origin identifier /// - /// - /// Since the original run of and could not transfer to future games, - /// any special encounters (event data) can only be allowed if the savedata originated from that era. - /// - GBCartEraOnly, + StadiumJ, /// /// Pokémon Stadium data origin identifier /// - /// Stadium, /// /// Pokémon Stadium 2 data origin identifier /// - /// Stadium2, - - /// - /// Generation 1 Game Boy Cartridge Era Only data origin identifier - /// - EventsGBGen1, - - /// - /// Generation 2 Game Boy Cartridge Era Only data origin identifier - /// - EventsGBGen2, - - /// - /// Generation 1/2 3DS Virtual Console data origin identifier - /// - VCEvents, #endregion } } diff --git a/pkNX.Structures/Item/Item.cs b/pkNX.Structures/Item/Item.cs index 2ba55cbb..83da6353 100644 --- a/pkNX.Structures/Item/Item.cs +++ b/pkNX.Structures/Item/Item.cs @@ -33,8 +33,8 @@ public class Item [Category(Battle), Description("Routine # to call when used; 0=unusable.")] public byte EffectBattle { get; set; } // Battle Type - public byte _0xC { get; set; } // 0 or 1 - public byte _0xD { get; set; } // Classification (0-3 Battle, 4 Balls, 5 Mail) + public byte Unk_0xC { get; set; } // 0 or 1 + public byte Unk_0xD { get; set; } // Classification (0-3 Battle, 4 Balls, 5 Mail) private byte Consumable { get; set; } public byte SortIndex { get; set; } public BattleStatusFlags CureInflict { get; set; } // Bitflags diff --git a/pkNX.Structures/Learnset/Learnset8.cs b/pkNX.Structures/Learnset/Learnset8.cs index e80c23c2..8d87bb89 100644 --- a/pkNX.Structures/Learnset/Learnset8.cs +++ b/pkNX.Structures/Learnset/Learnset8.cs @@ -20,8 +20,8 @@ public Learnset8(byte[] data) Count = count; if (Count == 0) { - Levels = Moves = Array.Empty(); - return; + Levels = Moves = Array.Empty(); + return; } Moves = new int[Count]; diff --git a/pkNX.Structures/Legality/Encounters.cs b/pkNX.Structures/Legality/Encounters.cs index e23bd392..a9b08e8b 100644 --- a/pkNX.Structures/Legality/Encounters.cs +++ b/pkNX.Structures/Legality/Encounters.cs @@ -9,7 +9,7 @@ public static partial class Legal 001, 004, 007, 010, 013, 016, 029, 032, 041, 043, 060, 063, 066, 069, 074, 081, 092, 111, 116, 137, 147, }; - public static readonly int[] BasicStarters_6 = BasicStarters_1.Concat(new int[] + public static readonly int[] BasicStarters_6 = BasicStarters_1.Concat(new[] { 152, 155, 158, 172, 173, 174, 175, 179, 187, 220, 239, 240, 246, 252, 255, 258, 265, 270, 273, 280, 287, 293, 298, 304, 328, 355, 363, 371, 374, 387, 390, 393, 396, 403, 406, 440, 443, 495, 498, 501, 506, 519, diff --git a/pkNX.Structures/Legality/GameInfo.cs b/pkNX.Structures/Legality/GameInfo.cs index 5200dc7b..4c70ace4 100644 --- a/pkNX.Structures/Legality/GameInfo.cs +++ b/pkNX.Structures/Legality/GameInfo.cs @@ -34,7 +34,7 @@ private Action GetInitMethod(GameVersion game) { return game switch { - GameVersion.XY => (Action) LoadXY, + GameVersion.XY => LoadXY, GameVersion.ORASDEMO => LoadAO, GameVersion.ORAS => LoadAO, GameVersion.SMDEMO => LoadSM, diff --git a/pkNX.Structures/Legality/Legal.cs b/pkNX.Structures/Legality/Legal.cs index 9a1e1b06..c899363d 100644 --- a/pkNX.Structures/Legality/Legal.cs +++ b/pkNX.Structures/Legality/Legal.cs @@ -48,7 +48,7 @@ public static int[] GetRandomItemList(GameVersion game) return MegaDictionaryAO; } - private static readonly Dictionary MegaDictionaryXY = new Dictionary + private static readonly Dictionary MegaDictionaryXY = new() { {003, new[] {659}}, // Venusaur @ Venusaurite {006, new[] {660, 678}}, // Charizard @ Charizardite X/Y @@ -80,7 +80,7 @@ public static int[] GetRandomItemList(GameVersion game) {460, new[] {674}}, // Abomasnow @ Abomasite }; - private static readonly Dictionary MegaDictionaryAO = new Dictionary + private static readonly Dictionary MegaDictionaryAO = new() { {003, new[] {659}}, // Venusaur @ Venusaurite {006, new[] {660, 678}}, // Charizard @ Charizardite X/Y @@ -131,7 +131,7 @@ public static int[] GetRandomItemList(GameVersion game) {719, new[] {764}}, // Diancie @ Diancite }; - private static readonly Dictionary MegaDictionaryGG = new Dictionary + private static readonly Dictionary MegaDictionaryGG = new() { {003, new[] {659}}, // Venusaur @ Venusaurite {006, new[] {660, 678}}, // Charizard @ Charizardite X/Y @@ -192,7 +192,7 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount) 503, 504, 525, 529, 583, 585, 605, 742 }; - public static readonly HashSet BattleForms = new HashSet + public static readonly HashSet BattleForms = new() { (int)Species.Castform, (int)Species.Cherrim, @@ -210,7 +210,7 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount) (int)Species.Eternatus, }; - public static readonly HashSet BattleMegas = new HashSet + public static readonly HashSet BattleMegas = new() { // XY (int)Species.Venusaur, (int)Species.Charizard, (int)Species.Blastoise, (int)Species.Alakazam, (int)Species.Gengar, @@ -228,8 +228,8 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount) (int)Species.Audino, (int)Species.Diancie, }; - public static readonly HashSet BattlePrimals = new HashSet { 382, 383 }; // Kyogre and Groudon - public static readonly HashSet BattleFusions = new HashSet { 646, 800, 898 }; // Kyurem, Necrozma, Calyrex - public static HashSet BattleExclusiveForms = new HashSet(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions))); + public static readonly HashSet BattlePrimals = new() { 382, 383 }; // Kyogre and Groudon + public static readonly HashSet BattleFusions = new() { 646, 800, 898 }; // Kyurem, Necrozma, Calyrex + public static HashSet BattleExclusiveForms = new(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions))); } } diff --git a/pkNX.Structures/Legality/Species.cs b/pkNX.Structures/Legality/Species.cs index b68abc1c..74e7d3a4 100644 --- a/pkNX.Structures/Legality/Species.cs +++ b/pkNX.Structures/Legality/Species.cs @@ -10,7 +10,7 @@ public static partial class Legal 094, 097, 099, 101, 103, 105, 106, 107, 110, 115, 119, 121, 122, 124, 127, 128, 130, 131, 132, 134, 135, 136, 139, 141, 142, 143, 149, }; - public static readonly int[] FinalEvolutions_6 = FinalEvolutions_1.Concat(new int[] + public static readonly int[] FinalEvolutions_6 = FinalEvolutions_1.Concat(new[] { 154, 157, 160, 162, 164, 166, 168, 169, 171, 178, 181, 182, 184, 185, 186, 189, 192, 195, 196, 197, 199, 201, 202, 203, 205, 206, 208, 210, 211, 212, 213, 214, 217, 219, 222, 224, 225, 226, 227, 229, 230, 232, 234, 235, 237, 241, 242, 248, 254, 257, 260, 262, 264, 267, 269, 272, 275, 277, 279, 282, 284, 286, 289, 291, 292, 295, 297, 301, 302, 303, 306, 308, 310, 311, @@ -22,12 +22,12 @@ public static partial class Legal 703, 706, 707, 709, 711, 713, 715, }).ToArray(); - public static readonly int[] FinalEvolutions_7 = FinalEvolutions_6.Concat(new int[] + public static readonly int[] FinalEvolutions_7 = FinalEvolutions_6.Concat(new[] { 724, 727, 730, 733, 735, 738, 740, 741, 743, 745, 746, 748, 750, 752, 754, 756, 758, 760, 763, 764, 765, 766, 768, 770, 771, 774, 775, 776, 777, 779, 780, 781, 784, }).ToArray(); - public static readonly int[] FinalEvolutions_8 = FinalEvolutions_7.Concat(new int[] + public static readonly int[] FinalEvolutions_8 = FinalEvolutions_7.Concat(new[] { 812, 815, 818, 820, 823, 826, 828, 830, 832, 834, 836, 839, 841, 842, 844, 845, 847, 849, 851, 853, 855, 858, 861, 862, 863, 864, 865, 866, 867, 869, 870, 871, 873, 874, 875, 876, 877, 879, 880, 881, 882, 883, 884, 887, @@ -43,7 +43,7 @@ public static partial class Legal #endregion }; - public static readonly int[] Legendary_6 = Legendary_1.Concat(new int[] + public static readonly int[] Legendary_6 = Legendary_1.Concat(new[] { #region Legendary 243, // Raikou @@ -83,7 +83,7 @@ public static partial class Legal #endregion }).ToArray(); - public static readonly int[] Legendary_SM = Legendary_6.Concat(new int[] + public static readonly int[] Legendary_SM = Legendary_6.Concat(new[] { #region Legendary 773, // Silvally @@ -104,13 +104,13 @@ public static partial class Legal #endregion }).ToArray(); - public static readonly int[] Legendary_USUM = Legendary_SM.Concat(new int[] { 804, 805, 806 }).ToArray(); // Poipole, Blacephalon, Stakataka + public static readonly int[] Legendary_USUM = Legendary_SM.Concat(new[] { 804, 805, 806 }).ToArray(); // Poipole, Blacephalon, Stakataka - public static readonly int[] Legendary_8 = Legendary_USUM.Concat(new int[] { 888, 889, 890 }).ToArray(); // Zacian, Zamazenta, Eternatus + public static readonly int[] Legendary_8 = Legendary_USUM.Concat(new[] { 888, 889, 890 }).ToArray(); // Zacian, Zamazenta, Eternatus public static readonly int[] Mythical_1 = { 151 }; // Mew - public static readonly int[] Mythical_6 = Mythical_1.Concat(new int[] + public static readonly int[] Mythical_6 = Mythical_1.Concat(new[] { #region Mythical 251, // Celebi @@ -131,10 +131,10 @@ public static partial class Legal #endregion }).ToArray(); - public static readonly int[] Mythical_SM = Mythical_6.Concat(new int[] { 801, 802 }).ToArray(); // Magearna, Marshadow + public static readonly int[] Mythical_SM = Mythical_6.Concat(new[] { 801, 802 }).ToArray(); // Magearna, Marshadow - public static readonly int[] Mythical_USUM = Mythical_SM.Concat(new int[] { 807 }).ToArray(); // Zeraora + public static readonly int[] Mythical_USUM = Mythical_SM.Concat(new[] { 807 }).ToArray(); // Zeraora - public static readonly int[] Mythical_GG = Mythical_1.Concat(new int[] { 809 }).ToArray(); // Melmetal + public static readonly int[] Mythical_GG = Mythical_1.Concat(new[] { 809 }).ToArray(); // Melmetal } } diff --git a/pkNX.Structures/Legality/Tables6.cs b/pkNX.Structures/Legality/Tables6.cs index 600c7905..81abb455 100644 --- a/pkNX.Structures/Legality/Tables6.cs +++ b/pkNX.Structures/Legality/Tables6.cs @@ -488,11 +488,11 @@ public static partial class Legal new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching }; - public static readonly HashSet MemoryGeneral = new HashSet { 1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59 }; - public static readonly HashSet MemorySpecific = new HashSet { 6 }; - public static readonly HashSet MemoryMove = new HashSet { 12, 16, 48, 49 }; - public static readonly HashSet MemoryItem = new HashSet { 5, 15, 26, 34, 40, 51 }; - public static readonly HashSet MemorySpecies = new HashSet { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60 }; + public static readonly HashSet MemoryGeneral = new() { 1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59 }; + public static readonly HashSet MemorySpecific = new() { 6 }; + public static readonly HashSet MemoryMove = new() { 12, 16, 48, 49 }; + public static readonly HashSet MemoryItem = new() { 5, 15, 26, 34, 40, 51 }; + public static readonly HashSet MemorySpecies = new() { 7, 9, 13, 14, 17, 21, 18, 25, 29, 44, 45, 50, 60 }; #endregion public static readonly int[] MovePP_XY = diff --git a/pkNX.Structures/Legality/Tables7.cs b/pkNX.Structures/Legality/Tables7.cs index e3ff5ba9..f98dc64b 100644 --- a/pkNX.Structures/Legality/Tables7.cs +++ b/pkNX.Structures/Legality/Tables7.cs @@ -197,14 +197,14 @@ public static partial class Legal #endregion public static readonly bool[] ReleasedHeldItems_7 = Enumerable.Range(0, MaxItemID_7_SM+1).Select(i => HeldItems_SM.Contains((ushort)i) && !UnreleasedHeldItems_7.Contains(i)).ToArray(); - public static readonly HashSet Totem_Alolan = new HashSet + public static readonly HashSet Totem_Alolan = new() { (int)Species.Raticate, // Normal, Alolan, Totem (int)Species.Marowak, // Normal, Alolan, Totem (int)Species.Mimikyu, // Normal, Busted, Totem, Totem_Busted }; - public static readonly HashSet Totem_SM = new HashSet + public static readonly HashSet Totem_SM = new() { (int)Species.Raticate, (int)Species.Gumshoos, @@ -216,7 +216,7 @@ public static partial class Legal (int)Species.Kommoo, }; - public static readonly HashSet Totem_USUM = new HashSet + public static readonly HashSet Totem_USUM = new() { (int)Species.Raticate, (int)Species.Gumshoos, diff --git a/pkNX.Structures/Legality/Tables8.cs b/pkNX.Structures/Legality/Tables8.cs index 1ee23050..53ab08cf 100644 --- a/pkNX.Structures/Legality/Tables8.cs +++ b/pkNX.Structures/Legality/Tables8.cs @@ -180,7 +180,7 @@ public static partial class Legal internal static readonly ushort[] HeldItems_SWSH = new ushort[1].Concat(Pouch_Items_SWSH).Concat(Pouch_Berries_SWSH).Concat(Pouch_Medicine_SWSH).Concat(Pouch_Ingredients_SWSH).Concat(Pouch_Treasure_SWSH).Concat(TR_SWSH).ToArray(); - internal static readonly HashSet GalarOriginForms = new HashSet + internal static readonly HashSet GalarOriginForms = new() { (int)Species.Meowth, (int)Species.Ponyta, @@ -204,13 +204,13 @@ public static partial class Legal (int)Species.Slowking, }; - internal static readonly HashSet GalarVariantFormEvolutions = new HashSet + internal static readonly HashSet GalarVariantFormEvolutions = new() { (int)Species.MrMime, (int)Species.Weezing, }; - internal static readonly HashSet GalarForm0Evolutions = new HashSet + internal static readonly HashSet GalarForm0Evolutions = new() { (int)Species.Obstagoon, (int)Species.Perrserker, @@ -220,7 +220,7 @@ public static partial class Legal (int)Species.Runerigus, }; - public static readonly HashSet EvolveToGalarForms = new HashSet(GalarVariantFormEvolutions.Concat(GalarOriginForms)); + public static readonly HashSet EvolveToGalarForms = new(GalarVariantFormEvolutions.Concat(GalarOriginForms)); public static readonly int[] GigantamaxForms = { @@ -260,7 +260,7 @@ public static partial class Legal (int)Species.Urshifu, }; - internal static readonly HashSet ValidMet_SWSH = new HashSet + internal static readonly HashSet ValidMet_SWSH = new() { 006, 008, 012, 014, 016, 018, @@ -341,7 +341,7 @@ public static partial class Legal }; #region Unreleased Items - internal static readonly HashSet UnreleasedHeldItems_8 = new HashSet + internal static readonly HashSet UnreleasedHeldItems_8 = new() { 298, // Flame Plate 299, // Splash Plate diff --git a/pkNX.Structures/Misc/CaptureReward.cs b/pkNX.Structures/Misc/CaptureReward.cs index dd803616..89a33dcf 100644 --- a/pkNX.Structures/Misc/CaptureReward.cs +++ b/pkNX.Structures/Misc/CaptureReward.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures /// They do this because the Pickup Ability no longer exists, and to ease the grind of marts. public class CaptureRewardTable { - public List Table = new List(); + public List Table = new(); public CaptureRewardTable(byte[] data) { @@ -33,7 +33,7 @@ private static void ReadTable(BinaryReader br, CaptureRewardGroup g) private static CaptureRewardEntry ReadEntry(BinaryReader br) { - return new CaptureRewardEntry + return new() { Item = br.ReadInt32(), Count = br.ReadInt32(), diff --git a/pkNX.Structures/Personal/PersonalInfoSM.cs b/pkNX.Structures/Personal/PersonalInfoSM.cs index 90dd6788..2430625c 100644 --- a/pkNX.Structures/Personal/PersonalInfoSM.cs +++ b/pkNX.Structures/Personal/PersonalInfoSM.cs @@ -35,6 +35,6 @@ public override byte[] Write() public int SpecialZ_Item { get => BitConverter.ToUInt16(Data, 0x4C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4C); } public int SpecialZ_BaseMove { get => BitConverter.ToUInt16(Data, 0x4E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x4E); } public int SpecialZ_ZMove { get => BitConverter.ToUInt16(Data, 0x50); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x50); } - public bool LocalVariant { get => Data[0x52] == 1; set => Data[0x52] = (byte)(value ? 1 : 0); } + public bool LocalVariant { get => Data[0x52] == 1; set => Data[0x52] = value ? 1 : 0; } } } diff --git a/pkNX.Structures/Personal/PersonalTable.cs b/pkNX.Structures/Personal/PersonalTable.cs index e8301d8c..94a04e3a 100644 --- a/pkNX.Structures/Personal/PersonalTable.cs +++ b/pkNX.Structures/Personal/PersonalTable.cs @@ -24,44 +24,30 @@ private static byte[][] SplitBytes(byte[] data, int size) private static Func GetConstructor(GameVersion format) { - switch (format) + return format switch { - case GameVersion.BW: - return z => new PersonalInfoBW(z); - case GameVersion.B2W2: - return z => new PersonalInfoB2W2(z); - case GameVersion.XY: - return z => new PersonalInfoXY(z); - case GameVersion.ORAS: - return z => new PersonalInfoORAS(z); - case GameVersion.SM: - case GameVersion.USUM: - return z => new PersonalInfoSM(z); - case GameVersion.GG: - return z => new PersonalInfoGG(z); - default: - return z => new PersonalInfoSWSH(z); - } + GameVersion.BW => z => new PersonalInfoBW(z), + GameVersion.B2W2 => z => new PersonalInfoB2W2(z), + GameVersion.XY => z => new PersonalInfoXY(z), + GameVersion.ORAS => z => new PersonalInfoORAS(z), + GameVersion.SM or GameVersion.USUM => z => new PersonalInfoSM(z), + GameVersion.GG => z => new PersonalInfoGG(z), + _ => z => new PersonalInfoSWSH(z), + }; } private static int GetEntrySize(GameVersion format) { - switch (format) + return format switch { - case GameVersion.BW: return PersonalInfoBW.SIZE; - case GameVersion.B2W2: return PersonalInfoB2W2.SIZE; - case GameVersion.XY: return PersonalInfoXY.SIZE; - case GameVersion.ORAS: return PersonalInfoORAS.SIZE; - case GameVersion.SM: - case GameVersion.USUM: - case GameVersion.GG: return PersonalInfoSM.SIZE; - - case GameVersion.SW: - case GameVersion.SH: - case GameVersion.SWSH: return PersonalInfoSWSH.SIZE; - - default: return -1; - } + GameVersion.BW => PersonalInfoBW.SIZE, + GameVersion.B2W2 => PersonalInfoB2W2.SIZE, + GameVersion.XY => PersonalInfoXY.SIZE, + GameVersion.ORAS => PersonalInfoORAS.SIZE, + GameVersion.SM or GameVersion.USUM or GameVersion.GG => PersonalInfoSM.SIZE, + GameVersion.SW or GameVersion.SH or GameVersion.SWSH => PersonalInfoSWSH.SIZE, + _ => -1 + }; } public PersonalTable(byte[] data, GameVersion format) diff --git a/pkNX.Structures/Scripts/OpCodeTypeMappings.cs b/pkNX.Structures/Scripts/OpCodeTypeMappings.cs index 09daac35..d29591d5 100644 --- a/pkNX.Structures/Scripts/OpCodeTypeMappings.cs +++ b/pkNX.Structures/Scripts/OpCodeTypeMappings.cs @@ -4,7 +4,8 @@ namespace pkNX.Structures { public static partial class PawnUtil { - public static readonly Dictionary OpCodeTypes = new Dictionary { + public static readonly Dictionary OpCodeTypes = new() + { { AmxOpCode.NONE, AmxOpCodeType.NoParams }, { AmxOpCode.LOAD_PRI, AmxOpCodeType.OneParam }, { AmxOpCode.LOAD_ALT, AmxOpCodeType.OneParam }, diff --git a/pkNX.Structures/Scripts/PawnUtil.cs b/pkNX.Structures/Scripts/PawnUtil.cs index 5a9a1096..ee18e4a4 100644 --- a/pkNX.Structures/Scripts/PawnUtil.cs +++ b/pkNX.Structures/Scripts/PawnUtil.cs @@ -128,7 +128,7 @@ private static byte[] CompressInstruction(uint instruction) var signBit = sign ? 0x40 : 0x00; if ((bytes.Last() & 0x40) != signBit) - bytes.Add((byte)(sign ? 0xFF : 0x80)); + bytes.Add(sign ? 0xFF : 0x80); } // Little endian to big endian diff --git a/pkNX.Structures/Scripts/VariableType.cs b/pkNX.Structures/Scripts/VariableType.cs index 013a6e12..f8f6085a 100644 --- a/pkNX.Structures/Scripts/VariableType.cs +++ b/pkNX.Structures/Scripts/VariableType.cs @@ -15,7 +15,7 @@ public static class VariableTypeExtensions private const byte IDENT_REFERENCE = 2; private const byte IDENT_ARRAY = 3; private const byte IDENT_REFARRAY = 4; - private const byte IDENT_FUNCTION = 9; + //private const byte IDENT_FUNCTION = 9; private const byte IDENT_VARARGS = 11; public static VariableType FromIdent(this byte ident) diff --git a/pkNX.Structures/Text/TextConfig.cs b/pkNX.Structures/Text/TextConfig.cs index 85bb3701..c440b417 100644 --- a/pkNX.Structures/Text/TextConfig.cs +++ b/pkNX.Structures/Text/TextConfig.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures /// public class TextConfig { - internal static readonly TextConfig Default = new TextConfig(GameVersion.Any); + internal static readonly TextConfig Default = new(GameVersion.Any); private static readonly char[] _trim_hex = { '0', 'x' }; private readonly TextVariableCode[] Variables; diff --git a/pkNX.Structures/Text/TextFile.cs b/pkNX.Structures/Text/TextFile.cs index f72691b6..eea240b0 100644 --- a/pkNX.Structures/Text/TextFile.cs +++ b/pkNX.Structures/Text/TextFile.cs @@ -141,8 +141,7 @@ public string[] Lines private byte[][] ConvertLinesToData(string[] value) { - if (value == null) - value = Array.Empty(); + value ??= Array.Empty(); ushort key = KEY_BASE; var lineData = new byte[value.Length][]; diff --git a/pkNX.Structures/Text/TextVariableCode.cs b/pkNX.Structures/Text/TextVariableCode.cs index 551bca20..3d322555 100644 --- a/pkNX.Structures/Text/TextVariableCode.cs +++ b/pkNX.Structures/Text/TextVariableCode.cs @@ -32,210 +32,210 @@ public static TextVariableCode[] GetVariables(GameVersion game) private static readonly TextVariableCode[] XY = { - new TextVariableCode(0xFF00, "COLOR"), - new TextVariableCode(0x0100, "TRNAME"), - new TextVariableCode(0x0101, "PKNAME"), - new TextVariableCode(0x0102, "PKNICK"), - new TextVariableCode(0x0103, "TYPE"), - new TextVariableCode(0x0105, "LOCATION"), - new TextVariableCode(0x0106, "ABILITY"), - new TextVariableCode(0x0107, "MOVE"), - new TextVariableCode(0x0108, "ITEM1"), - new TextVariableCode(0x0109, "ITEM2"), - new TextVariableCode(0x010A, "sTRBAG"), - new TextVariableCode(0x010B, "BOX"), - new TextVariableCode(0x010D, "EVSTAT"), - new TextVariableCode(0x0110, "OPOWER"), - new TextVariableCode(0x0127, "RIBBON"), - new TextVariableCode(0x0134, "MIINAME"), - new TextVariableCode(0x013E, "WEATHER"), - new TextVariableCode(0x0189, "TRNICK"), - new TextVariableCode(0x018A, "1stchrTR"), - new TextVariableCode(0x018B, "SHOUTOUT"), - new TextVariableCode(0x018E, "BERRY"), - new TextVariableCode(0x018F, "REMFEEL"), - new TextVariableCode(0x0190, "REMQUAL"), - new TextVariableCode(0x0191, "WEBSITE"), - new TextVariableCode(0x019C, "CHOICECOS"), - new TextVariableCode(0x01A1, "GSYNCID"), - new TextVariableCode(0x0192, "PRVIDSAY"), - new TextVariableCode(0x0193, "BTLTEST"), - new TextVariableCode(0x0195, "GENLOC"), - new TextVariableCode(0x0199, "CHOICEFOOD"), - new TextVariableCode(0x019A, "HOTELITEM"), - new TextVariableCode(0x019B, "TAXISTOP"), - new TextVariableCode(0x019F, "MAISTITLE"), - new TextVariableCode(0x1000, "ITEMPLUR0"), - new TextVariableCode(0x1001, "ITEMPLUR1"), - new TextVariableCode(0x1100, "GENDBR"), - new TextVariableCode(0x1101, "NUMBRNCH"), - new TextVariableCode(0x1302, "iCOLOR2"), - new TextVariableCode(0x1303, "iCOLOR3"), - new TextVariableCode(0x0200, "NUM1"), - new TextVariableCode(0x0201, "NUM2"), - new TextVariableCode(0x0202, "NUM3"), - new TextVariableCode(0x0203, "NUM4"), - new TextVariableCode(0x0204, "NUM5"), - new TextVariableCode(0x0205, "NUM6"), - new TextVariableCode(0x0206, "NUM7"), - new TextVariableCode(0x0207, "NUM8"), - new TextVariableCode(0x0208, "NUM9"), + new(0xFF00, "COLOR"), + new(0x0100, "TRNAME"), + new(0x0101, "PKNAME"), + new(0x0102, "PKNICK"), + new(0x0103, "TYPE"), + new(0x0105, "LOCATION"), + new(0x0106, "ABILITY"), + new(0x0107, "MOVE"), + new(0x0108, "ITEM1"), + new(0x0109, "ITEM2"), + new(0x010A, "sTRBAG"), + new(0x010B, "BOX"), + new(0x010D, "EVSTAT"), + new(0x0110, "OPOWER"), + new(0x0127, "RIBBON"), + new(0x0134, "MIINAME"), + new(0x013E, "WEATHER"), + new(0x0189, "TRNICK"), + new(0x018A, "1stchrTR"), + new(0x018B, "SHOUTOUT"), + new(0x018E, "BERRY"), + new(0x018F, "REMFEEL"), + new(0x0190, "REMQUAL"), + new(0x0191, "WEBSITE"), + new(0x019C, "CHOICECOS"), + new(0x01A1, "GSYNCID"), + new(0x0192, "PRVIDSAY"), + new(0x0193, "BTLTEST"), + new(0x0195, "GENLOC"), + new(0x0199, "CHOICEFOOD"), + new(0x019A, "HOTELITEM"), + new(0x019B, "TAXISTOP"), + new(0x019F, "MAISTITLE"), + new(0x1000, "ITEMPLUR0"), + new(0x1001, "ITEMPLUR1"), + new(0x1100, "GENDBR"), + new(0x1101, "NUMBRNCH"), + new(0x1302, "iCOLOR2"), + new(0x1303, "iCOLOR3"), + new(0x0200, "NUM1"), + new(0x0201, "NUM2"), + new(0x0202, "NUM3"), + new(0x0203, "NUM4"), + new(0x0204, "NUM5"), + new(0x0205, "NUM6"), + new(0x0206, "NUM7"), + new(0x0207, "NUM8"), + new(0x0208, "NUM9"), }; private static readonly TextVariableCode[] AO = { - new TextVariableCode(0xFF00, "COLOR"), - new TextVariableCode(0x0100, "TRNAME"), - new TextVariableCode(0x0101, "PKNAME"), - new TextVariableCode(0x0102, "PKNICK"), - new TextVariableCode(0x0103, "TYPE"), - new TextVariableCode(0x0105, "LOCATION"), - new TextVariableCode(0x0106, "ABILITY"), - new TextVariableCode(0x0107, "MOVE"), - new TextVariableCode(0x0108, "ITEM1"), - new TextVariableCode(0x0109, "ITEM2"), - new TextVariableCode(0x010A, "sTRBAG"), - new TextVariableCode(0x010B, "BOX"), - new TextVariableCode(0x010D, "EVSTAT"), - new TextVariableCode(0x0110, "OPOWER"), - new TextVariableCode(0x0127, "RIBBON"), - new TextVariableCode(0x0134, "MIINAME"), - new TextVariableCode(0x013E, "WEATHER"), - new TextVariableCode(0x0189, "TRNICK"), - new TextVariableCode(0x018A, "1stchrTR"), - new TextVariableCode(0x018B, "SHOUTOUT"), - new TextVariableCode(0x018E, "BERRY"), - new TextVariableCode(0x018F, "REMFEEL"), - new TextVariableCode(0x0190, "REMQUAL"), - new TextVariableCode(0x0191, "WEBSITE"), - new TextVariableCode(0x019C, "CHOICECOS"), - new TextVariableCode(0x01A1, "GSYNCID"), - new TextVariableCode(0x0192, "PRVIDSAY"), - new TextVariableCode(0x0193, "BTLTEST"), - new TextVariableCode(0x0195, "GENLOC"), - new TextVariableCode(0x0199, "CHOICEFOOD"), - new TextVariableCode(0x019A, "HOTELITEM"), - new TextVariableCode(0x019B, "TAXISTOP"), - new TextVariableCode(0x019F, "MAISTITLE"), - new TextVariableCode(0x1000, "ITEMPLUR0"), - new TextVariableCode(0x1001, "ITEMPLUR1"), - new TextVariableCode(0x1100, "GENDBR"), - new TextVariableCode(0x1101, "NUMBRNCH"), - new TextVariableCode(0x1302, "iCOLOR2"), - new TextVariableCode(0x1303, "iCOLOR3"), - new TextVariableCode(0x0200, "NUM1"), - new TextVariableCode(0x0201, "NUM2"), - new TextVariableCode(0x0202, "NUM3"), - new TextVariableCode(0x0203, "NUM4"), - new TextVariableCode(0x0204, "NUM5"), - new TextVariableCode(0x0205, "NUM6"), - new TextVariableCode(0x0206, "NUM7"), - new TextVariableCode(0x0207, "NUM8"), - new TextVariableCode(0x0208, "NUM9"), + new(0xFF00, "COLOR"), + new(0x0100, "TRNAME"), + new(0x0101, "PKNAME"), + new(0x0102, "PKNICK"), + new(0x0103, "TYPE"), + new(0x0105, "LOCATION"), + new(0x0106, "ABILITY"), + new(0x0107, "MOVE"), + new(0x0108, "ITEM1"), + new(0x0109, "ITEM2"), + new(0x010A, "sTRBAG"), + new(0x010B, "BOX"), + new(0x010D, "EVSTAT"), + new(0x0110, "OPOWER"), + new(0x0127, "RIBBON"), + new(0x0134, "MIINAME"), + new(0x013E, "WEATHER"), + new(0x0189, "TRNICK"), + new(0x018A, "1stchrTR"), + new(0x018B, "SHOUTOUT"), + new(0x018E, "BERRY"), + new(0x018F, "REMFEEL"), + new(0x0190, "REMQUAL"), + new(0x0191, "WEBSITE"), + new(0x019C, "CHOICECOS"), + new(0x01A1, "GSYNCID"), + new(0x0192, "PRVIDSAY"), + new(0x0193, "BTLTEST"), + new(0x0195, "GENLOC"), + new(0x0199, "CHOICEFOOD"), + new(0x019A, "HOTELITEM"), + new(0x019B, "TAXISTOP"), + new(0x019F, "MAISTITLE"), + new(0x1000, "ITEMPLUR0"), + new(0x1001, "ITEMPLUR1"), + new(0x1100, "GENDBR"), + new(0x1101, "NUMBRNCH"), + new(0x1302, "iCOLOR2"), + new(0x1303, "iCOLOR3"), + new(0x0200, "NUM1"), + new(0x0201, "NUM2"), + new(0x0202, "NUM3"), + new(0x0203, "NUM4"), + new(0x0204, "NUM5"), + new(0x0205, "NUM6"), + new(0x0206, "NUM7"), + new(0x0207, "NUM8"), + new(0x0208, "NUM9"), }; private static readonly TextVariableCode[] SM = { - new TextVariableCode(0xFF00, "COLOR"), - new TextVariableCode(0x0100, "TRNAME"), - new TextVariableCode(0x0101, "PKNAME"), - new TextVariableCode(0x0102, "PKNICK"), - new TextVariableCode(0x0103, "TYPE"), - new TextVariableCode(0x0105, "LOCATION"), - new TextVariableCode(0x0106, "ABILITY"), - new TextVariableCode(0x0107, "MOVE"), - new TextVariableCode(0x0108, "ITEM1"), - new TextVariableCode(0x0109, "ITEM2"), - new TextVariableCode(0x010A, "sTRBAG"), - new TextVariableCode(0x010B, "BOX"), - new TextVariableCode(0x010D, "EVSTAT"), - new TextVariableCode(0x0110, "OPOWER"), - new TextVariableCode(0x0127, "RIBBON"), - new TextVariableCode(0x0134, "MIINAME"), - new TextVariableCode(0x013E, "WEATHER"), - new TextVariableCode(0x0189, "TRNICK"), - new TextVariableCode(0x018A, "1stchrTR"), - new TextVariableCode(0x018B, "SHOUTOUT"), - new TextVariableCode(0x018E, "BERRY"), - new TextVariableCode(0x018F, "REMFEEL"), - new TextVariableCode(0x0190, "REMQUAL"), - new TextVariableCode(0x0191, "WEBSITE"), - new TextVariableCode(0x019C, "CHOICECOS"), - new TextVariableCode(0x01A1, "GSYNCID"), - new TextVariableCode(0x0192, "PRVIDSAY"), - new TextVariableCode(0x0193, "BTLTEST"), - new TextVariableCode(0x0195, "GENLOC"), - new TextVariableCode(0x0199, "CHOICEFOOD"), - new TextVariableCode(0x019A, "HOTELITEM"), - new TextVariableCode(0x019B, "TAXISTOP"), - new TextVariableCode(0x019F, "MAISTITLE"), - new TextVariableCode(0x1000, "ITEMPLUR0"), - new TextVariableCode(0x1001, "ITEMPLUR1"), - new TextVariableCode(0x1100, "GENDBR"), - new TextVariableCode(0x1101, "NUMBRNCH"), - new TextVariableCode(0x1302, "iCOLOR2"), - new TextVariableCode(0x1303, "iCOLOR3"), - new TextVariableCode(0x0200, "NUM1"), - new TextVariableCode(0x0201, "NUM2"), - new TextVariableCode(0x0202, "NUM3"), - new TextVariableCode(0x0203, "NUM4"), - new TextVariableCode(0x0204, "NUM5"), - new TextVariableCode(0x0205, "NUM6"), - new TextVariableCode(0x0206, "NUM7"), - new TextVariableCode(0x0207, "NUM8"), - new TextVariableCode(0x0208, "NUM9"), + new(0xFF00, "COLOR"), + new(0x0100, "TRNAME"), + new(0x0101, "PKNAME"), + new(0x0102, "PKNICK"), + new(0x0103, "TYPE"), + new(0x0105, "LOCATION"), + new(0x0106, "ABILITY"), + new(0x0107, "MOVE"), + new(0x0108, "ITEM1"), + new(0x0109, "ITEM2"), + new(0x010A, "sTRBAG"), + new(0x010B, "BOX"), + new(0x010D, "EVSTAT"), + new(0x0110, "OPOWER"), + new(0x0127, "RIBBON"), + new(0x0134, "MIINAME"), + new(0x013E, "WEATHER"), + new(0x0189, "TRNICK"), + new(0x018A, "1stchrTR"), + new(0x018B, "SHOUTOUT"), + new(0x018E, "BERRY"), + new(0x018F, "REMFEEL"), + new(0x0190, "REMQUAL"), + new(0x0191, "WEBSITE"), + new(0x019C, "CHOICECOS"), + new(0x01A1, "GSYNCID"), + new(0x0192, "PRVIDSAY"), + new(0x0193, "BTLTEST"), + new(0x0195, "GENLOC"), + new(0x0199, "CHOICEFOOD"), + new(0x019A, "HOTELITEM"), + new(0x019B, "TAXISTOP"), + new(0x019F, "MAISTITLE"), + new(0x1000, "ITEMPLUR0"), + new(0x1001, "ITEMPLUR1"), + new(0x1100, "GENDBR"), + new(0x1101, "NUMBRNCH"), + new(0x1302, "iCOLOR2"), + new(0x1303, "iCOLOR3"), + new(0x0200, "NUM1"), + new(0x0201, "NUM2"), + new(0x0202, "NUM3"), + new(0x0203, "NUM4"), + new(0x0204, "NUM5"), + new(0x0205, "NUM6"), + new(0x0206, "NUM7"), + new(0x0207, "NUM8"), + new(0x0208, "NUM9"), }; private static readonly TextVariableCode[] GG = { - new TextVariableCode(0xFF00, "COLOR"), - new TextVariableCode(0x0100, "TRNAME"), - new TextVariableCode(0x0101, "PKNAME"), - new TextVariableCode(0x0102, "PKNICK"), - new TextVariableCode(0x0103, "TYPE"), - new TextVariableCode(0x0105, "LOCATION"), - new TextVariableCode(0x0106, "ABILITY"), - new TextVariableCode(0x0107, "MOVE"), - new TextVariableCode(0x0108, "ITEM1"), - new TextVariableCode(0x0109, "ITEM2"), - new TextVariableCode(0x010A, "sTRBAG"), - new TextVariableCode(0x010B, "BOX"), - new TextVariableCode(0x010D, "EVSTAT"), - new TextVariableCode(0x0110, "OPOWER"), - new TextVariableCode(0x0127, "RIBBON"), - new TextVariableCode(0x0134, "MIINAME"), - new TextVariableCode(0x013E, "WEATHER"), - new TextVariableCode(0x0189, "TRNICK"), - new TextVariableCode(0x018A, "1stchrTR"), - new TextVariableCode(0x018B, "SHOUTOUT"), - new TextVariableCode(0x018E, "BERRY"), - new TextVariableCode(0x018F, "REMFEEL"), - new TextVariableCode(0x0190, "REMQUAL"), - new TextVariableCode(0x0191, "WEBSITE"), - new TextVariableCode(0x019C, "CHOICECOS"), - new TextVariableCode(0x01A1, "GSYNCID"), - new TextVariableCode(0x0192, "PRVIDSAY"), - new TextVariableCode(0x0193, "BTLTEST"), - new TextVariableCode(0x0195, "GENLOC"), - new TextVariableCode(0x0199, "CHOICEFOOD"), - new TextVariableCode(0x019A, "HOTELITEM"), - new TextVariableCode(0x019B, "TAXISTOP"), - new TextVariableCode(0x019F, "MAISTITLE"), - new TextVariableCode(0x1000, "ITEMPLUR0"), - new TextVariableCode(0x1001, "ITEMPLUR1"), - new TextVariableCode(0x1100, "GENDBR"), - new TextVariableCode(0x1101, "NUMBRNCH"), - new TextVariableCode(0x1302, "iCOLOR2"), - new TextVariableCode(0x1303, "iCOLOR3"), - new TextVariableCode(0x0200, "NUM1"), - new TextVariableCode(0x0201, "NUM2"), - new TextVariableCode(0x0202, "NUM3"), - new TextVariableCode(0x0203, "NUM4"), - new TextVariableCode(0x0204, "NUM5"), - new TextVariableCode(0x0205, "NUM6"), - new TextVariableCode(0x0206, "NUM7"), - new TextVariableCode(0x0207, "NUM8"), - new TextVariableCode(0x0208, "NUM9"), + new(0xFF00, "COLOR"), + new(0x0100, "TRNAME"), + new(0x0101, "PKNAME"), + new(0x0102, "PKNICK"), + new(0x0103, "TYPE"), + new(0x0105, "LOCATION"), + new(0x0106, "ABILITY"), + new(0x0107, "MOVE"), + new(0x0108, "ITEM1"), + new(0x0109, "ITEM2"), + new(0x010A, "sTRBAG"), + new(0x010B, "BOX"), + new(0x010D, "EVSTAT"), + new(0x0110, "OPOWER"), + new(0x0127, "RIBBON"), + new(0x0134, "MIINAME"), + new(0x013E, "WEATHER"), + new(0x0189, "TRNICK"), + new(0x018A, "1stchrTR"), + new(0x018B, "SHOUTOUT"), + new(0x018E, "BERRY"), + new(0x018F, "REMFEEL"), + new(0x0190, "REMQUAL"), + new(0x0191, "WEBSITE"), + new(0x019C, "CHOICECOS"), + new(0x01A1, "GSYNCID"), + new(0x0192, "PRVIDSAY"), + new(0x0193, "BTLTEST"), + new(0x0195, "GENLOC"), + new(0x0199, "CHOICEFOOD"), + new(0x019A, "HOTELITEM"), + new(0x019B, "TAXISTOP"), + new(0x019F, "MAISTITLE"), + new(0x1000, "ITEMPLUR0"), + new(0x1001, "ITEMPLUR1"), + new(0x1100, "GENDBR"), + new(0x1101, "NUMBRNCH"), + new(0x1302, "iCOLOR2"), + new(0x1303, "iCOLOR3"), + new(0x0200, "NUM1"), + new(0x0201, "NUM2"), + new(0x0202, "NUM3"), + new(0x0203, "NUM4"), + new(0x0204, "NUM5"), + new(0x0205, "NUM6"), + new(0x0206, "NUM7"), + new(0x0207, "NUM8"), + new(0x0208, "NUM9"), }; } } \ No newline at end of file diff --git a/pkNX.Structures/Util.cs b/pkNX.Structures/Util.cs index 4e46335b..b7243cc2 100644 --- a/pkNX.Structures/Util.cs +++ b/pkNX.Structures/Util.cs @@ -7,7 +7,7 @@ namespace pkNX.Structures { public static class Util { - public static Random Rand { get; set; } = new Random(); + public static Random Rand { get; set; } = new(); internal static uint Rand32() => (uint)Rand.Next(1 << 30) << 2 | (uint)Rand.Next(1 << 2); private static T[] GetArray(IReadOnlyList entries, Func del) diff --git a/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs b/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs index aa465188..f1e15e6a 100644 --- a/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs +++ b/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs @@ -17,7 +17,7 @@ public sealed class TrData6AO : TrData6 public override int Item3 { get => BitConverter.ToUInt16(Data, 0x0C); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0C); } public override int Item4 { get => BitConverter.ToUInt16(Data, 0x0E); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0E); } public override uint AI { get => BitConverter.ToUInt32(Data, 0x10); set => BitConverter.GetBytes(value).CopyTo(Data, 0x10); } - public override bool Heal { get => Data[0x14] == 1; set => Data[0x14] = (byte)(value ? 1 : 0); } + public override bool Heal { get => Data[0x14] == 1; set => Data[0x14] = value ? 1 : 0; } public override int Money { get => Data[0x15]; set => Data[0x15] = (byte)value; } public override int Gift { get => BitConverter.ToUInt16(Data, 0x16); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x16); } } diff --git a/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs b/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs index f29ff877..5da71acf 100644 --- a/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs +++ b/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs @@ -16,7 +16,7 @@ public sealed class TrData6XY : TrData6 public override int Item3 { get => BitConverter.ToUInt16(Data, 0x08); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x08); } public override int Item4 { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } public override uint AI { get => BitConverter.ToUInt32(Data, 0x0C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x0C); } - public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = (byte)(value ? 1 : 0); } + public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = value ? 1 : 0; } public override int Money { get => Data[0x11]; set => Data[0x11] = (byte)value; } public override int Gift { get => BitConverter.ToUInt16(Data, 0x12); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); } } diff --git a/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs index 81cf9be2..e3832101 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs @@ -5,10 +5,10 @@ public class TrainerClass7b : TrainerClass public sealed override int SIZE => 0x24; public TrainerClass7b(byte[] data = null) => Data = data ?? new byte[SIZE]; - public byte _0x00 { get => Data[0]; set => Data[0] = value; } + public byte Unk_0x00 { get => Data[0]; set => Data[0] = value; } public override int Group { get => Data[1]; set => Data[1] = (byte)value; } public override int BallID { get => Data[2]; set => Data[2] = (byte)value; } - public byte _0x03 { get => Data[3]; set => Data[3] = value; } + public byte Unk_0x03 { get => Data[3]; set => Data[3] = value; } // model hash at end (name, form, variation)? diff --git a/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs b/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs index e2e36c08..08e3b00d 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs @@ -13,10 +13,10 @@ public class TrainerClass8 : TrainerClass public sealed override int SIZE => 280; public TrainerClass8(byte[] data = null) => Data = data ?? new byte[SIZE]; - public byte _0x00 { get => Data[0]; set => Data[0] = value; } // bool? + public byte Unk_0x00 { get => Data[0]; set => Data[0] = value; } // bool? public override int Group { get => Data[1]; set => Data[1] = (byte)value; } public override int BallID { get => Data[2]; set => Data[2] = (byte)value; } - public byte _0x03 { get => Data[3]; set => Data[3] = value; } // bool? + public byte Unk_0x03 { get => Data[3]; set => Data[3] = value; } // bool? // model hash (name, form, variation)? public byte[] Hash => Data.Slice(0x8, 0x10); diff --git a/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs index dc189bfe..25330b23 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs @@ -16,7 +16,7 @@ public sealed class TrainerData7b : TrainerData public override int Item4 { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } public override uint AI { get => BitConverter.ToUInt32(Data, 0x0C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x0C); } - public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = (byte)(value ? 1 : 0); } // unused? + public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = value ? 1 : 0; } // unused? public override int Money { get => Data[0x11]; set => Data[0x11] = (byte)value; } // 12 unused diff --git a/pkNX.Structures/VsTrainer/GG/TrainerData8.cs b/pkNX.Structures/VsTrainer/GG/TrainerData8.cs index 92ff3ffb..ea6e25d7 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerData8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerData8.cs @@ -16,7 +16,7 @@ public sealed class TrainerData8 : TrainerData public override int Item4 { get => BitConverter.ToUInt16(Data, 0x0A); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0A); } public override uint AI { get => BitConverter.ToUInt32(Data, 0x0C); set => BitConverter.GetBytes(value).CopyTo(Data, 0x0C); } - public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = (byte)(value ? 1 : 0); } // unused? + public override bool Heal { get => Data[0x10] == 1; set => Data[0x10] = value ? 1 : 0; } // unused? public override int Money { get => Data[0x11]; set => Data[0x11] = (byte)value; } public override int Gift { get => BitConverter.ToUInt16(Data, 0x12); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x12); } // unused? diff --git a/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs index 34425618..1492856f 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs @@ -60,7 +60,7 @@ public override int Ability public override int IV_SPE { get => (int)(IV32 >> 15) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } public override int IV_SPA { get => (int)(IV32 >> 20) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } public override int IV_SPD { get => (int)(IV32 >> 25) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } - public override bool Shiny { get => ((IV32 >> 30) & 1) == 1; set => IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } + public override bool Shiny { get => ((IV32 >> 30) & 1) == 1; set => IV32 = (IV32 & ~0x40000000u) | (value ? 0x40000000u : 0); } public override bool CanMegaEvolve { diff --git a/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs b/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs index 5f40610c..5332d35b 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs @@ -75,7 +75,7 @@ public override int Ability public override int IV_SPE { get => (int)(IV32 >> 15) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 15)) | (uint)((value > 31 ? 31 : value) << 15)); } public override int IV_SPA { get => (int)(IV32 >> 20) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 20)) | (uint)((value > 31 ? 31 : value) << 20)); } public override int IV_SPD { get => (int)(IV32 >> 25) & 0x1F; set => IV32 = (uint)((IV32 & ~(0x1F << 25)) | (uint)((value > 31 ? 31 : value) << 25)); } - public override bool Shiny { get => ((IV32 >> 30) & 1) == 1; set => IV32 = (uint)((IV32 & ~0x40000000) | (uint)(value ? 0x40000000 : 0)); } + public override bool Shiny { get => ((IV32 >> 30) & 1) == 1; set => IV32 = (IV32 & ~0x40000000u) | (value ? 0x40000000u : 0); } public override bool CanDynamax { diff --git a/pkNX.Structures/VsTrainer/VsTrainer.cs b/pkNX.Structures/VsTrainer/VsTrainer.cs index 4baefa03..7c1e044b 100644 --- a/pkNX.Structures/VsTrainer/VsTrainer.cs +++ b/pkNX.Structures/VsTrainer/VsTrainer.cs @@ -7,7 +7,7 @@ public class VsTrainer public int ID { get; set; } public string Name { get; set; } public TrainerData Self { get; set; } - public readonly List Team = new List(6); + public readonly List Team = new(6); public TrainerClass GetClass(IList list) => list[Self.Class]; } diff --git a/pkNX.WinForms/Controls/StatEditor.cs b/pkNX.WinForms/Controls/StatEditor.cs index 6b3c779c..ffb4977b 100644 --- a/pkNX.WinForms/Controls/StatEditor.cs +++ b/pkNX.WinForms/Controls/StatEditor.cs @@ -119,7 +119,7 @@ public void LoadStats(StatPKM pkm) private void UpdateIV(object sender, EventArgs e) { - if (UpdatingFields || !(sender is MaskedTextBox t)) + if (UpdatingFields || sender is not MaskedTextBox t) return; var index = Array.IndexOf(tb_iv, t); if (index < 0) @@ -134,7 +134,7 @@ private void UpdateIV(object sender, EventArgs e) private void UpdateEV(object sender, EventArgs e) { - if (UpdatingFields || !(sender is MaskedTextBox t)) + if (UpdatingFields || sender is not MaskedTextBox t) return; var index = Array.IndexOf(tb_ev, t); if (index < 0) @@ -146,7 +146,7 @@ private void UpdateEV(object sender, EventArgs e) private void UpdateAV(object sender, EventArgs e) { - if (UpdatingFields || !(sender is MaskedTextBox t) || !(PKM is IAwakened a)) + if (UpdatingFields || sender is not MaskedTextBox t || PKM is not IAwakened a) return; var index = Array.IndexOf(tb_av, t); if (index < 0) diff --git a/pkNX.WinForms/Dumping/FlatBufferConverter.cs b/pkNX.WinForms/Dumping/FlatBufferConverter.cs index 92ec537c..212e11b0 100644 --- a/pkNX.WinForms/Dumping/FlatBufferConverter.cs +++ b/pkNX.WinForms/Dumping/FlatBufferConverter.cs @@ -159,7 +159,7 @@ public static string WriteJson(T obj) public static byte[] GetSchema(string name) { var obj = Resources.ResourceManager.GetObject(name); - if (!(obj is byte[] b)) + if (obj is not byte[] b) throw new FileNotFoundException(nameof(name)); return b; } diff --git a/pkNX.WinForms/MainEditor/EditUtil.cs b/pkNX.WinForms/MainEditor/EditUtil.cs index cc94c9d2..c683d21d 100644 --- a/pkNX.WinForms/MainEditor/EditUtil.cs +++ b/pkNX.WinForms/MainEditor/EditUtil.cs @@ -11,11 +11,11 @@ namespace pkNX.WinForms [Serializable] public class SharedSettings { - public PersonalRandSettings Personal { get; set; } = new PersonalRandSettings(); - public SpeciesSettings Species { get; set; } = new SpeciesSettings(); - public TrainerRandSettings Trainer { get; set; } = new TrainerRandSettings(); - public MovesetRandSettings Move { get; set; } = new MovesetRandSettings(); - public LearnSettings Learn { get; set; } = new LearnSettings(); + public PersonalRandSettings Personal { get; set; } = new(); + public SpeciesSettings Species { get; set; } = new(); + public TrainerRandSettings Trainer { get; set; } = new(); + public MovesetRandSettings Move { get; set; } = new(); + public LearnSettings Learn { get; set; } = new(); } public static class EditUtil diff --git a/pkNX.WinForms/Ripper/FileRipper.cs b/pkNX.WinForms/Ripper/FileRipper.cs index 6e7120e4..d8917b15 100644 --- a/pkNX.WinForms/Ripper/FileRipper.cs +++ b/pkNX.WinForms/Ripper/FileRipper.cs @@ -17,10 +17,10 @@ public enum RipResultCode public static class FileRipper { - public static ContainerHandler DefaultHandler { private get; set; } = new ContainerHandler(); + public static ContainerHandler DefaultHandler { private get; set; } = new(); public static readonly List> Loaders = - new List> + new() { GFPackDump, NSODump, @@ -72,8 +72,7 @@ public static FileRipperResult TryOpenFile(string path, ContainerHandler handler if (!File.Exists(path)) return new FileRipperResult(RipResultCode.FileExist); - if (handler == null) - handler = DefaultHandler; + handler ??= DefaultHandler; try { diff --git a/pkNX.WinForms/Subforms/GGWE.cs b/pkNX.WinForms/Subforms/GGWE.cs index 2a164228..747133b3 100644 --- a/pkNX.WinForms/Subforms/GGWE.cs +++ b/pkNX.WinForms/Subforms/GGWE.cs @@ -97,7 +97,7 @@ private static IEnumerable GetScreenedNames(IEnumerable names) } } - private static readonly Dictionary LocIDTable = new Dictionary + private static readonly Dictionary LocIDTable = new() { ["forest001"] = 39, ["r004d0101"] = 40, @@ -412,7 +412,7 @@ void ApplyRand(IList slots) } } - public static readonly Dictionary RandomScaledRates = new Dictionary + public static readonly Dictionary RandomScaledRates = new() { [01] = new[] {100}, [04] = new[] {60, 30, 7, 3}, diff --git a/pkNX.WinForms/Subforms/SSWE.cs b/pkNX.WinForms/Subforms/SSWE.cs index 93cae9c0..cbb5fc50 100644 --- a/pkNX.WinForms/Subforms/SSWE.cs +++ b/pkNX.WinForms/Subforms/SSWE.cs @@ -199,7 +199,7 @@ void ApplyRand(IList slots) } } - public static readonly Dictionary RandomScaledRates = new Dictionary + public static readonly Dictionary RandomScaledRates = new() { [01] = new[] {100}, [04] = new[] {60, 30, 7, 3},