From 8d9ee8259d629ef11a33e6710091f4f9bb15a1a2 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 16 Oct 2005 01:18:10 +0000 Subject: Global "configdir" variable with directory to store config files in. Create a function to find the filename for a savegame slot. Store savegames in the config dir. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 202 --- src/m_misc.c | 45 ++++++++++++--------------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) (limited to 'src/m_misc.c') diff --git a/src/m_misc.c b/src/m_misc.c index 95d13738..4af77c05 100644 --- a/src/m_misc.c +++ b/src/m_misc.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $ +// $Id: m_misc.c 202 2005-10-16 01:18:10Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -23,6 +23,11 @@ // // // $Log$ +// Revision 1.13 2005/10/16 01:18:10 fraggle +// Global "configdir" variable with directory to store config files in. +// Create a function to find the filename for a savegame slot. Store +// savegames in the config dir. +// // Revision 1.12 2005/09/17 20:50:46 fraggle // Mouse acceleration code to emulate old DOS drivers // @@ -78,7 +83,7 @@ //----------------------------------------------------------------------------- static const char -rcsid[] = "$Id: m_misc.c 111 2005-09-17 20:50:46Z fraggle $"; +rcsid[] = "$Id: m_misc.c 202 2005-10-16 01:18:10Z fraggle $"; #include #include @@ -586,33 +591,9 @@ void M_SaveDefaults (void) void M_LoadDefaults (void) { - char *config_dir; char *homedir; int i; - - homedir = getenv("HOME"); - - if (homedir != NULL) - { - // put all configuration in a config directory off the - // homedir - - config_dir = malloc(strlen(homedir) + strlen(PACKAGE_TARNAME) + 5); - - sprintf(config_dir, "%s/.%s/", homedir, PACKAGE_TARNAME); - - // make the directory if it doesnt already exist -#ifdef _WIN32 - mkdir(config_dir); -#else - mkdir(config_dir, 0755); -#endif - } - else - { - config_dir = strdup(""); - } - + // check for a custom default file i = M_CheckParm ("-config"); @@ -623,8 +604,8 @@ void M_LoadDefaults (void) } else { - doom_defaults.filename = malloc(strlen(config_dir) + 10); - sprintf(doom_defaults.filename, "%sdefault.cfg", config_dir); + doom_defaults.filename = malloc(strlen(configdir) + 10); + sprintf(doom_defaults.filename, "%sdefault.cfg", configdir); } printf("saving config in %s\n", doom_defaults.filename); @@ -640,15 +621,13 @@ void M_LoadDefaults (void) else { extra_defaults.filename - = malloc(strlen(config_dir) + strlen(PACKAGE_TARNAME) + 10); + = malloc(strlen(configdir) + strlen(PACKAGE_TARNAME) + 10); sprintf(extra_defaults.filename, "%s%s.cfg", - config_dir, PACKAGE_TARNAME); + configdir, PACKAGE_TARNAME); } LoadDefaultCollection(&doom_defaults); LoadDefaultCollection(&extra_defaults); - - free(config_dir); } -- cgit v1.2.3