diff --git a/PKHeX.Core/Editing/PKM/QR/QRMessageUtil.cs b/PKHeX.Core/Editing/PKM/QR/QRMessageUtil.cs index 19fa5730d..9bb9e9b66 100644 --- a/PKHeX.Core/Editing/PKM/QR/QRMessageUtil.cs +++ b/PKHeX.Core/Editing/PKM/QR/QRMessageUtil.cs @@ -37,17 +37,21 @@ public static class QRMessageUtil public static string GetMessage(PKM pk) { if (pk is PK7 pk7) - { - Span payload = stackalloc byte[QR7.SIZE]; - QR7.SetQRData(pk7, payload); - return GetMessage(payload); - } + return GetMessage(pk7); var server = GetExploitURLPrefixPKM(pk.Format); var data = pk.EncryptedBoxData; return GetMessageBase64(data, server); } + /// + public static string GetMessage(PK7 pk7, int box = 0, int slot = 0, int num_copies = 1) + { + Span data = stackalloc byte[QR7.SIZE]; + QR7.SetQRData(pk7, data, box, slot, num_copies); + return GetMessage(data); + } + /// /// Gets a QR Message from the input data. /// diff --git a/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs b/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs index b6e6888bf..2538ee915 100644 --- a/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs +++ b/PKHeX.Core/Saves/Substructures/Gen7/QR7.cs @@ -9,8 +9,9 @@ namespace PKHeX.Core; // u32 slot; // u32 num_copies; // u8 reserved[0x1C]; -// u8 ek7[0x104]; -// u8 dex_data[0x60]; +// u8 ek7[0x104]; -- starts at 0x30 +// u8 alignment[0xC]; +// u8 dex_data[0x60]; -- starts at 0x140 // u16 crc16 // sizeof(QR7) == 0x1A2 @@ -43,7 +44,7 @@ private static bool IsGenderDifferent(ushort species) return (table[index] & (1 << (species & 7))) != 0; } - private static void GetRawQR(Span dest, ushort species, byte form, bool shiny, byte gender) + private static void SetDexData(Span dest, ushort species, byte form, bool shiny, byte gender) { dest[..6].Fill(0xFF); WriteUInt16LittleEndian(dest[0x28..], species); @@ -86,7 +87,7 @@ public static void SetQRData(PK7 pk7, Span span, int box = 0, int slot = 0 WriteInt32LittleEndian(span[0x10..], num_copies); // No need to check max num_copies, payload parser handles it on-console. pk7.EncryptedPartyData.CopyTo(span[0x30..]); // Copy in pokemon data - GetRawQR(span[0x140..], pk7.Species, pk7.Form, pk7.IsShiny, pk7.Gender); + SetDexData(span[0x140..], pk7.Species, pk7.Form, pk7.IsShiny, pk7.Gender); var chk = Checksums.CRC16Invert(span[..0x1A0]); WriteUInt16LittleEndian(span[0x1A0..], chk); diff --git a/PKHeX.Drawing.Misc/QR/QREncode.cs b/PKHeX.Drawing.Misc/QR/QREncode.cs index 5cd501d03..ddd911168 100644 --- a/PKHeX.Drawing.Misc/QR/QREncode.cs +++ b/PKHeX.Drawing.Misc/QR/QREncode.cs @@ -32,11 +32,7 @@ public static class QREncode /// The number of copies to encode. /// A bitmap containing the QR code. public static Bitmap GenerateQRCode7(PK7 pk7, int box = 0, int slot = 0, int copies = 1) - { - byte[] data = QR7.GenerateQRData(pk7, box, slot, copies); - var msg = QRMessageUtil.GetMessage(data); - return GenerateQRCode(msg, ppm: 4); - } + => GenerateQRCode(QRMessageUtil.GetMessage(pk7, box, slot, copies), ppm: 4); /// /// Generates a QR code bitmap from a message string.