q3map2: use "My Games" directory if exists on Win32
This commit is contained in:
parent
d9f3f840b7
commit
9b15142ec2
|
|
@ -196,6 +196,26 @@ void HomePaths_Realise()
|
||||||
Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
|
Q_mkdir(g_qeglobals.m_userEnginePath.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#elif defined(WIN32)
|
||||||
|
if(!string_empty(prefix))
|
||||||
|
{
|
||||||
|
StringOutputStream path(256);
|
||||||
|
TCHAR mydocsdir[MAX_PATH + 1];
|
||||||
|
if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
|
||||||
|
{
|
||||||
|
path << DirectoryCleaned(mydocsdir) << "My Games/" << prefix << "/";
|
||||||
|
// win32: only add it if it already exists
|
||||||
|
if(file_is_directory(path.c_str()))
|
||||||
|
g_qeglobals.m_userEnginePath = path.c_str();
|
||||||
|
else
|
||||||
|
g_qeglobals.m_userEnginePath = EnginePath_get();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_qeglobals.m_userEnginePath = EnginePath_get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
g_qeglobals.m_userEnginePath = EnginePath_get();
|
g_qeglobals.m_userEnginePath = EnginePath_get();
|
||||||
|
|
|
||||||
|
|
@ -78,22 +78,19 @@ void QE_InitVFS()
|
||||||
|
|
||||||
const char* gamename = gamename_get();
|
const char* gamename = gamename_get();
|
||||||
const char* basegame = basegame_get();
|
const char* basegame = basegame_get();
|
||||||
#if defined(POSIX)
|
|
||||||
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
|
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
|
||||||
#endif
|
|
||||||
const char* globalRoot = EnginePath_get();
|
const char* globalRoot = EnginePath_get();
|
||||||
|
|
||||||
// if we have a mod dir
|
// if we have a mod dir
|
||||||
if(!string_equal(gamename, basegame))
|
if(!string_equal(gamename, basegame))
|
||||||
{
|
{
|
||||||
#if defined(POSIX)
|
|
||||||
// ~/.<gameprefix>/<fs_game>
|
// ~/.<gameprefix>/<fs_game>
|
||||||
|
if(userRoot)
|
||||||
{
|
{
|
||||||
StringOutputStream userGamePath(256);
|
StringOutputStream userGamePath(256);
|
||||||
userGamePath << userRoot << gamename << '/';
|
userGamePath << userRoot << gamename << '/';
|
||||||
GlobalFileSystem().initDirectory(userGamePath.c_str());
|
GlobalFileSystem().initDirectory(userGamePath.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// <fs_basepath>/<fs_game>
|
// <fs_basepath>/<fs_game>
|
||||||
{
|
{
|
||||||
|
|
@ -103,14 +100,13 @@ void QE_InitVFS()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(POSIX)
|
|
||||||
// ~/.<gameprefix>/<fs_main>
|
// ~/.<gameprefix>/<fs_main>
|
||||||
|
if(userRoot)
|
||||||
{
|
{
|
||||||
StringOutputStream userBasePath(256);
|
StringOutputStream userBasePath(256);
|
||||||
userBasePath << userRoot << basegame << '/';
|
userBasePath << userRoot << basegame << '/';
|
||||||
GlobalFileSystem().initDirectory(userBasePath.c_str());
|
GlobalFileSystem().initDirectory(userBasePath.c_str());
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// <fs_basepath>/<fs_main>
|
// <fs_basepath>/<fs_main>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,18 @@ gets the user's home dir (for ~/.q3a)
|
||||||
char *LokiGetHomeDir( void )
|
char *LokiGetHomeDir( void )
|
||||||
{
|
{
|
||||||
#ifndef Q_UNIX
|
#ifndef Q_UNIX
|
||||||
|
#ifndef WIN32
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#else
|
||||||
|
static char buf[MAX_OS_PATH];
|
||||||
|
TCHAR mydocsdir[MAX_PATH + 1];
|
||||||
|
if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir))
|
||||||
|
{
|
||||||
|
snprintf(buf, "%s/My Games", mydocsdir);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
char *home;
|
char *home;
|
||||||
uid_t id;
|
uid_t id;
|
||||||
|
|
@ -107,6 +118,14 @@ void LokiInitPaths( char *argv0 )
|
||||||
#ifndef Q_UNIX
|
#ifndef Q_UNIX
|
||||||
/* this is kinda crap, but hey */
|
/* this is kinda crap, but hey */
|
||||||
strcpy( installPath, "../" );
|
strcpy( installPath, "../" );
|
||||||
|
|
||||||
|
/* get home dir */
|
||||||
|
home = LokiGetHomeDir();
|
||||||
|
if( home == NULL )
|
||||||
|
home = ".";
|
||||||
|
|
||||||
|
/* set home path */
|
||||||
|
homePath = home;
|
||||||
#else
|
#else
|
||||||
char temp[ MAX_OS_PATH ];
|
char temp[ MAX_OS_PATH ];
|
||||||
char last0[ 2 ];
|
char last0[ 2 ];
|
||||||
|
|
@ -272,28 +291,39 @@ adds a base path to the beginning of the list, prefixed by ~/
|
||||||
|
|
||||||
void AddHomeBasePath( char *path )
|
void AddHomeBasePath( char *path )
|
||||||
{
|
{
|
||||||
#ifdef Q_UNIX
|
|
||||||
int i;
|
int i;
|
||||||
char temp[ MAX_OS_PATH ];
|
char temp[ MAX_OS_PATH ];
|
||||||
|
|
||||||
|
if(!homePath)
|
||||||
|
return;
|
||||||
|
|
||||||
/* dummy check */
|
/* dummy check */
|
||||||
if( path == NULL || path[ 0 ] == '\0' )
|
if( path == NULL || path[ 0 ] == '\0' )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* concatenate home dir and path */
|
||||||
|
sprintf( temp, "%s/%s", homePath, path );
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
{
|
||||||
|
/* on Win32, we ONLY add it if the directory already exists */
|
||||||
|
GDir *dir;
|
||||||
|
dir = g_dir_open (temp, 0, NULL);
|
||||||
|
if(!dir)
|
||||||
|
return;
|
||||||
|
g_dir_close(dir);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* make a hole */
|
/* make a hole */
|
||||||
for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
|
for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
|
||||||
basePaths[ i + 1 ] = basePaths[ i ];
|
basePaths[ i + 1 ] = basePaths[ i ];
|
||||||
|
|
||||||
/* concatenate home dir and path */
|
|
||||||
sprintf( temp, "%s/%s", homePath, path );
|
|
||||||
|
|
||||||
/* add it to the list */
|
/* add it to the list */
|
||||||
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
||||||
strcpy( basePaths[ 0 ], temp );
|
strcpy( basePaths[ 0 ], temp );
|
||||||
CleanPath( basePaths[ 0 ] );
|
CleanPath( basePaths[ 0 ] );
|
||||||
numBasePaths++;
|
numBasePaths++;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user