summaryrefslogtreecommitdiff
path: root/src/setup
diff options
context:
space:
mode:
authorSimon Howard2009-05-08 19:15:25 +0000
committerSimon Howard2009-05-08 19:15:25 +0000
commit97f0be5d839ae5ec5b4c4d28dcf850f7afe08555 (patch)
treee6432180085f511fa4c6cc51978c03a2d297a8e8 /src/setup
parent86934db17860154f8fd9680bfca7e3a72669dc07 (diff)
downloadchocolate-doom-97f0be5d839ae5ec5b4c4d28dcf850f7afe08555.tar.gz
chocolate-doom-97f0be5d839ae5ec5b4c4d28dcf850f7afe08555.tar.bz2
chocolate-doom-97f0be5d839ae5ec5b4c4d28dcf850f7afe08555.zip
Choose appropriate executable depending on game type.
Subversion-branch: /branches/raven-branch Subversion-revision: 1514
Diffstat (limited to 'src/setup')
-rw-r--r--src/setup/execute.c17
-rw-r--r--src/setup/mode.c40
-rw-r--r--src/setup/mode.h1
3 files changed, 39 insertions, 19 deletions
diff --git a/src/setup/execute.c b/src/setup/execute.c
index 9846cd20..a43c3220 100644
--- a/src/setup/execute.c
+++ b/src/setup/execute.c
@@ -39,23 +39,10 @@
#include "config.h"
#include "execute.h"
+#include "mode.h"
#include "m_argv.h"
#include "m_config.h"
-#ifdef _WIN32
-#define DOOM_BINARY PACKAGE_TARNAME ".exe"
-#else
-#define DOOM_BINARY INSTALL_DIR "/" PACKAGE_TARNAME
-#endif
-
-#ifdef _WIN32
-#define DIR_SEPARATOR '\\'
-#define PATH_SEPARATOR ';'
-#else
-#define DIR_SEPARATOR '/'
-#define PATH_SEPARATOR ':'
-#endif
-
struct execute_context_s
{
char *response_file;
@@ -196,7 +183,7 @@ int ExecuteDoom(execute_context_t *context)
response_file_arg = malloc(strlen(context->response_file) + 2);
sprintf(response_file_arg, "@%s", context->response_file);
- argv[0] = DOOM_BINARY;
+ argv[0] = GetExecutableName();
argv[1] = response_file_arg;
argv[2] = NULL;
diff --git a/src/setup/mode.c b/src/setup/mode.c
index d5a396ac..9426e10a 100644
--- a/src/setup/mode.c
+++ b/src/setup/mode.c
@@ -19,8 +19,11 @@
// 02111-1307, USA.
//
+#include <stdlib.h>
#include <string.h>
+#include "doomtype.h"
+
#include "config.h"
#include "textscreen.h"
@@ -52,6 +55,7 @@ typedef struct
char *name;
char *config_file;
char *extra_config_file;
+ char *executable;
} mission_config_t;
// Default mission to fall back on, if no IWADs are found at all:
@@ -66,7 +70,8 @@ static mission_config_t mission_configs[] =
IWAD_MASK_DOOM,
"doom",
"default.cfg",
- PROGRAM_PREFIX "doom.cfg"
+ PROGRAM_PREFIX "doom.cfg",
+ PROGRAM_PREFIX "doom"
},
{
"Heretic",
@@ -74,7 +79,8 @@ static mission_config_t mission_configs[] =
IWAD_MASK_HERETIC,
"heretic",
"heretic.cfg",
- PROGRAM_PREFIX "heretic.cfg"
+ PROGRAM_PREFIX "heretic.cfg",
+ PROGRAM_PREFIX "heretic"
},
{
"Hexen",
@@ -82,7 +88,8 @@ static mission_config_t mission_configs[] =
IWAD_MASK_HEXEN,
"hexen",
"hexen.cfg",
- PROGRAM_PREFIX "hexen.cfg"
+ PROGRAM_PREFIX "hexen.cfg",
+ PROGRAM_PREFIX "hexen"
}
};
@@ -94,6 +101,7 @@ static int showMessages = 1;
static int screenblocks = 9;
static int detailLevel = 0;
static char *savedir = NULL;
+static char *executable = NULL;
static void BindMiscVariables(void)
{
@@ -144,9 +152,28 @@ void InitBindings(void)
BindMultiplayerVariables();
}
+// Set the name of the executable program to run the game:
+
+static void SetExecutable(mission_config_t *config)
+{
+ free(executable);
+
+#ifdef _WIN32
+ executable = malloc(strlen(config->executable) + 5);
+ sprintf(executable, "%s.exe", config->executable);
+#else
+ executable = malloc(strlen(INSTALL_DIR) + strlen(config->executable) + 2);
+ sprintf(executable, "%s%c%s", INSTALL_DIR, DIR_SEPARATOR,
+ config->executable);
+#endif
+
+puts(executable);
+}
+
static void SetMission(mission_config_t *config)
{
gamemission = config->mission;
+ SetExecutable(config);
M_SetConfigFilenames(config->config_file, config->extra_config_file);
}
@@ -175,7 +202,7 @@ static void GameSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(config))
static void OpenGameSelectDialog(GameSelectCallback callback)
{
- mission_config_t *mission;
+ mission_config_t *mission = NULL;
txt_window_t *window;
iwad_t **iwads;
int num_games;
@@ -267,3 +294,8 @@ void SetupMission(GameSelectCallback callback)
}
}
+char *GetExecutableName(void)
+{
+ return executable;
+}
+
diff --git a/src/setup/mode.h b/src/setup/mode.h
index a78a5bc2..1abd7d38 100644
--- a/src/setup/mode.h
+++ b/src/setup/mode.h
@@ -29,6 +29,7 @@ extern GameMission_t gamemission;
void SetupMission(GameSelectCallback callback);
void InitBindings(void);
+char *GetExecutableName(void);
#endif /* #ifndef SETUP_MODE_H */