summaryrefslogtreecommitdiff
path: root/setup
diff options
context:
space:
mode:
authorSimon Howard2010-12-25 21:51:24 +0000
committerSimon Howard2010-12-25 21:51:24 +0000
commita8839cecaa12fc3d9afb2bad0863b7b97901bc4c (patch)
tree39ad8934fb0bcd28060f849fda2d6b5917b014c3 /setup
parenta854f3e246be1373200a296413b31ece296c2914 (diff)
downloadchocolate-doom-a8839cecaa12fc3d9afb2bad0863b7b97901bc4c.tar.gz
chocolate-doom-a8839cecaa12fc3d9afb2bad0863b7b97901bc4c.tar.bz2
chocolate-doom-a8839cecaa12fc3d9afb2bad0863b7b97901bc4c.zip
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
Diffstat (limited to 'setup')
-rw-r--r--setup/execute.c55
-rw-r--r--setup/execute.h2
-rw-r--r--setup/mainmenu.c2
-rw-r--r--setup/multiplayer.c4
4 files changed, 40 insertions, 23 deletions
diff --git a/setup/execute.c b/setup/execute.c
index 8e753f60..69442b5d 100644
--- a/setup/execute.c
+++ b/setup/execute.c
@@ -101,6 +101,42 @@ static char *TempFile(char *s)
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;
@@ -119,25 +155,6 @@ execute_context_t *NewExecuteContext(void)
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, ...)
{
va_list args;
diff --git a/setup/execute.h b/setup/execute.h
index 24711a16..25f1f10a 100644
--- a/setup/execute.h
+++ b/setup/execute.h
@@ -35,7 +35,7 @@ typedef struct execute_context_s execute_context_t;
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);
diff --git a/setup/mainmenu.c b/setup/mainmenu.c
index 1c341d78..ae8ab9b0 100644
--- a/setup/mainmenu.c
+++ b/setup/mainmenu.c
@@ -152,7 +152,7 @@ static void LaunchDoom(void *unused1, void *unused2)
// Launch Doom
exec = NewExecuteContext();
- AddConfigParameters(exec);
+ PassThroughArguments(exec);
ExecuteDoom(exec);
exit(0);
diff --git a/setup/multiplayer.c b/setup/multiplayer.c
index 2cb961d7..eece16d4 100644
--- a/setup/multiplayer.c
+++ b/setup/multiplayer.c
@@ -265,7 +265,7 @@ static void StartGame(int multiplayer)
TXT_Shutdown();
M_SaveDefaults();
- AddConfigParameters(exec);
+ PassThroughArguments(exec);
ExecuteDoom(exec);
@@ -702,7 +702,7 @@ static void DoJoinGame(void *unused1, void *unused2)
M_SaveDefaults();
- AddConfigParameters(exec);
+ PassThroughArguments(exec);
ExecuteDoom(exec);