From afdd40bcee3ddca6354082e47a5197eef8dd4401 Mon Sep 17 00:00:00 2001 From: Kurt Date: Thu, 2 Jul 2020 17:44:03 -0500 Subject: [PATCH] Check counter rollover the opposite way FFFF and 0000 -> prefer 0000 FFFF and 0001 -> prefer 0001 ... FFFF and FFFE -> prefer FFFF they shouldn't be desync'd (incremental); only the uninitialized case is important to handle. --- PKHeX.Core/Saves/Substructures/Gen4/SAV4BlockDetection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PKHeX.Core/Saves/Substructures/Gen4/SAV4BlockDetection.cs b/PKHeX.Core/Saves/Substructures/Gen4/SAV4BlockDetection.cs index c186dc8d0..eaf20b9d1 100644 --- a/PKHeX.Core/Saves/Substructures/Gen4/SAV4BlockDetection.cs +++ b/PKHeX.Core/Saves/Substructures/Gen4/SAV4BlockDetection.cs @@ -35,10 +35,10 @@ public static int CompareFooters(byte[] data, int offset1, int offset2) private static int CompareCounters(uint counter1, uint counter2) { - // Uninitialized - if (counter1 == uint.MaxValue && counter2 == 0) + // Uninitialized -- only continue if a rollover case (humanly impossible) + if (counter1 == uint.MaxValue && counter2 != uint.MaxValue - 1) return Second; - if (counter1 == 0 && counter2 == uint.MaxValue) + if (counter2 == uint.MaxValue && counter1 != uint.MaxValue - 1) return First; // Different