mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
Doomprefdir (#29)
* Define a user-writeable directory with a little help from SDL_GetPrefPath() * Save config files, translation tables and savegames into this directory. * Screenshots are still saved into the "current" directory, i.e. the user's $HOME on Unix. * unconditionally create the user-writable directory * adapt to pending inclusion of m_misc2.c
This commit is contained in:
parent
6214abb7d7
commit
765394837c
@ -30,6 +30,7 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "d_io.h" // haleyjd
|
||||
#include "SDL_filesystem.h" // [FG] SDL_GetPrefPath()
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -47,6 +48,7 @@
|
||||
#include "f_wipe.h"
|
||||
#include "m_argv.h"
|
||||
#include "m_misc.h"
|
||||
#include "m_misc2.h" // [FG] M_StringDuplicate()
|
||||
#include "m_menu.h"
|
||||
#include "i_system.h"
|
||||
#include "i_sound.h"
|
||||
@ -581,6 +583,41 @@ char *D_DoomExeName(void)
|
||||
return name;
|
||||
}
|
||||
|
||||
// [FG] get the path to the default configuration dir to use
|
||||
|
||||
char *D_DoomPrefDir(void)
|
||||
{
|
||||
static char *dir;
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
char *result;
|
||||
|
||||
#if !defined(_WIN32) || defined(_WIN32_WCE)
|
||||
// Configuration settings are stored in an OS-appropriate path
|
||||
// determined by SDL. On typical Unix systems, this might be
|
||||
// ~/.local/share/chocolate-doom. On Windows, we behave like
|
||||
// Vanilla Doom and save in the current directory.
|
||||
|
||||
result = SDL_GetPrefPath("", PACKAGE_TARNAME);
|
||||
if (result != NULL)
|
||||
{
|
||||
dir = M_StringDuplicate(result);
|
||||
SDL_free(result);
|
||||
}
|
||||
else
|
||||
#endif /* #ifndef _WIN32 */
|
||||
{
|
||||
result = D_DoomExeDir();
|
||||
dir = M_StringDuplicate(result);
|
||||
}
|
||||
|
||||
M_MakeDirectory(dir);
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
//
|
||||
// CheckIWAD
|
||||
//
|
||||
@ -865,11 +902,11 @@ void IdentifyVersion (void)
|
||||
|
||||
// get config file from same directory as executable
|
||||
// killough 10/98
|
||||
sprintf(basedefault,"%s/%s.cfg", D_DoomExeDir(), D_DoomExeName());
|
||||
sprintf(basedefault,"%s/%s.cfg", D_DoomPrefDir(), D_DoomExeName());
|
||||
|
||||
// set save path to -save parm or current dir
|
||||
|
||||
strcpy(basesavegame,"."); //jff 3/27/98 default to current dir
|
||||
strcpy(basesavegame,D_DoomPrefDir()); //jff 3/27/98 default to current dir
|
||||
if ((i=M_CheckParm("-save")) && i<myargc-1) //jff 3/24/98 if -save present
|
||||
{
|
||||
if (!stat(myargv[i+1],&sbuf) && S_ISDIR(sbuf.st_mode)) // and is a dir
|
||||
|
@ -40,6 +40,7 @@ void D_AddFile(char *file);
|
||||
char *D_DoomExeDir(void); // killough 2/16/98: path to executable's dir
|
||||
char *D_DoomExeName(void); // killough 10/98: executable's name
|
||||
extern char basesavegame[]; // killough 2/16/98: savegame path
|
||||
char *D_DoomPrefDir(void);
|
||||
|
||||
//jff 1/24/98 make command line copies of play modes available
|
||||
extern boolean clnomonsters; // checkparm of -nomonsters
|
||||
|
@ -1807,7 +1807,7 @@ void M_SaveDefaults (void)
|
||||
if (!defaults_loaded || !defaultfile)
|
||||
return;
|
||||
|
||||
sprintf(tmpfile, "%s/tmp%.5s.cfg", D_DoomExeDir(), D_DoomExeName());
|
||||
sprintf(tmpfile, "%s/tmp%.5s.cfg", D_DoomPrefDir(), D_DoomExeName());
|
||||
NormalizeSlashes(tmpfile);
|
||||
|
||||
errno = 0;
|
||||
|
@ -769,12 +769,12 @@ void R_InitTranMap(int progress)
|
||||
else
|
||||
{ // Compose a default transparent filter map based on PLAYPAL.
|
||||
unsigned char *playpal = W_CacheLumpName("PLAYPAL", PU_STATIC);
|
||||
char fname[PATH_MAX+1], *D_DoomExeDir(void);
|
||||
char fname[PATH_MAX+1], *D_DoomPrefDir(void);
|
||||
struct {
|
||||
unsigned char pct;
|
||||
unsigned char playpal[256];
|
||||
} cache;
|
||||
FILE *cachefp = fopen(strcat(strcpy(fname, D_DoomExeDir()),
|
||||
FILE *cachefp = fopen(strcat(strcpy(fname, D_DoomPrefDir()),
|
||||
"/tranmap.dat"),"r+b");
|
||||
|
||||
main_tranmap = Z_Malloc(256*256, PU_STATIC, 0); // killough 4/11/98
|
||||
|
Loading…
x
Reference in New Issue
Block a user