ref: 0083adaa40f4af7d44a3744ca315edb8d87c6bd8
parent: 005b2ccbc37e080e3651fbdac896cf28098bc920
author: Thomas A. Birkel <capnclever@gmail.com>
date: Wed Nov 30 20:12:08 EST 2016
m_config.c: Merge "-savedir", "-cdrom" usage into M_GetSaveGameDir() Adding "-cdrom" logic to M_GetSaveGameDir() fixed vanilla behavior for non-Doom games. Hexen-specific logic involving hexen.cfg "savedir" was added to D_SetDefaultSavePath().
--- a/src/doom/d_main.c
+++ b/src/doom/d_main.c
@@ -1614,42 +1614,7 @@
// we've finished loading Dehacked patches.
D_SetGameDescription();
- //!
- // @arg <directory>
- //
- // Specify a path from which to load and save games. If the directory
- // does not exist then it will automatically be created.
- // NOTE TO WINDOWS USERS: Do not end a path with a backslash ("\") if it
- // requires quote-wrapping (e.g., "C:\pa th\") as this will be
- // misinterpreted by the command line.
- //
-
- p = M_CheckParmWithArgs("-savedir", 1);
- if (p)
- {
- savegamedir = myargv[p + 1];
- if (!M_FileExists(savegamedir))
- {
- M_MakeDirectory(savegamedir);
- }
-
- // add separator at end just in case
- savegamedir = M_StringJoin(savegamedir, DIR_SEPARATOR_S, NULL);
-
- printf("Save directory changed to %s.\n", savegamedir);
- }
- else
-#ifdef _WIN32
- // In -cdrom mode, we write savegames to c:\doomdata as well as configs.
- if (M_ParmExists("-cdrom"))
- {
- savegamedir = configdir;
- }
- else
-#endif
- {
- savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission));
- }
+ savegamedir = M_GetSaveGameDir(D_SaveGameIWADName(gamemission));
// Check for -file in shareware
if (modifiedgame && (gamevariant != freedoom))
--- a/src/heretic/d_main.c
+++ b/src/heretic/d_main.c
@@ -1068,31 +1068,6 @@
savegamedir = M_GetSaveGameDir("heretic.wad");
- //!
- // @arg <directory>
- //
- // Specify a path from which to load and save games. If the directory
- // does not exist then it will automatically be created.
- // NOTE TO WINDOWS USERS: Do not end a path with a backslash ("\") if it
- // requires quote-wrapping (e.g., "C:\pa th\") as this will be
- // misinterpreted by the command line.
- //
-
- p = M_CheckParmWithArgs("-savedir", 1);
- if (p)
- {
- savegamedir = myargv[p + 1];
- if (!M_FileExists(savegamedir))
- {
- M_MakeDirectory(savegamedir);
- }
-
- // add separator at end just in case
- savegamedir = M_StringJoin(savegamedir, DIR_SEPARATOR_S, NULL);
-
- printf("Save directory changed to %s.\n", savegamedir);
- }
-
I_PrintStartupBanner(gamedescription);
if (M_ParmExists("-testcontrols"))
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -184,15 +184,31 @@
{
SavePath = M_GetSaveGameDir("hexen.wad");
- // If we are not using a savegame path (probably because we are on
- // Windows and not using a config dir), behave like Vanilla Hexen
- // and use hexndata/:
-
if (!strcmp(SavePath, ""))
{
- SavePath = malloc(10);
- M_snprintf(SavePath, 10, "hexndata%c", DIR_SEPARATOR);
+ // only get hexen.cfg path if one is not already found
+
+ if (!strcmp(SavePathConfig, ""))
+ {
+ // If we are not using a savegame path (probably because we are on
+ // Windows and not using a config dir), behave like Vanilla Hexen
+ // and use hexndata/:
+
+ SavePath = malloc(10);
+ M_snprintf(SavePath, 10, "hexndata%c", DIR_SEPARATOR);
+ }
+ else
+ {
+ SavePath = M_StringDuplicate(SavePathConfig);
+ }
}
+
+ // only set hexen.cfg path if using default handling
+
+ if (!M_ParmExists("-savedir") && !M_ParmExists("-cdrom"))
+ {
+ SavePathConfig = SavePath;
+ }
}
// The Mac version of the Hexen IWAD is different to the "normal" DOS
@@ -375,33 +391,12 @@
M_SetConfigDir(NULL);
}
- D_SetDefaultSavePath();
M_SetConfigFilenames("hexen.cfg", PROGRAM_PREFIX "hexen.cfg");
M_LoadDefaults();
- SavePath = SavePathConfig;
- I_AtExit(M_SaveDefaults, false);
+ D_SetDefaultSavePath();
- //!
- // @arg <directory>
- //
- // Specify a path from which to load and save games. If the directory
- // does not exist then it will automatically be created.
- // NOTE TO WINDOWS USERS: Do not end a path with a backslash ("\") if it
- // requires quote-wrapping (e.g., "C:\pa th\") as this will be
- // misinterpreted by the command line.
- //
-
- p = M_CheckParmWithArgs("-savedir", 1);
- if (p)
- {
- SavePath = myargv[p + 1];
-
- // add separator at end just in case
- SavePath = M_StringJoin(SavePath, DIR_SEPARATOR_S, NULL);
-
- printf("Save directory changed to %s.\n", SavePath);
- }
+ I_AtExit(M_SaveDefaults, false);
// Now that the savedir is loaded, make sure it exists
CreateSavePath();
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -2172,11 +2172,41 @@
{
char *savegamedir;
char *topdir;
+ int p;
+ //!
+ // @arg <directory>
+ //
+ // Specify a path from which to load and save games. If the directory
+ // does not exist then it will automatically be created.
+ //
+
+ p = M_CheckParmWithArgs("-savedir", 1);
+ if (p)
+ {
+ savegamedir = myargv[p + 1];
+ if (!M_FileExists(savegamedir))
+ {
+ M_MakeDirectory(savegamedir);
+ }
+
+ // add separator at end just in case
+ savegamedir = M_StringJoin(savegamedir, DIR_SEPARATOR_S, NULL);
+
+ printf("Save directory changed to %s.\n", savegamedir);
+ }
+#ifdef _WIN32
+ // In -cdrom mode, we write savegames to a specific directory
+ // in addition to configs.
+
+ else if (M_ParmExists("-cdrom"))
+ {
+ savegamedir = configdir;
+ }
+#endif
// If not "doing" a configuration directory (Windows), don't "do"
// a savegame directory, either.
-
- if (!strcmp(configdir, ""))
+ else if (!strcmp(configdir, ""))
{
savegamedir = M_StringDuplicate("");
}
--- a/src/strife/d_main.c
+++ b/src/strife/d_main.c
@@ -1658,33 +1658,7 @@
D_IdentifyVersion();
InitGameVersion();
D_SetGameDescription();
-
savegamedir = M_GetSaveGameDir("strife1.wad");
-
- //!
- // @arg <directory>
- //
- // Specify a path from which to load and save games. If the directory
- // does not exist then it will automatically be created.
- // NOTE TO WINDOWS USERS: Do not end a path with a backslash ("\") if it
- // requires quote-wrapping (e.g., "C:\pa th\") as this will be
- // misinterpreted by the command line.
- //
-
- p = M_CheckParmWithArgs("-savedir", 1);
- if (p)
- {
- savegamedir = myargv[p + 1];
- if (!M_FileExists(savegamedir))
- {
- M_MakeDirectory(savegamedir);
- }
-
- // add separator at end just in case
- savegamedir = M_StringJoin(savegamedir, DIR_SEPARATOR_S, NULL);
-
- printf("Save directory changed to %s.\n", savegamedir);
- }
// fraggle 20130405: I_InitTimer is needed here for the netgame
// startup. Start low-level sound init here too.