mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Clean up autodetected game install search paths on all platforms that use them.
This should prevent Lunar Apocalypse from becoming Nuclear Winter with Megaton on Linux and Mac. git-svn-id: https://svn.eduke32.com/eduke32@4886 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1f3ce84585
commit
e3de98e2ae
4 changed files with 57 additions and 55 deletions
|
@ -25,8 +25,10 @@ void agecache(void);
|
|||
|
||||
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
|
||||
char *listsearchpath(int32_t initp);
|
||||
int32_t addsearchpath(const char *p);
|
||||
#define addsearchpath(a) addsearchpath_user(a, 0)
|
||||
int32_t addsearchpath_user(const char *p, int32_t user);
|
||||
int32_t removesearchpath(const char *p);
|
||||
void removesearchpaths_withuser(int32_t usermask);
|
||||
int32_t findfrompath(const char *fn, char **where);
|
||||
int32_t openfrompath(const char *fn, int32_t flags, int32_t mode);
|
||||
BFILE *fopenfrompath(const char *fn, const char *mode);
|
||||
|
|
|
@ -334,6 +334,7 @@ typedef struct _searchpath
|
|||
struct _searchpath *next;
|
||||
char *path;
|
||||
size_t pathlen; // to save repeated calls to strlen()
|
||||
int32_t user;
|
||||
} searchpath_t;
|
||||
static searchpath_t *searchpathhead = NULL;
|
||||
static size_t maxsearchpathlen = 0;
|
||||
|
@ -351,7 +352,7 @@ char *listsearchpath(int32_t initp)
|
|||
return sp ? sp->path : NULL;
|
||||
}
|
||||
|
||||
int32_t addsearchpath(const char *p)
|
||||
int32_t addsearchpath_user(const char *p, int32_t user)
|
||||
{
|
||||
struct Bstat st;
|
||||
char *s;
|
||||
|
@ -392,6 +393,8 @@ int32_t addsearchpath(const char *p)
|
|||
|
||||
Bcorrectfilename(srch->path,0);
|
||||
|
||||
srch->user = user;
|
||||
|
||||
initprintf("Using %s for game data\n", srch->path);
|
||||
|
||||
Bfree(path);
|
||||
|
@ -450,6 +453,34 @@ int32_t removesearchpath(const char *p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void removesearchpaths_withuser(int32_t usermask)
|
||||
{
|
||||
for (searchpath_t *srch = searchpathhead; srch; srch = srch->next)
|
||||
{
|
||||
if (srch->user & usermask)
|
||||
{
|
||||
if (srch == searchpathhead)
|
||||
searchpathhead = srch->next;
|
||||
else
|
||||
{
|
||||
searchpath_t *sp;
|
||||
|
||||
for (sp = searchpathhead; sp; sp = sp->next)
|
||||
{
|
||||
if (sp->next == srch)
|
||||
{
|
||||
sp->next = srch->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bfree(srch->path);
|
||||
Bfree(srch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t findfrompath(const char *fn, char **where)
|
||||
{
|
||||
searchpath_t *sp;
|
||||
|
|
|
@ -609,23 +609,23 @@ static void G_AddSteamPaths(const char *basepath)
|
|||
char buf[BMAX_PATH];
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Duke Nukem 3D/gameroot", basepath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Duke Nukem 3D/gameroot/addons/dc", basepath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Duke Nukem 3D/gameroot/addons/nw", basepath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Duke Nukem 3D/gameroot/addons/vacation", basepath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
#if defined __APPLE__
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Nam/Nam.app/Contents/Resources/Nam.boxer/C.harddisk/NAM", basepath);
|
||||
#else
|
||||
Bsnprintf(buf, sizeof(buf), "%s/steamapps/common/Nam/NAM", basepath);
|
||||
#endif
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_NAM);
|
||||
}
|
||||
|
||||
// A bare-bones "parser" for Valve's KeyValues VDF format.
|
||||
|
@ -829,7 +829,7 @@ void G_AddSearchPaths(void)
|
|||
G_ParseSteamKeyValuesForPaths(buf);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D.app/Contents/Resources/Duke Nukem 3D.boxer/C.harddisk", applications[i]);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
}
|
||||
|
||||
for (i = 0; i < 2; i++)
|
||||
|
@ -852,83 +852,47 @@ void G_AddSearchPaths(void)
|
|||
if ((instpath = G_GetInstallPath(INSTPATH_STEAM_DUKE3D)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/dc", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/nw", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/vacation", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
}
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_GOG_DUKE3D)))
|
||||
addsearchpath(instpath);
|
||||
addsearchpath_user(instpath, SEARCHPATH_REMOVE);
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_3DR_DUKE3D)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
}
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_3DR_ANTH)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_REMOVE);
|
||||
}
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_STEAM_NAM)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/NAM", instpath);
|
||||
addsearchpath(buf);
|
||||
addsearchpath_user(buf, SEARCHPATH_NAM);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void G_CleanupSearchPaths(void)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
char buf[BMAX_PATH];
|
||||
const char* instpath;
|
||||
removesearchpaths_withuser(SEARCHPATH_REMOVE);
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_STEAM_DUKE3D)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot", instpath);
|
||||
removesearchpath(buf);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/dc", instpath);
|
||||
removesearchpath(buf);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/nw", instpath);
|
||||
removesearchpath(buf);
|
||||
|
||||
Bsnprintf(buf, sizeof(buf), "%s/gameroot/addons/vacation", instpath);
|
||||
removesearchpath(buf);
|
||||
}
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_GOG_DUKE3D)))
|
||||
removesearchpath(instpath);
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_3DR_DUKE3D)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D", instpath);
|
||||
removesearchpath(buf);
|
||||
}
|
||||
|
||||
if ((instpath = G_GetInstallPath(INSTPATH_3DR_ANTH)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/Duke Nukem 3D", instpath);
|
||||
removesearchpath(buf);
|
||||
}
|
||||
|
||||
if (g_gameType != GAMEFLAG_NAM && (instpath = G_GetInstallPath(INSTPATH_STEAM_NAM)))
|
||||
{
|
||||
Bsnprintf(buf, sizeof(buf), "%s/NAM", instpath);
|
||||
removesearchpath(buf);
|
||||
}
|
||||
#endif
|
||||
if (!(NAM || NAPALM))
|
||||
removesearchpaths_withuser(SEARCHPATH_NAM);
|
||||
}
|
||||
|
||||
//////////
|
||||
|
|
|
@ -50,6 +50,11 @@ enum instpath_t {
|
|||
NUMINSTPATHS
|
||||
};
|
||||
|
||||
enum searchpathtypes_t {
|
||||
SEARCHPATH_REMOVE = 1<<0,
|
||||
SEARCHPATH_NAM = 1<<1,
|
||||
};
|
||||
|
||||
typedef enum basepal_ {
|
||||
BASEPAL = 0,
|
||||
WATERPAL,
|
||||
|
|
Loading…
Reference in a new issue