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
This commit is contained in:
biwa 2022-04-17 18:09:29 +02:00
parent ac57fecf0c
commit ddd68de72e
2 changed files with 12 additions and 6 deletions

View file

@ -831,7 +831,7 @@ namespace CodeImp.DoomBuilder
else if(string.Compare(curarg, "-MAP", true) == 0) else if(string.Compare(curarg, "-MAP", true) == 0)
{ {
// Store next arg as map name information // Store next arg as map name information
autoloadmap = argslist.Dequeue(); autoloadmap = argslist.Dequeue()?.ToUpperInvariant();
} }
// Config name info? // Config name info?
else if((string.Compare(curarg, "-CFG", true) == 0) || else if((string.Compare(curarg, "-CFG", true) == 0) ||

View file

@ -546,10 +546,11 @@ namespace CodeImp.DoomBuilder.Windows
if(General.AutoLoadMap != null) if(General.AutoLoadMap != null)
{ {
Configuration mapsettings; Configuration mapsettings;
// Try to find existing options in the settings file // Try to find existing options in the settings file
string dbsfile = General.AutoLoadFile.Substring(0, General.AutoLoadFile.Length - 4) + ".dbs"; //string dbsfile = General.AutoLoadFile.Substring(0, General.AutoLoadFile.Length - 4) + ".dbs";
if(File.Exists(dbsfile)) string dbsfile = Path.ChangeExtension(General.AutoLoadFile, "dbs");
if (File.Exists(dbsfile))
try { mapsettings = new Configuration(dbsfile, true); } try { mapsettings = new Configuration(dbsfile, true); }
catch(Exception) { mapsettings = new Configuration(true); } catch(Exception) { mapsettings = new Configuration(true); }
else else
@ -557,8 +558,13 @@ namespace CodeImp.DoomBuilder.Windows
//mxd. Get proper configuration file //mxd. Get proper configuration file
bool longtexturenamessupported = false; bool longtexturenamessupported = false;
string configfile = General.AutoLoadConfig; string configfile = null;
if(string.IsNullOrEmpty(configfile)) configfile = mapsettings.ReadSetting("gameconfig", "");
// 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) if(configfile.Trim().Length == 0)
{ {
showdialog = true; showdialog = true;