shithub: choc

Download patch

ref: a8839cecaa12fc3d9afb2bad0863b7b97901bc4c
parent: a854f3e246be1373200a296413b31ece296c2914
author: Simon Howard <[email protected]>
date: Sat Dec 25 16:51:24 EST 2010

Pass through all command line arguments specified to the setup tool to
the game, to match Vanilla behavior (thanks AlexXav).

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2227

--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@
        removed from the title of the dialog box that appears on
        Windows when this happens.  This is desirable as not all such
        messages are actually errors (thanks Proteh).
+     * The setup tool now passes through all command line arguments
+       when launching the game (thanks AlexXav).
 
     Bugs fixed:
      * A workaround has been a bug in old versions of SDL_mixer
--- a/setup/execute.c
+++ b/setup/execute.c
@@ -101,6 +101,42 @@
     return result;
 }
 
+static int ArgumentNeedsEscape(char *arg)
+{
+    char *p;
+
+    for (p = arg; *p != '\0'; ++p)
+    {
+        if (isspace(*p))
+        {
+            return 1;
+        }
+    }
+
+    return 0;
+}
+
+// Arguments passed to the setup tool should be passed through to the
+// game when launching a game.  Calling this adds all arguments from
+// myargv to the output context.
+
+void PassThroughArguments(execute_context_t *context)
+{
+    int i;
+
+    for (i = 1; i < myargc; ++i)
+    {
+        if (ArgumentNeedsEscape(myargv[i]))
+        {
+            AddCmdLineParameter(context, "\"%s\"", myargv[i]);
+        }
+        else
+        {
+            AddCmdLineParameter(context, "%s", myargv[i]);
+        }
+    }
+}
+
 execute_context_t *NewExecuteContext(void)
 {
     execute_context_t *result;
@@ -117,25 +153,6 @@
     }
     
     return result;
-}
-
-void AddConfigParameters(execute_context_t *context)
-{
-    int p;
-
-    p = M_CheckParm("-config");
-
-    if (p > 0)
-    {
-        AddCmdLineParameter(context, "-config \"%s\"", myargv[p + 1]);
-    }
-
-    p = M_CheckParm("-extraconfig");
-
-    if (p > 0)
-    {
-        AddCmdLineParameter(context, "-extraconfig \"%s\"", myargv[p + 1]);
-    }
 }
 
 void AddCmdLineParameter(execute_context_t *context, char *s, ...)
--- a/setup/execute.h
+++ b/setup/execute.h
@@ -35,7 +35,7 @@
 
 execute_context_t *NewExecuteContext(void);
 void AddCmdLineParameter(execute_context_t *context, char *s, ...);
-void AddConfigParameters(execute_context_t *context);
+void PassThroughArguments(execute_context_t *context);
 int ExecuteDoom(execute_context_t *context);
 int FindInstalledIWADs(void);
 
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -152,7 +152,7 @@
     // Launch Doom
 
     exec = NewExecuteContext();
-    AddConfigParameters(exec);
+    PassThroughArguments(exec);
     ExecuteDoom(exec);
 
     exit(0);
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -265,7 +265,7 @@
     TXT_Shutdown();
     
     M_SaveDefaults();
-    AddConfigParameters(exec);
+    PassThroughArguments(exec);
 
     ExecuteDoom(exec);
 
@@ -702,7 +702,7 @@
     
     M_SaveDefaults();
 
-    AddConfigParameters(exec);
+    PassThroughArguments(exec);
 
     ExecuteDoom(exec);