ref: 97f0be5d839ae5ec5b4c4d28dcf850f7afe08555
parent: 86934db17860154f8fd9680bfca7e3a72669dc07
author: Simon Howard <[email protected]>
date: Fri May 8 15:15:25 EDT 2009
Choose appropriate executable depending on game type. Subversion-branch: /branches/raven-branch Subversion-revision: 1514
--- 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 @@
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;
--- 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 @@
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 @@
IWAD_MASK_DOOM,
"doom",
"default.cfg",
- PROGRAM_PREFIX "doom.cfg"
+ PROGRAM_PREFIX "doom.cfg",
+ PROGRAM_PREFIX "doom"
},
{
"Heretic",
@@ -74,7 +79,8 @@
IWAD_MASK_HERETIC,
"heretic",
"heretic.cfg",
- PROGRAM_PREFIX "heretic.cfg"
+ PROGRAM_PREFIX "heretic.cfg",
+ PROGRAM_PREFIX "heretic"
},
{
"Hexen",
@@ -82,7 +88,8 @@
IWAD_MASK_HEXEN,
"hexen",
"hexen.cfg",
- PROGRAM_PREFIX "hexen.cfg"
+ PROGRAM_PREFIX "hexen.cfg",
+ PROGRAM_PREFIX "hexen"
}
};
@@ -94,6 +101,7 @@
static int screenblocks = 9;
static int detailLevel = 0;
static char *savedir = NULL;
+static char *executable = NULL;
static void BindMiscVariables(void)
{
@@ -144,9 +152,28 @@
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 OpenGameSelectDialog(GameSelectCallback callback)
{
- mission_config_t *mission;
+ mission_config_t *mission = NULL;
txt_window_t *window;
iwad_t **iwads;
int num_games;
@@ -265,5 +292,10 @@
{
OpenGameSelectDialog(callback);
}
+}
+
+char *GetExecutableName(void)
+{
+ return executable;
}
--- a/src/setup/mode.h
+++ b/src/setup/mode.h
@@ -29,6 +29,7 @@
void SetupMission(GameSelectCallback callback);
void InitBindings(void);
+char *GetExecutableName(void);
#endif /* #ifndef SETUP_MODE_H */