From 2c523dcd973c0b7b2bee2cbcff6b68fe24cf2041 Mon Sep 17 00:00:00 2001 From: Kaphotics Date: Thu, 21 Apr 2016 18:47:51 -0700 Subject: [PATCH] Allow wc6fulls to be added to DB Minor load/save improvements --- PKX/f1-Main.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index 2ac17f7ec..081b4c104 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -245,6 +245,7 @@ private void mainMenuOpen(object sender, EventArgs e) private void mainMenuSave(object sender, EventArgs e) { if (!verifiedPKX()) return; + PK6 pk = preparepkx(); SaveFileDialog sfd = new SaveFileDialog { Filter = "PKX File|*.pk6;*.pkx" + @@ -252,7 +253,7 @@ private void mainMenuSave(object sender, EventArgs e) "|BIN File|*.bin" + "|All Files|*.*", DefaultExt = "pk6", - FileName = TB_Nickname.Text + " - " + TB_PID.Text + FileName = Util.CleanFileName(pk.FileName) }; if (sfd.ShowDialog() != DialogResult.OK) return; string path = sfd.FileName; @@ -267,7 +268,6 @@ private void mainMenuSave(object sender, EventArgs e) File.WriteAllBytes(path + ".bak", backupfile); } - PK6 pk = preparepkx(); if (new[] {".ekx", ".ek6", ".bin"}.Contains(ext)) File.WriteAllBytes(path, pk.EncryptedPartyData); else if (new[] { ".pkx", ".pk6" }.Contains(ext)) @@ -560,6 +560,7 @@ private void openQuick(string path) try { openFile(input, path, ext); } catch { + if (input.Length <= PK6.SIZE_PARTY) try { byte[] blank = (byte[])blankEK6.Clone(); @@ -569,7 +570,9 @@ private void openQuick(string path) openFile(blank, path, ext); } - catch { openFile(input, path, ext); } + catch { try { openFile(input, path, ext); return; } catch {} } + + Util.Error("Unable to load file."); } } } @@ -852,7 +855,7 @@ private void refreshWC6DB() if (Directory.Exists(WC6DatabasePath)) wc6db.AddRange(from file in Directory.GetFiles(WC6DatabasePath, "*", SearchOption.AllDirectories) let fi = new FileInfo(file) - where fi.Extension == ".wc6" && fi.Length == WC6.Size + where new[] {".wc6full", ".wc6"}.Contains(fi.Extension) && new[] {WC6.Size, WC6.SizeFull}.Contains((int)fi.Length) select new WC6(File.ReadAllBytes(file))); Legal.WC6DB = wc6db.Distinct().ToArray();