mirror of
https://github.com/Manu098vm/Switch-Gift-Data-Manager.git
synced 2026-03-21 17:34:31 -05:00
Handle WCID editing for GiftType9.Pokemon
This commit is contained in:
parent
32480c8c9b
commit
eab6cb1f71
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user