From b1c0beff74df70205239ca159af675dedd1afb37 Mon Sep 17 00:00:00 2001 From: Kurt Date: Sat, 24 Oct 2015 16:52:25 -0700 Subject: [PATCH] Send "chunk uninitialized detection" to class yeah, get educated. --- Misc/SAV6.cs | 23 +++++++++++++++++++++++ PKX/f1-Main.cs | 21 +++------------------ 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/Misc/SAV6.cs b/Misc/SAV6.cs index e3331adcd..3a1da722f 100644 --- a/Misc/SAV6.cs +++ b/Misc/SAV6.cs @@ -471,5 +471,28 @@ p.IsNicknamed ascending for (int i = 0; i < len; i++) setData(sorted[i], Box + i * PK6.SIZE_STORED); } + + // Writeback Validity + public string checkChunkFF() + { + string r = ""; + byte[] FFFF = Enumerable.Repeat((byte)0xFF, 0x200).ToArray(); + for (int i = 0; i < Data.Length / 0x200; i++) + { + if (!FFFF.SequenceEqual(Data.Skip(i * 0x200).Take(0x200))) continue; + r = String.Format("0x200 chunk @ 0x{0} is FF'd.", (i * 0x200).ToString("X5")) + + Environment.NewLine + "Cyber will screw up (as of August 31st 2014)." + Environment.NewLine + Environment.NewLine; + + // Check to see if it is in the Pokedex + if (i * 0x200 > PokeDex && i * 0x200 < PokeDex + 0x900) + { + r += "Problem lies in the Pokedex. "; + if (i * 0x200 == PokeDex + 0x400) + r += "Remove a language flag for a species < 585, ie Petilil"; + } + break; + } + return r; + } } } diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 465eba0e7..dcc486645 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -2397,24 +2397,9 @@ private void clickExportSAV(object sender, EventArgs e) byte[] sav = SAV.Write(); // Chunk Error Checking - byte[] FFFF = Enumerable.Repeat((byte)0xFF, 0x200).ToArray(); - for (int i = 0; i < sav.Length / 0x200; i++) - { - if (!FFFF.SequenceEqual(sav.Skip(i*0x200).Take(0x200))) continue; - string problem = String.Format("0x200 chunk @ 0x{0} is FF'd.", (i * 0x200).ToString("X5")) - + Environment.NewLine + "Cyber will screw up (as of August 31st)." + Environment.NewLine + Environment.NewLine; - - // Check to see if it is in the Pokedex - if (i * 0x200 > SAV.PokeDex && i * 0x200 < SAV.PokeDex + 0x900) - { - problem += "Problem lies in the Pokedex. "; - if (i * 0x200 == SAV.PokeDex + 0x400) - problem += "Remove a language flag for a species ~ ex " + specieslist[548]; - } - - if (Util.Prompt(MessageBoxButtons.YesNo, problem, "Continue saving?") != DialogResult.Yes) - return; - } + string err = SAV.checkChunkFF(); + if (err.Length > 0 && Util.Prompt(MessageBoxButtons.YesNo, err, "Continue saving?") != DialogResult.Yes) + return; SaveFileDialog cySAV = new SaveFileDialog(); // Try for file path