From ddd68de72e10c5001d8d178245b18ace4f5d72bd Mon Sep 17 00:00:00 2001 From: biwa <6475593+biwa@users.noreply.github.com> Date: Sun, 17 Apr 2022 18:09:29 +0200 Subject: [PATCH] Command line arguments: - using "-map" with lower case parameter doesn't crash anymore - using "-cfg"/"-config" with a non-existing configuration file doesn't crash anymore --- Source/Core/General/General.cs | 2 +- Source/Core/Windows/MainForm.cs | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Core/General/General.cs b/Source/Core/General/General.cs index e9ba62c2..544ba8fc 100755 --- a/Source/Core/General/General.cs +++ b/Source/Core/General/General.cs @@ -831,7 +831,7 @@ namespace CodeImp.DoomBuilder else if(string.Compare(curarg, "-MAP", true) == 0) { // Store next arg as map name information - autoloadmap = argslist.Dequeue(); + autoloadmap = argslist.Dequeue()?.ToUpperInvariant(); } // Config name info? else if((string.Compare(curarg, "-CFG", true) == 0) || diff --git a/Source/Core/Windows/MainForm.cs b/Source/Core/Windows/MainForm.cs index cc29f7eb..d98e99b1 100755 --- a/Source/Core/Windows/MainForm.cs +++ b/Source/Core/Windows/MainForm.cs @@ -546,10 +546,11 @@ namespace CodeImp.DoomBuilder.Windows if(General.AutoLoadMap != null) { Configuration mapsettings; - + // Try to find existing options in the settings file - string dbsfile = General.AutoLoadFile.Substring(0, General.AutoLoadFile.Length - 4) + ".dbs"; - if(File.Exists(dbsfile)) + //string dbsfile = General.AutoLoadFile.Substring(0, General.AutoLoadFile.Length - 4) + ".dbs"; + string dbsfile = Path.ChangeExtension(General.AutoLoadFile, "dbs"); + if (File.Exists(dbsfile)) try { mapsettings = new Configuration(dbsfile, true); } catch(Exception) { mapsettings = new Configuration(true); } else @@ -557,8 +558,13 @@ namespace CodeImp.DoomBuilder.Windows //mxd. Get proper configuration file bool longtexturenamessupported = false; - string configfile = General.AutoLoadConfig; - if(string.IsNullOrEmpty(configfile)) configfile = mapsettings.ReadSetting("gameconfig", ""); + string configfile = null; + + // Make sure the config file exists + if(General.GetConfigurationInfo(General.AutoLoadConfig) != null) + configfile = General.AutoLoadConfig; + + if (string.IsNullOrEmpty(configfile)) configfile = mapsettings.ReadSetting("gameconfig", ""); if(configfile.Trim().Length == 0) { showdialog = true;