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());
|
||||
}
|
||||
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
|
||||
{
|
||||
g_qeglobals.m_userEnginePath = EnginePath_get();
|
||||
|
|
|
|||
|
|
@ -78,22 +78,19 @@ void QE_InitVFS()
|
|||
|
||||
const char* gamename = gamename_get();
|
||||
const char* basegame = basegame_get();
|
||||
#if defined(POSIX)
|
||||
const char* userRoot = g_qeglobals.m_userEnginePath.c_str();
|
||||
#endif
|
||||
const char* globalRoot = EnginePath_get();
|
||||
|
||||
// if we have a mod dir
|
||||
if(!string_equal(gamename, basegame))
|
||||
{
|
||||
#if defined(POSIX)
|
||||
// ~/.<gameprefix>/<fs_game>
|
||||
if(userRoot)
|
||||
{
|
||||
StringOutputStream userGamePath(256);
|
||||
userGamePath << userRoot << gamename << '/';
|
||||
GlobalFileSystem().initDirectory(userGamePath.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
// <fs_basepath>/<fs_game>
|
||||
{
|
||||
|
|
@ -103,14 +100,13 @@ void QE_InitVFS()
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(POSIX)
|
||||
// ~/.<gameprefix>/<fs_main>
|
||||
if(userRoot)
|
||||
{
|
||||
StringOutputStream userBasePath(256);
|
||||
userBasePath << userRoot << basegame << '/';
|
||||
GlobalFileSystem().initDirectory(userBasePath.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
// <fs_basepath>/<fs_main>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -65,7 +65,18 @@ gets the user's home dir (for ~/.q3a)
|
|||
char *LokiGetHomeDir( void )
|
||||
{
|
||||
#ifndef Q_UNIX
|
||||
return NULL;
|
||||
#ifndef WIN32
|
||||
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
|
||||
char *home;
|
||||
uid_t id;
|
||||
|
|
@ -107,6 +118,14 @@ void LokiInitPaths( char *argv0 )
|
|||
#ifndef Q_UNIX
|
||||
/* this is kinda crap, but hey */
|
||||
strcpy( installPath, "../" );
|
||||
|
||||
/* get home dir */
|
||||
home = LokiGetHomeDir();
|
||||
if( home == NULL )
|
||||
home = ".";
|
||||
|
||||
/* set home path */
|
||||
homePath = home;
|
||||
#else
|
||||
char temp[ MAX_OS_PATH ];
|
||||
char last0[ 2 ];
|
||||
|
|
@ -272,28 +291,39 @@ adds a base path to the beginning of the list, prefixed by ~/
|
|||
|
||||
void AddHomeBasePath( char *path )
|
||||
{
|
||||
#ifdef Q_UNIX
|
||||
int i;
|
||||
char temp[ MAX_OS_PATH ];
|
||||
int i;
|
||||
char temp[ MAX_OS_PATH ];
|
||||
|
||||
if(!homePath)
|
||||
return;
|
||||
|
||||
/* dummy check */
|
||||
if( path == NULL || path[ 0 ] == '\0' )
|
||||
/* dummy check */
|
||||
if( path == NULL || path[ 0 ] == '\0' )
|
||||
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 */
|
||||
for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
|
||||
basePaths[ i + 1 ] = basePaths[ i ];
|
||||
/* make a hole */
|
||||
for( i = (MAX_BASE_PATHS - 2); i >= 0; i-- )
|
||||
basePaths[ i + 1 ] = basePaths[ i ];
|
||||
|
||||
/* concatenate home dir and path */
|
||||
sprintf( temp, "%s/%s", homePath, path );
|
||||
|
||||
/* add it to the list */
|
||||
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
||||
strcpy( basePaths[ 0 ], temp );
|
||||
CleanPath( basePaths[ 0 ] );
|
||||
numBasePaths++;
|
||||
#endif
|
||||
/* add it to the list */
|
||||
basePaths[ 0 ] = safe_malloc( strlen( temp ) + 1 );
|
||||
strcpy( basePaths[ 0 ], temp );
|
||||
CleanPath( basePaths[ 0 ] );
|
||||
numBasePaths++;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user