From f6bddf6fce6dc22a7076b90ac8675867bb436a40 Mon Sep 17 00:00:00 2001 From: Kurt Date: Wed, 14 Oct 2015 18:45:45 -0700 Subject: [PATCH] Ramsav/Powersave cleanup Old code which is unnecessary. --- PKX/f1-Main.cs | 38 ++++++-------------------------------- SAV/SAV_Trainer.cs | 2 +- 2 files changed, 7 insertions(+), 33 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index c18bbf72a..2d84db6e1 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -191,7 +191,6 @@ public Main() public static byte[] originalSAV; // original save public static byte[] powersave; // raw Powersave file public static byte[] ramsav; - public static bool ramsavloaded; public static bool savedited; public string pathSDF; public string path3DS; @@ -603,7 +602,8 @@ private void openFile(byte[] input, string path, string ext) } private void openMAIN(byte[] input, string path, string GameType, bool oras, bool ram = false) { - ramsavloaded = ram; + if (!ram) + ramsav = null; L_Save.Text = "SAV: " + Path.GetFileName(path); SaveGame = new PKX.SaveGame(GameType); @@ -617,15 +617,13 @@ private void openMAIN(byte[] input, string path, string GameType, bool oras, boo } private void open1MB(byte[] input, string path, string GameType, bool oras) { - ramsavloaded = false; + ramsav = null; L_Save.Text = "SAV: " + Path.GetFileName(path); SaveGame = new PKX.SaveGame(GameType); powersave = input; savefile = input.Skip(0x5400).Take(oras ? 0x76000 : 0x65600).ToArray(); - getSAVOffsets(ref oras); // to detect if we are ORAS or not - openSave(oras); } private bool openXOR(byte[] input, string path) @@ -689,7 +687,7 @@ private void openSave(bool oras) savedited = false; Menu_ToggleBoxUI.Visible = false; - B_VerifyCHK.Enabled = !ramsavloaded; + B_VerifyCHK.Enabled = ramsav != null; DaycareSlot = 0; setBoxNames(); // Display the Box Names @@ -2491,7 +2489,7 @@ private void clickExportSAV(object sender, EventArgs e) } // Export - if (ramsavloaded && ModifierKeys == Keys.Shift) // Export RAM SAV to another. + if (ramsav != null && ModifierKeys == Keys.Shift) // Export RAM SAV to another. { Util.Alert("Please specify the target cart/console-RAM save."); OpenFileDialog ofd = new OpenFileDialog(); @@ -2508,7 +2506,7 @@ private void clickExportSAV(object sender, EventArgs e) File.WriteAllBytes(path, newRAM); Util.Alert("Saved RAM SAV to:" + Environment.NewLine + path, "Target RAM:" + Environment.NewLine + target); } - else if (ramsavloaded && ModifierKeys != Keys.Control) // Export RAM SAV if it is the currently loaded one. + else if (ramsav != null && ModifierKeys != Keys.Control) // Export RAM SAV if it is the currently loaded one. { cySAV.Filter = "ramsav|*.bin"; cySAV.FileName = "ramsav.bin"; @@ -2925,30 +2923,6 @@ private void setBoxNames() } CB_BoxSelect.SelectedIndex = selectedbox; // restore selected box } - private void getSAVOffsets(ref bool oras) - { - // Get the save file offsets for the input game - bool enableInterface = false; - if (savefile.Length == 0x65600 && BitConverter.ToUInt32(savefile, savefile.Length - 0x1F0) == 0x42454546) - { - enableInterface = true; - SaveGame = new PKX.SaveGame("XY"); - } - else if (savefile.Length == 0x76000 && BitConverter.ToUInt32(savefile, savefile.Length - 0x1F0) == 0x42454546) - { - enableInterface = true; - SaveGame = new PKX.SaveGame("ORAS"); - oras = true; - } - else - { - Util.Error("Unrecognized Save File loaded."); - SaveGame = new PKX.SaveGame("Error"); - } - - // Enable Buttons - GB_SAVtools.Enabled = B_JPEG.Enabled = B_VerifyCHK.Enabled = enableInterface; - } private void getQuickFiller(PictureBox pb, byte[] dslotdata = null) { if (!init) return; diff --git a/SAV/SAV_Trainer.cs b/SAV/SAV_Trainer.cs index ba711befc..36abce119 100644 --- a/SAV/SAV_Trainer.cs +++ b/SAV/SAV_Trainer.cs @@ -31,7 +31,7 @@ public SAV_Trainer() getComboBoxes(); getTextBoxes(); getBadges(); - GB_Map.Enabled = !Main.ramsavloaded; + GB_Map.Enabled = Main.ramsav != null; statdata = new[] { "0x000", "0x000", // Steps taken?