mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 11:22:18 -04:00
add D_DoomPrefDir() instead of D_DoomExeDir() to iwad_dirs (#2115)
D_DoomPrefDir() returns the executable directory on Windows, and a user-writable config directory everywhere else.
This commit is contained in:
parent
2ac2f646de
commit
5e04f8742e
36
src/d_iwad.c
36
src/d_iwad.c
@ -89,6 +89,38 @@ char *D_DoomExeDir(void)
|
||||
return base;
|
||||
}
|
||||
|
||||
// [FG] get the path to the default configuration dir to use
|
||||
|
||||
char *D_DoomPrefDir(void)
|
||||
{
|
||||
static char *dir;
|
||||
|
||||
if (dir == NULL)
|
||||
{
|
||||
#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.
|
||||
|
||||
char *result = SDL_GetPrefPath("", PROJECT_SHORTNAME);
|
||||
if (result != NULL)
|
||||
{
|
||||
dir = M_DirName(result);
|
||||
SDL_free(result);
|
||||
}
|
||||
else
|
||||
#endif /* #ifndef _WIN32 */
|
||||
{
|
||||
dir = D_DoomExeDir();
|
||||
}
|
||||
|
||||
M_MakeDirectory(dir);
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
// This is Windows-specific code that automatically finds the location
|
||||
// of installed IWAD files. The registry is inspected to find special
|
||||
// keys installed by the Windows installers for various CD versions
|
||||
@ -547,7 +579,9 @@ void BuildIWADDirList(void)
|
||||
|
||||
// Next check the directory where the executable is located. This might
|
||||
// be different from the current directory.
|
||||
array_push(iwad_dirs, D_DoomExeDir());
|
||||
// D_DoomPrefDir() returns the executable directory on Windows,
|
||||
// and a user-writable config directory everywhere else.
|
||||
array_push(iwad_dirs, D_DoomPrefDir());
|
||||
|
||||
// Add DOOMWADDIR if it is in the environment
|
||||
env = M_getenv("DOOMWADDIR");
|
||||
|
@ -30,6 +30,7 @@ typedef struct
|
||||
} iwad_t;
|
||||
|
||||
char *D_DoomExeDir(void); // killough 2/16/98: path to executable's dir
|
||||
char *D_DoomPrefDir(void); // [FG] default configuration dir
|
||||
char *D_FindWADByName(const char *filename);
|
||||
char *D_TryFindWADByName(const char *filename);
|
||||
char *D_FindLMPByName(const char *filename);
|
||||
|
32
src/d_main.c
32
src/d_main.c
@ -622,38 +622,6 @@ 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)
|
||||
{
|
||||
#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.
|
||||
|
||||
char *result = SDL_GetPrefPath("", PROJECT_SHORTNAME);
|
||||
if (result != NULL)
|
||||
{
|
||||
dir = M_DirName(result);
|
||||
SDL_free(result);
|
||||
}
|
||||
else
|
||||
#endif /* #ifndef _WIN32 */
|
||||
{
|
||||
dir = D_DoomExeDir();
|
||||
}
|
||||
|
||||
M_MakeDirectory(dir);
|
||||
}
|
||||
|
||||
return dir;
|
||||
}
|
||||
|
||||
// Calculate the path to the directory for autoloaded WADs/DEHs.
|
||||
// Creates the directory as necessary.
|
||||
|
||||
|
@ -30,7 +30,6 @@ void D_AddFile(const char *file);
|
||||
char *D_DoomExeName(void); // killough 10/98: executable's name
|
||||
extern char *basesavegame; // killough 2/16/98: savegame path
|
||||
extern char *screenshotdir; // [FG] screenshot path
|
||||
char *D_DoomPrefDir(void); // [FG] default configuration dir
|
||||
void D_SetSavegameDirectory(void);
|
||||
|
||||
extern const char *gamedescription;
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "am_map.h"
|
||||
#include "config.h"
|
||||
#include "d_main.h"
|
||||
#include "d_iwad.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "doomtype.h"
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "d_main.h"
|
||||
#include "d_iwad.h"
|
||||
#include "d_think.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user