From 9aba68db7be1731ea86a7d9beb0620bdab1a0f65 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Tue, 11 Jul 2017 21:06:04 +0200 Subject: [PATCH] Reject ZWADs with an error message. --- Source/Core/IO/WAD.cs | 4 ++++ Source/Core/Windows/ChangeMapForm.cs | 8 ++++---- Source/Core/Windows/OpenMapOptionsForm.cs | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Source/Core/IO/WAD.cs b/Source/Core/IO/WAD.cs index 540a3e5..ac5907d 100644 --- a/Source/Core/IO/WAD.cs +++ b/Source/Core/IO/WAD.cs @@ -32,6 +32,7 @@ namespace CodeImp.DoomBuilder.IO // WAD types public const string TYPE_IWAD = "IWAD"; public const string TYPE_PWAD = "PWAD"; + public const string TYPE_ZWAD = "ZWAD"; // Encoder public static readonly Encoding ENCODING = Encoding.ASCII; @@ -194,6 +195,9 @@ namespace CodeImp.DoomBuilder.IO // Read WAD type type = ENCODING.GetString(reader.ReadBytes(4)); + + if (type == TYPE_ZWAD) + throw new IOException("Sorry, can't open ZWADs. Please decompress first."); // Number of lumps numlumps = reader.ReadInt32(); diff --git a/Source/Core/Windows/ChangeMapForm.cs b/Source/Core/Windows/ChangeMapForm.cs index 192b13f..522c4b6 100644 --- a/Source/Core/Windows/ChangeMapForm.cs +++ b/Source/Core/Windows/ChangeMapForm.cs @@ -45,11 +45,11 @@ namespace CodeImp.DoomBuilder.Windows // Open the WAD file wadfile = new WAD(filepathname, true); } - catch(Exception) + catch(Exception e) { - // Unable to open WAD file (or its config) - MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); - this.DialogResult = DialogResult.Cancel; + // Unable to open WAD file (or its config) + MessageBox.Show(this, "Could not open the WAD file for reading.\n" + e.GetType().Name + ": " + e.Message + "\nPlease make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); + this.DialogResult = DialogResult.Cancel; this.Close(); return; } diff --git a/Source/Core/Windows/OpenMapOptionsForm.cs b/Source/Core/Windows/OpenMapOptionsForm.cs index 7960737..cfcfe6f 100644 --- a/Source/Core/Windows/OpenMapOptionsForm.cs +++ b/Source/Core/Windows/OpenMapOptionsForm.cs @@ -90,10 +90,10 @@ namespace CodeImp.DoomBuilder.Windows // Open the WAD file wadfile = new WAD(filepathname, true); } - catch(Exception) + catch(Exception e) { - // Unable to open WAD file (or its config) - MessageBox.Show(this, "Could not open the WAD file for reading. Please make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); + // Unable to open WAD file (or its config) + MessageBox.Show(this, "Could not open the WAD file for reading.\n" + e.GetType().Name + ": " + e.Message + "\nPlease make sure the file you selected is valid and is not in use by any other application.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); if(wadfile != null) wadfile.Dispose(); this.DialogResult = DialogResult.Cancel; this.Close();