mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-26 17:00:56 +00:00
Prevent loading anything except the GRP from the Steam or GOG Duke3D install directories. Loading DUKE.RTS from those paths will be resolved later.
git-svn-id: https://svn.eduke32.com/eduke32@3637 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
73cb94b389
commit
e20b834ea8
5 changed files with 100 additions and 19 deletions
|
@ -23,6 +23,7 @@ void agecache(void);
|
|||
|
||||
extern int32_t pathsearchmode; // 0 = gamefs mode (default), 1 = localfs mode (editor's mode)
|
||||
int32_t addsearchpath(const char *p);
|
||||
int32_t removesearchpath(const char *p);
|
||||
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);
|
||||
|
|
|
@ -353,11 +353,9 @@ int32_t addsearchpath(const char *p)
|
|||
}
|
||||
|
||||
Bstrcpy(srch->path, path);
|
||||
for (s=srch->path; *s; s++)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
for (s=srch->path; *s; s++);
|
||||
s--;
|
||||
|
||||
if (s<srch->path || toupperlookup[*s] != '/')
|
||||
Bstrcat(srch->path, "/");
|
||||
|
||||
|
@ -373,6 +371,58 @@ int32_t addsearchpath(const char *p)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t removesearchpath(const char *p)
|
||||
{
|
||||
searchpath_t *srch;
|
||||
char *s;
|
||||
char *path = (char *)Bmalloc(Bstrlen(p) + 2);
|
||||
|
||||
Bstrcpy(path, p);
|
||||
|
||||
if (path[Bstrlen(path)-1] == '\\')
|
||||
path[Bstrlen(path)-1] = 0;
|
||||
|
||||
for (s=path; *s; s++);
|
||||
s--;
|
||||
|
||||
if (s<path || toupperlookup[*s] != '/')
|
||||
Bstrcat(path, "/");
|
||||
|
||||
Bcorrectfilename(path,0);
|
||||
|
||||
for (srch = searchpathhead; srch; srch = srch->next)
|
||||
{
|
||||
if (!Bstrncmp(path, srch->path, srch->pathlen))
|
||||
{
|
||||
// initprintf("Removing %s from path stack\n", path);
|
||||
|
||||
if (srch == searchpathhead)
|
||||
searchpathhead = srch->next;
|
||||
else
|
||||
{
|
||||
searchpath_t *sp;
|
||||
|
||||
for (sp = searchpathhead; sp; sp = sp->next)
|
||||
{
|
||||
if (sp->next == srch)
|
||||
{
|
||||
// initprintf("matched %s\n", srch->path);
|
||||
sp->next = srch->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Bfree(srch->path);
|
||||
Bfree(srch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Bfree(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t findfrompath(const char *fn, char **where)
|
||||
{
|
||||
searchpath_t *sp;
|
||||
|
|
|
@ -218,17 +218,28 @@ void G_ExtPreInit(void)
|
|||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
const char * G_GetSteamPath(void)
|
||||
const char * G_GetInstallPath(int32_t insttype)
|
||||
{
|
||||
static char spath[BMAX_PATH];
|
||||
static int32_t success = -1;
|
||||
static char spath[NUMINSTPATHS][BMAX_PATH];
|
||||
static int32_t success[NUMINSTPATHS] = { -1, -1 };
|
||||
int32_t siz = BMAX_PATH;
|
||||
|
||||
if (success == -1)
|
||||
success = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225140", "InstallLocation", NULL, spath, (LPDWORD)&siz);
|
||||
// this still needs to be fixed for win64 builds
|
||||
if (success[insttype] == -1)
|
||||
{
|
||||
switch (insttype)
|
||||
{
|
||||
case INSTPATH_STEAM:
|
||||
success[insttype] = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Steam App 225140", "InstallLocation", NULL, spath[insttype], (LPDWORD)&siz);
|
||||
break;
|
||||
case INSTPATH_GOG:
|
||||
success[insttype] = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", NULL, spath[insttype], (LPDWORD)&siz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (success == ERROR_SUCCESS)
|
||||
return spath;
|
||||
if (success[insttype] == ERROR_SUCCESS)
|
||||
return spath[insttype];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -247,21 +258,18 @@ void G_AddSearchPaths(void)
|
|||
#elif defined (_WIN32)
|
||||
// detect Steam and GOG versions of Duke3D
|
||||
char buf[BMAX_PATH];
|
||||
int32_t siz = BMAX_PATH, ret;
|
||||
|
||||
if (G_GetSteamPath())
|
||||
if (G_GetInstallPath(INSTPATH_STEAM))
|
||||
{
|
||||
Bsprintf(buf, "%s/gameroot/classic", G_GetSteamPath());
|
||||
Bsprintf(buf, "%s/gameroot", G_GetInstallPath(INSTPATH_STEAM));
|
||||
addsearchpath(buf);
|
||||
|
||||
Bsprintf(buf, "%s/gameroot/addons", G_GetSteamPath());
|
||||
Bsprintf(buf, "%s/gameroot/addons", G_GetInstallPath(INSTPATH_STEAM));
|
||||
addsearchpath(buf);
|
||||
}
|
||||
|
||||
ret = SHGetValueA(HKEY_LOCAL_MACHINE, "SOFTWARE\\GOG.com\\GOGDUKE3D", "PATH", NULL, buf, (LPDWORD)&siz);
|
||||
|
||||
if (ret == ERROR_SUCCESS)
|
||||
addsearchpath(buf);
|
||||
if (G_GetInstallPath(INSTPATH_GOG))
|
||||
addsearchpath(G_GetInstallPath(INSTPATH_GOG));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ enum Games_t {
|
|||
GAMECOUNT
|
||||
};
|
||||
|
||||
enum instpath_t {
|
||||
INSTPATH_STEAM,
|
||||
INSTPATH_GOG,
|
||||
NUMINSTPATHS
|
||||
};
|
||||
|
||||
extern const char *defaultgamegrp[GAMECOUNT];
|
||||
extern const char *defaultdeffilename[GAMECOUNT];
|
||||
extern const char *defaultconfilename;
|
||||
|
@ -55,4 +61,6 @@ extern void G_ExtPreInit(void);
|
|||
|
||||
extern void G_AddSearchPaths(void);
|
||||
|
||||
extern const char * G_GetInstallPath(int32_t insttype);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -10452,6 +10452,20 @@ int32_t app_main(int32_t argc, const char **argv)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (G_GetInstallPath(INSTPATH_STEAM))
|
||||
{
|
||||
Bsprintf(buf, "%s/gameroot", G_GetInstallPath(INSTPATH_STEAM));
|
||||
removesearchpath(buf);
|
||||
|
||||
Bsprintf(buf, "%s/gameroot/addons", G_GetInstallPath(INSTPATH_STEAM));
|
||||
removesearchpath(buf);
|
||||
}
|
||||
|
||||
if (G_GetInstallPath(INSTPATH_GOG))
|
||||
removesearchpath(G_GetInstallPath(INSTPATH_GOG));
|
||||
#endif
|
||||
|
||||
if (g_modDir[0] != '/')
|
||||
G_LoadGroupsInDir(g_modDir);
|
||||
|
||||
|
|
Loading…
Reference in a new issue