From bbd1aff5fe24ec85ea708466f7121940c06a66ef Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 9 Jan 2020 08:17:41 -0800 Subject: [PATCH] Add new lengths new format still crashes as block absolute index is now different should do a different way of loading blocks (key instead of index) --- PKHeX.Core/Saves/MemeCrypto/SwishCrypto.cs | 2 +- PKHeX.Core/Saves/Util/SaveUtil.cs | 5 +++-- PKHeX.Core/Util/FileUtil.cs | 2 +- PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs | 6 ++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/PKHeX.Core/Saves/MemeCrypto/SwishCrypto.cs b/PKHeX.Core/Saves/MemeCrypto/SwishCrypto.cs index 301d7c1b7..7e87ba3ac 100644 --- a/PKHeX.Core/Saves/MemeCrypto/SwishCrypto.cs +++ b/PKHeX.Core/Saves/MemeCrypto/SwishCrypto.cs @@ -74,7 +74,7 @@ private static byte[] ComputeHash(byte[] data) /// True if hash matches public static bool GetIsHashValid(byte[] data) { - if (data.Length != SaveUtil.SIZE_G8SWSH) + if (data.Length != SaveUtil.SIZE_G8SWSH && data.Length != SaveUtil.SIZE_G8SWSH_1) return false; var hash = ComputeHash(data); diff --git a/PKHeX.Core/Saves/Util/SaveUtil.cs b/PKHeX.Core/Saves/Util/SaveUtil.cs index 3c5c76c7b..2c96edc4a 100644 --- a/PKHeX.Core/Saves/Util/SaveUtil.cs +++ b/PKHeX.Core/Saves/Util/SaveUtil.cs @@ -17,6 +17,7 @@ public static class SaveUtil public const int BEEF = 0x42454546; public const int SIZE_G8SWSH = 0x1716B3; + public const int SIZE_G8SWSH_1 = 0x17195E; public const int SIZE_G7GG = 0x100000; public const int SIZE_G7USUM = 0x6CC00; public const int SIZE_G7SM = 0x6BE00; @@ -60,7 +61,7 @@ public static class SaveUtil private static readonly HashSet SIZES = new HashSet(SIZES_2) { - SIZE_G8SWSH, + SIZE_G8SWSH, SIZE_G8SWSH_1, SIZE_G7SM, SIZE_G7USUM, SIZE_G7GG, SIZE_G6XY, SIZE_G6ORAS, SIZE_G6ORASDEMO, SIZE_G5RAW, SIZE_G5BW, SIZE_G5B2W2, @@ -443,7 +444,7 @@ private static GameVersion GetIsBelugaSAV(byte[] data) /// Version Identifier or Invalid if type cannot be determined. private static GameVersion GetIsG8SAV(byte[] data) { - if (data.Length != SIZE_G8SWSH) + if (data.Length != SIZE_G8SWSH && data.Length != SIZE_G8SWSH_1) return Invalid; return SwishCrypto.GetIsHashValid(data) ? SWSH : Invalid; diff --git a/PKHeX.Core/Util/FileUtil.cs b/PKHeX.Core/Util/FileUtil.cs index 995eb988b..e1036165f 100644 --- a/PKHeX.Core/Util/FileUtil.cs +++ b/PKHeX.Core/Util/FileUtil.cs @@ -80,7 +80,7 @@ public static bool IsFileTooBig(long length) { if (length <= 0x100000) return false; - if (length == SaveUtil.SIZE_G4BR || length == SaveUtil.SIZE_G8SWSH) + if (length == SaveUtil.SIZE_G4BR || length == SaveUtil.SIZE_G8SWSH ||length == SaveUtil.SIZE_G8SWSH_1) return false; if (SAV3GCMemoryCard.IsMemoryCardSize(length)) return false; // pbr/GC have size > 1MB diff --git a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs index 8fae012d8..85b07960d 100644 --- a/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs +++ b/PKHeX.WinForms/Controls/PKM Editor/PKMEditor.cs @@ -73,8 +73,8 @@ private void UpdateStats() private void SavePartyStats(PKM pk) { Stats.SavePartyStats(pk); - pk.Stat_Level = CurrentLevel; - } + pk.Stat_Level = Util.ToInt32((HaX ? MT_Level : TB_Level).Text); + } public PKM CurrentPKM { get => PreparePKM(); set => Entity = value; } public bool ModifyPKM { private get; set; } = true; @@ -102,7 +102,6 @@ public bool HideSecretValues public PKM Entity { get; private set; } public bool FieldsLoaded { get; private set; } public bool ChangingFields { get; set; } - public int CurrentLevel => Util.ToInt32((HaX ? MT_Level : TB_Level).Text); private GameVersion origintrack; private Action GetFieldsfromPKM; @@ -121,7 +120,6 @@ public bool HideSecretValues private readonly PictureBox[] movePB, relearnPB; public SaveFile RequestSaveFile => SaveFileRequested?.Invoke(this, EventArgs.Empty); public bool PKMIsUnsaved => FieldsLoaded && LastData?.Any(b => b != 0) == true && !LastData.SequenceEqual(CurrentPKM.Data); - public bool IsEmptyOrEgg => CHK_IsEgg.Checked || CB_Species.SelectedIndex == 0; private readonly ComboBox[] Moves, Relearn, ValidationRequired, PPUps; private readonly MaskedTextBox[] MovePP;