ref: f0c5cc898d993d3388dfbce5833e8ccca7b2f03f
parent: 67fbcdce28b89b24f8fb27d5f25393ad775af719
author: Simon Howard <[email protected]>
date: Sun Mar 8 19:46:09 EDT 2009
Fix -cdrom command line parameter to work with Heretic and Hexen; compiles now work on Windows. Subversion-branch: /branches/raven-branch Subversion-revision: 1452
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1187,7 +1187,29 @@
// find which dir to use for config files
- M_SetConfigDir();
+#ifdef _WIN32
+
+ //!
+ // @platform windows
+ // @vanilla
+ //
+ // Save configuration data and savegames in c:\doomdata,
+ // allowing play from CD.
+ //
+
+ if (M_CheckParm("-cdrom") > 0)
+ {
+ printf(D_CDROM);
+
+ M_SetConfigDir("c:\\doomdata\\");
+ }
+ else
+#endif
+ {
+ // Auto-detect the configuration dir.
+
+ M_SetConfigDir(NULL);
+ }
//!
// @arg <x>
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -812,16 +812,6 @@
startmap = 1;
autostart = false;
- // Check for -CDROM
- cdrom = false;
-#ifdef __WATCOMC__
- if (M_CheckParm("-cdrom"))
- {
- cdrom = true;
- mkdir("c:\\heretic.cd");
- }
-#endif
-
//
// get skill / episode / map from parms
//
@@ -859,7 +849,34 @@
printf("V_Init: allocate screens.\n");
V_Init();
- M_SetConfigDir();
+ // Check for -CDROM
+
+ cdrom = false;
+
+#ifdef _WIN32
+
+ //!
+ // @platform windows
+ // @vanilla
+ //
+ // Save configuration data and savegames in c:\heretic.cd,
+ // allowing play from CD.
+ //
+
+ if (M_CheckParm("-cdrom"))
+ {
+ cdrom = true;
+ }
+#endif
+
+ if (cdrom)
+ {
+ M_SetConfigDir("c:\\heretic.cd\\");
+ }
+ else
+ {
+ M_SetConfigDir(NULL);
+ }
// Load defaults before initing other systems
printf("M_LoadDefaults: Load system defaults.\n");
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -116,7 +116,7 @@
boolean randomclass; // checkparm of -randclass
boolean debugmode; // checkparm of -debug
boolean ravpic; // checkparm of -ravpic
-boolean cdrom; // true if cd-rom mode active
+boolean cdrom = false; // true if cd-rom mode active
boolean cmdfrag; // true if a CMD_FRAG packet should be sent out
boolean singletics; // debug flag to cancel adaptiveness
boolean artiskip; // whether shift-enter skips an artifact
@@ -246,7 +246,29 @@
// Load defaults before initing other systems
ST_Message("M_LoadDefaults: Load system defaults.\n");
D_BindVariables();
- M_SetConfigDir();
+
+#ifdef _WIN32
+
+ //!
+ // @platform windows
+ // @vanilla
+ //
+ // Save configuration data and savegames in c:\hexndata,
+ // allowing play from CD.
+ //
+
+ cdrom = M_ParmExists("-cdrom");
+#endif
+
+ if (cdrom)
+ {
+ M_SetConfigDir("c:\\hexndata\\");
+ }
+ else
+ {
+ M_SetConfigDir(NULL);
+ }
+
D_SetDefaultSavePath();
M_SetConfigFilenames("hexen.cfg", PROGRAM_PREFIX "hexen.cfg");
M_LoadDefaults();
@@ -399,7 +421,7 @@
artiskip = M_ParmExists("-artiskip");
debugmode = M_ParmExists("-debug");
deathmatch = M_ParmExists("-deathmatch");
- cdrom = M_ParmExists("-cdrom");
+
cmdfrag = M_ParmExists("-cmdfrag");
// Process command line options
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -1104,20 +1104,17 @@
variable->bound = true;
}
-//
-// SetConfigDir:
-//
-// Sets the location of the configuration directory, where configuration
-// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
-//
+// Get the path to the default configuration dir to use, if NULL
+// is passed to M_SetConfigDir.
-void M_SetConfigDir(void)
+static char *GetDefaultConfigDir(void)
{
#ifndef _WIN32
- // Ignore the HOME environment variable on Windows - just behave
- // like Vanilla Doom.
+ // On Unix systems we put configuration into ~/.chocolate-doom, but
+ // on Windows we just use the current directory, like Vanilla.
char *homedir;
+ char *result;
homedir = getenv("HOME");
@@ -1126,39 +1123,44 @@
// put all configuration in a config directory off the
// homedir
- configdir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
+ result = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5);
- sprintf(configdir, "%s%c.%s%c", homedir, DIR_SEPARATOR,
- PACKAGE_TARNAME, DIR_SEPARATOR);
-
- // make the directory if it doesnt already exist
-
- M_MakeDirectory(configdir);
+ sprintf(result, "%s%c.%s%c", homedir, DIR_SEPARATOR,
+ PACKAGE_TARNAME, DIR_SEPARATOR);
}
else
#endif /* #ifndef _WIN32 */
{
-#ifdef _WIN32
- //!
- // @platform windows
- // @vanilla
- //
- // Save configuration data and savegames in c:\doomdata,
- // allowing play from CD.
- //
+ // On Windows, we just use the current directory.
- if (M_CheckParm("-cdrom") > 0)
- {
- printf(D_CDROM);
- configdir = strdup("c:\\doomdata\\");
+ return strdup("");
+ }
+}
- M_MakeDirectory(configdir);
- }
- else
-#endif
- {
- configdir = strdup("");
- }
+//
+// SetConfigDir:
+//
+// Sets the location of the configuration directory, where configuration
+// files are stored - default.cfg, chocolate-doom.cfg, savegames, etc.
+//
+
+void M_SetConfigDir(char *dir)
+{
+ // Use the directory that was passed, or find the default.
+
+ if (dir != NULL)
+ {
+ configdir = dir;
}
+ else
+ {
+ configdir = GetDefaultConfigDir();
+ }
+
+ printf("Using %s for configuration and saves\n", configdir);
+
+ // Make the directory if it doesn't already exist:
+
+ M_MakeDirectory(configdir);
}
--- a/src/m_config.h
+++ b/src/m_config.h
@@ -31,7 +31,7 @@
void M_LoadDefaults(void);
void M_SaveDefaults(void);
void M_SaveDefaultsAlternate(char *main, char *extra);
-void M_SetConfigDir(void);
+void M_SetConfigDir(char *dir);
void M_BindVariable(char *name, void *variable);
void M_SetConfigFilenames(char *main_config, char *extra_config);
--- a/src/setup/mainmenu.c
+++ b/src/setup/mainmenu.c
@@ -178,7 +178,7 @@
SetChatMacroDefaults();
SetPlayerNameDefault();
- M_SetConfigDir();
+ M_SetConfigDir(NULL);
M_LoadDefaults();
}