From 15c4e960970d8a217390ef8a3ce8fbf505dd0674 Mon Sep 17 00:00:00 2001 From: Kurt Date: Tue, 14 Jun 2022 17:29:47 -0700 Subject: [PATCH] Allow detection of ek6/ek7/eb7 from bytes --- PKHeX.Core/PKM/Util/EntityFormat.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/PKHeX.Core/PKM/Util/EntityFormat.cs b/PKHeX.Core/PKM/Util/EntityFormat.cs index d07aceb7b..c7d708cf9 100644 --- a/PKHeX.Core/PKM/Util/EntityFormat.cs +++ b/PKHeX.Core/PKM/Util/EntityFormat.cs @@ -48,11 +48,7 @@ private static EntityFormatDetected GetFormat67_PGT(ReadOnlySpan data) private static bool IsFormat67(ReadOnlySpan data) { if (ReadUInt16LittleEndian(data[0x04..]) != 0) // Bad Sanity? - return false; // non-zero ItemID - if (ReadUInt16LittleEndian(data[0x06..]) == GetCHK(data, SIZE_6STORED)) - return true; - if (ReadUInt16LittleEndian(data[0x58..]) != 0) // Not encrypted terminator - return false; + return false; // PGT with non-zero ItemID // PGT files have the last 0x10 bytes 00; PK6/etc will have data here. var tail = data[..^0x10]; @@ -61,6 +57,9 @@ private static bool IsFormat67(ReadOnlySpan data) if (b != 0) return true; } + + if (ReadUInt16LittleEndian(data[0x06..]) == GetCHK(data, SIZE_6STORED)) + return true; // decrypted return false; }