mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-23 12:04:38 -04:00
rewrite D_DoomExeDir() to use SDL_GetBasePath() (#1145)
* rewrite D_DoomExeDir() to use SDL_GetBasePath() * move D_DoomExeDir() to src/d_iwad.c
This commit is contained in:
parent
e0601f00fd
commit
dafff23764
30
src/d_iwad.c
30
src/d_iwad.c
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "SDL_filesystem.h" // [FG] SDL_GetBasePath()
|
||||||
|
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "m_io.h"
|
#include "m_io.h"
|
||||||
#include "d_iwad.h"
|
#include "d_iwad.h"
|
||||||
@ -61,6 +63,32 @@ static void AddIWADDir(char *dir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return the path where the executable lies -- Lee Killough
|
||||||
|
|
||||||
|
char *D_DoomExeDir(void)
|
||||||
|
{
|
||||||
|
static char *base;
|
||||||
|
|
||||||
|
if (base == NULL) // cache multiple requests
|
||||||
|
{
|
||||||
|
char *result;
|
||||||
|
|
||||||
|
result = SDL_GetBasePath();
|
||||||
|
if (result != NULL)
|
||||||
|
{
|
||||||
|
base = M_StringDuplicate(result);
|
||||||
|
SDL_free(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = M_DirName(myargv[0]);
|
||||||
|
base = M_StringDuplicate(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
// This is Windows-specific code that automatically finds the location
|
// This is Windows-specific code that automatically finds the location
|
||||||
// of installed IWAD files. The registry is inspected to find special
|
// of installed IWAD files. The registry is inspected to find special
|
||||||
// keys installed by the Windows installers for various CD versions
|
// keys installed by the Windows installers for various CD versions
|
||||||
@ -538,7 +566,7 @@ void BuildIWADDirList(void)
|
|||||||
|
|
||||||
// Next check the directory where the executable is located. This might
|
// Next check the directory where the executable is located. This might
|
||||||
// be different from the current directory.
|
// be different from the current directory.
|
||||||
AddIWADDir(M_DirName(myargv[0]));
|
AddIWADDir(D_DoomExeDir());
|
||||||
|
|
||||||
// Add DOOMWADDIR if it is in the environment
|
// Add DOOMWADDIR if it is in the environment
|
||||||
env = M_getenv("DOOMWADDIR");
|
env = M_getenv("DOOMWADDIR");
|
||||||
|
@ -29,6 +29,7 @@ typedef struct
|
|||||||
const char *description;
|
const char *description;
|
||||||
} iwad_t;
|
} iwad_t;
|
||||||
|
|
||||||
|
char *D_DoomExeDir(void); // killough 2/16/98: path to executable's dir
|
||||||
char *D_FindWADByName(const char *filename);
|
char *D_FindWADByName(const char *filename);
|
||||||
char *D_TryFindWADByName(const char *filename);
|
char *D_TryFindWADByName(const char *filename);
|
||||||
char *D_FindIWADFile(GameMode_t *mode, GameMission_t *mission);
|
char *D_FindIWADFile(GameMode_t *mode, GameMission_t *mission);
|
||||||
|
13
src/d_main.c
13
src/d_main.c
@ -658,19 +658,6 @@ void D_AddFile(const char *file)
|
|||||||
wadfiles[numwadfiles] = NULL;
|
wadfiles[numwadfiles] = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the path where the executable lies -- Lee Killough
|
|
||||||
char *D_DoomExeDir(void)
|
|
||||||
{
|
|
||||||
static char *base;
|
|
||||||
|
|
||||||
if (!base) // cache multiple requests
|
|
||||||
{
|
|
||||||
base = M_DirName(myargv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return base;
|
|
||||||
}
|
|
||||||
|
|
||||||
// killough 10/98: return the name of the program the exe was invoked as
|
// killough 10/98: return the name of the program the exe was invoked as
|
||||||
char *D_DoomExeName(void)
|
char *D_DoomExeName(void)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,6 @@ extern char **wadfiles; // killough 11/98
|
|||||||
|
|
||||||
void D_AddFile(const char *file);
|
void D_AddFile(const 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
|
char *D_DoomExeName(void); // killough 10/98: executable's name
|
||||||
extern char *basesavegame; // killough 2/16/98: savegame path
|
extern char *basesavegame; // killough 2/16/98: savegame path
|
||||||
extern char *screenshotdir; // [FG] screenshot path
|
extern char *screenshotdir; // [FG] screenshot path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user