diff --git a/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs b/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs index e42237a..635832e 100644 --- a/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs +++ b/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs @@ -126,8 +126,28 @@ namespace SwitchGiftDataManager.Core public override void SetID(ushort wcid) { + var pkEdited = false; + //Wondercard ID in Gen 9 also influence the TID and SID of Pokémon Entities + if (Type is GiftType9 t9 && t9 is GiftType9.Pokemon) + { + //Old FullTID + var ftid = BinaryPrimitives.ReadUInt32LittleEndian(Data.AsSpan(TIDOffset)) - (0xF4240 * (uint)WCID); + + //Recalculate the TID and SID (FullTID) to account for the new Wondercard ID + BinaryPrimitives.WriteUInt32LittleEndian(Data.AsSpan(TIDOffset), ftid + (1000000u * (uint)wcid)); + + pkEdited = true; + } + + //Write the new Wondercard ID BinaryPrimitives.WriteUInt16LittleEndian(Data.AsSpan(WondercardIDOffset), wcid); WCID = wcid; + + //Reload Pokémon content + if (pkEdited) + Content = GetPokemon(); + + //Refresh card checksum UpdateChecksum(); } diff --git a/SwitchGiftDataManager.WinForm/MainWindow.cs b/SwitchGiftDataManager.WinForm/MainWindow.cs index ea78c9e..5af240f 100644 --- a/SwitchGiftDataManager.WinForm/MainWindow.cs +++ b/SwitchGiftDataManager.WinForm/MainWindow.cs @@ -199,35 +199,19 @@ namespace SwitchGiftDataManager.WinForm if (wcid != list.GetWCID(ListBoxWC.SelectedIndex)) { - var proceed = true; - if (CurrentGame is Games.SCVI) + var index = list.GetIndex(wcid); + if (index == -1) { - var warning = "WARNING\n\n" + - "WCID editings in SV wondercards might impact the entity's TID and SID, resulting in an illegal Pokémon.\n" + - "Do not share Pokémon obtained with the use of edited wondercards.\n" + - "\nDo you want to coninue?"; - var disclaimer = MessageBox.Show(warning, "Disclaimer", MessageBoxButtons.YesNo); - - if (disclaimer == DialogResult.No) - proceed = false; + list.SetWCID(ListBoxWC.SelectedIndex, wcid); + list.Sort(); + UpdateWCList(); + ListBoxWC.SelectedIndex = list.GetIndex(wcid); + BtnApply.Enabled = false; } - - if (proceed) + else { - var index = list.GetIndex(wcid); - if (index == -1) - { - list.SetWCID(ListBoxWC.SelectedIndex, wcid); - list.Sort(); - UpdateWCList(); - ListBoxWC.SelectedIndex = list.GetIndex(wcid); - BtnApply.Enabled = false; - } - else - { - MessageBox.Show($"WCID {wcid} already exists."); - return; - } + MessageBox.Show($"WCID {wcid} already exists."); + return; } }