Just create the screenshot directory in fs_gamepath.

While here set the fs_gamedir to the last directory of the generic
search path in case that the game is reset to baseq2.
This commit is contained in:
Yamagi Burmeister 2017-07-25 09:19:17 +02:00
parent f311308713
commit e71f267de6

View file

@ -130,7 +130,6 @@ fsHandle_t *FS_GetFileByHandle(fileHandle_t f);
typedef struct fsRawPath_s { typedef struct fsRawPath_s {
char path[MAX_OSPATH]; char path[MAX_OSPATH];
qboolean create; qboolean create;
qboolean screenshot;
struct fsRawPath_s *next; struct fsRawPath_s *next;
} fsRawPath_t; } fsRawPath_t;
@ -1395,13 +1394,6 @@ void FS_BuildGenericSearchPath(void) {
Com_sprintf(path, sizeof(path), "%s/%s", search->path, BASEDIRNAME); Com_sprintf(path, sizeof(path), "%s/%s", search->path, BASEDIRNAME);
FS_AddDirToSearchPath(path, search->create); FS_AddDirToSearchPath(path, search->create);
// We need to create the screenshot directory since the
// render dll doesn't link the filesystem stuff.
if (search->screenshot) {
Com_sprintf(path, sizeof(path), "%s/%s/scrnshot", search->path, BASEDIRNAME);
Sys_Mkdir(path);
}
search = search->next; search = search->next;
} }
@ -1409,6 +1401,11 @@ void FS_BuildGenericSearchPath(void) {
// search path. Save the current head node so we can // search path. Save the current head node so we can
// distinguish generic and specialized directories. // distinguish generic and specialized directories.
fs_baseSearchPaths = fs_searchPaths; fs_baseSearchPaths = fs_searchPaths;
// We need to create the screenshot directory since the
// render dll doesn't link the filesystem stuff.
Com_sprintf(path, sizeof(path), "%s/scrnshot", fs_gamedir);
Sys_Mkdir(path);
} }
void void
@ -1490,11 +1487,13 @@ FS_BuildGameSpecificSearchPath(char *dir)
} }
// The game was reset to baseq2. Nothing to do here. // The game was reset to baseq2. Nothing to do here.
if ((Q_stricmp(dir, BASEDIRNAME) == 0) || (*dir == 0)) if ((Q_stricmp(dir, BASEDIRNAME) == 0) || (*dir == 0)) {
{
Cvar_FullSet("gamedir", "", CVAR_SERVERINFO | CVAR_NOSET); Cvar_FullSet("gamedir", "", CVAR_SERVERINFO | CVAR_NOSET);
Cvar_FullSet("game", "", CVAR_LATCH | CVAR_SERVERINFO); Cvar_FullSet("game", "", CVAR_LATCH | CVAR_SERVERINFO);
// TODO: Set fs_gamedir
// fs_gamedir must be reset to the last
// dir of the generic search path.
Q_strlcpy(fs_gamedir, fs_baseSearchPaths->path, sizeof(fs_gamedir));
} else { } else {
Cvar_FullSet("gamedir", dir, CVAR_SERVERINFO | CVAR_NOSET); Cvar_FullSet("gamedir", dir, CVAR_SERVERINFO | CVAR_NOSET);
search = fs_rawPath; search = fs_rawPath;
@ -1503,56 +1502,52 @@ FS_BuildGameSpecificSearchPath(char *dir)
Com_sprintf(path, sizeof(path), "%s/%s", search->path, dir); Com_sprintf(path, sizeof(path), "%s/%s", search->path, dir);
FS_AddDirToSearchPath(path, search->create); FS_AddDirToSearchPath(path, search->create);
// We need to create the screenshot directory since the
// render dll doesn't link the filesystem stuff.
if (search->screenshot) {
Com_sprintf(path, sizeof(path), "%s/%s/scrnshot", search->path, dir);
Sys_Mkdir(path);
}
search = search->next; search = search->next;
} }
} }
// We need to create the screenshot directory since the
// render dll doesn't link the filesystem stuff.
Com_sprintf(path, sizeof(path), "%s/scrnshot", fs_gamedir);
Sys_Mkdir(path);
} }
// -------- // --------
void FS_AddDirToRawPath (const char *dir, qboolean create, qboolean screenshot) { void FS_AddDirToRawPath (const char *dir, qboolean create) {
fsRawPath_t *search; fsRawPath_t *search;
// Add the directory // Add the directory
search = Z_Malloc(sizeof(fsRawPath_t)); search = Z_Malloc(sizeof(fsRawPath_t));
Q_strlcpy(search->path, dir, sizeof(search->path)); Q_strlcpy(search->path, dir, sizeof(search->path));
search->create = create; search->create = create;
search->screenshot = screenshot;
search->next = fs_rawPath; search->next = fs_rawPath;
fs_rawPath = search; fs_rawPath = search;
} }
void FS_BuildRawPath(void) { void FS_BuildRawPath(void) {
// Add $HOME/.yq2/baseq2 // Add $HOME/.yq2 (MUST be the last dir!)
// (MUST be the last dir!)
if (!is_portable) { if (!is_portable) {
const char *homedir = Sys_GetHomeDir(); const char *homedir = Sys_GetHomeDir();
if (homedir != NULL) { if (homedir != NULL) {
FS_AddDirToRawPath(homedir, true, true); FS_AddDirToRawPath(homedir, true);
} }
} }
// Add $binarydir/baseq2 // Add $binarydir
const char *binarydir = Sys_GetBinaryDir(); const char *binarydir = Sys_GetBinaryDir();
if(binarydir[0] != '\0') if(binarydir[0] != '\0')
{ {
FS_AddDirToRawPath(binarydir, false, false); FS_AddDirToRawPath(binarydir, false);
} }
// Add $basedir/ // Add $basedir/
FS_AddDirToRawPath(fs_basedir->string, false, false); FS_AddDirToRawPath(fs_basedir->string, false);
// Add SYSTEMDIR/baseq2 // Add SYSTEMDIR
#ifdef SYSTEMWIDE #ifdef SYSTEMWIDE
FS_AddDirToRawPath(SYSTEMDIR, false); FS_AddDirToRawPath(SYSTEMDIR, false);
#endif #endif
@ -1561,7 +1556,7 @@ void FS_BuildRawPath(void) {
// otherwise we cannot be sure that the game won't // otherwise we cannot be sure that the game won't
// stream the videos from the CD. // stream the videos from the CD.
if (fs_cddir->string[0] != '\0') { if (fs_cddir->string[0] != '\0') {
FS_AddDirToRawPath(fs_cddir->string, false, false); FS_AddDirToRawPath(fs_cddir->string, false);
} }
} }