mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-12-13 21:51:09 +00:00
Unify com_homepath and use XDG_DATA_HOME
This commit is contained in:
parent
cb7ccbacac
commit
95c3deaa0c
4 changed files with 53 additions and 26 deletions
|
@ -2678,7 +2678,10 @@ void Com_Init( char *commandLine ) {
|
||||||
|
|
||||||
com_standalone = Cvar_Get("com_standalone", "0", CVAR_ROM);
|
com_standalone = Cvar_Get("com_standalone", "0", CVAR_ROM);
|
||||||
com_basegame = Cvar_Get("com_basegame", BASEGAME, CVAR_INIT);
|
com_basegame = Cvar_Get("com_basegame", BASEGAME, CVAR_INIT);
|
||||||
com_homepath = Cvar_Get("com_homepath", "", CVAR_INIT);
|
com_homepath = Cvar_Get("com_homepath", HOMEPATH_NAME, CVAR_INIT);
|
||||||
|
if ( !com_homepath->string[0] ) {
|
||||||
|
Cvar_ForceReset( "com_homepath" );
|
||||||
|
}
|
||||||
|
|
||||||
if(!com_basegame->string[0])
|
if(!com_basegame->string[0])
|
||||||
Cvar_ForceReset("com_basegame");
|
Cvar_ForceReset("com_basegame");
|
||||||
|
|
|
@ -31,9 +31,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#define BASEGAME "foobar"
|
#define BASEGAME "foobar"
|
||||||
#define CLIENT_WINDOW_TITLE "changeme"
|
#define CLIENT_WINDOW_TITLE "changeme"
|
||||||
#define CLIENT_WINDOW_MIN_TITLE "changeme2"
|
#define CLIENT_WINDOW_MIN_TITLE "changeme2"
|
||||||
#define HOMEPATH_NAME_UNIX ".foo"
|
|
||||||
#define HOMEPATH_NAME_WIN "FooBar"
|
// GNU/Linux: $HOME/.local/share/homepath-name (lower case and spaces replaced with hyphens)
|
||||||
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
|
// MacOS: $HOME/Library/Application Support/Homepath Name
|
||||||
|
// Windows: %APPDATA%\Homepath Name
|
||||||
|
#define HOMEPATH_NAME "FooBar"
|
||||||
|
|
||||||
#define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace
|
#define GAMENAME_FOR_MASTER "foobar" // must NOT contain whitespace
|
||||||
// #define LEGACY_PROTOCOL // You probably don't need this for your standalone game
|
// #define LEGACY_PROTOCOL // You probably don't need this for your standalone game
|
||||||
#else
|
#else
|
||||||
|
@ -41,9 +44,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#define BASEGAME "baseq3"
|
#define BASEGAME "baseq3"
|
||||||
#define CLIENT_WINDOW_TITLE "ioquake3"
|
#define CLIENT_WINDOW_TITLE "ioquake3"
|
||||||
#define CLIENT_WINDOW_MIN_TITLE "ioq3"
|
#define CLIENT_WINDOW_MIN_TITLE "ioq3"
|
||||||
#define HOMEPATH_NAME_UNIX ".q3a"
|
|
||||||
#define HOMEPATH_NAME_WIN "Quake3"
|
// GNU/Linux: $HOME/.local/share/homepath-name (lower case and spaces replaced with hyphens)
|
||||||
#define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN
|
// MacOS: $HOME/Library/Application Support/Homepath Name
|
||||||
|
// Windows: %APPDATA%\Homepath Name
|
||||||
|
#define HOMEPATH_NAME "Lilium Quake3"
|
||||||
|
|
||||||
#define GAMENAME_FOR_MASTER "Quake3Arena"
|
#define GAMENAME_FOR_MASTER "Quake3Arena"
|
||||||
#define LEGACY_PROTOCOL
|
#define LEGACY_PROTOCOL
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -55,23 +55,46 @@ char *Sys_DefaultHomePath(void)
|
||||||
|
|
||||||
if( !*homePath && com_homepath != NULL )
|
if( !*homePath && com_homepath != NULL )
|
||||||
{
|
{
|
||||||
if( ( p = getenv( "HOME" ) ) != NULL )
|
#ifdef __APPLE__
|
||||||
|
if( ( p = getenv( "HOME" ) ) != NULL && *p != '\0' )
|
||||||
{
|
{
|
||||||
Com_sprintf(homePath, sizeof(homePath), "%s%c", p, PATH_SEP);
|
Com_sprintf(homePath, sizeof(homePath), "%s%cLibrary%cApplication Support%c%s", p, PATH_SEP, PATH_SEP, PATH_SEP, com_homepath->string);
|
||||||
#ifdef MACOS_X
|
}
|
||||||
Q_strcat(homePath, sizeof(homePath),
|
|
||||||
"Library/Application Support/");
|
|
||||||
|
|
||||||
if(com_homepath->string[0])
|
|
||||||
Q_strcat(homePath, sizeof(homePath), com_homepath->string);
|
|
||||||
else
|
|
||||||
Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_MACOSX);
|
|
||||||
#else
|
#else
|
||||||
if(com_homepath->string[0])
|
char directory[MAX_OSPATH];
|
||||||
Q_strcat(homePath, sizeof(homePath), com_homepath->string);
|
char *s;
|
||||||
|
|
||||||
|
Q_strncpyz( directory, com_homepath->string, sizeof(directory) );
|
||||||
|
|
||||||
|
// convert home directory name to lower case and replace spaces with hyphens
|
||||||
|
s = directory;
|
||||||
|
while( *s )
|
||||||
|
{
|
||||||
|
if( *s == ' ' )
|
||||||
|
{
|
||||||
|
*s = '-';
|
||||||
|
}
|
||||||
else
|
else
|
||||||
Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX);
|
{
|
||||||
|
*s = tolower(*s);
|
||||||
|
}
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( p = getenv( "XDG_DATA_HOME" ) ) != NULL && *p != '\0' )
|
||||||
|
{
|
||||||
|
Com_sprintf(homePath, sizeof(homePath), "%s%c%s", p, PATH_SEP, directory);
|
||||||
|
}
|
||||||
|
else if( ( p = getenv( "HOME" ) ) != NULL && *p != '\0' )
|
||||||
|
{
|
||||||
|
Com_sprintf(homePath, sizeof(homePath), "%s%c.local%cshare%c%s", p, PATH_SEP, PATH_SEP, PATH_SEP, directory);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if( !*homePath )
|
||||||
|
{
|
||||||
|
Com_Printf("Unable to detect home path\n");
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,7 @@ char *Sys_DefaultHomePath( void )
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Com_sprintf(homePath, sizeof(homePath), "%s%c", szPath, PATH_SEP);
|
Com_sprintf(homePath, sizeof(homePath), "%s%c%s", szPath, PATH_SEP, com_homepath->string);
|
||||||
|
|
||||||
if(com_homepath->string[0])
|
|
||||||
Q_strcat(homePath, sizeof(homePath), com_homepath->string);
|
|
||||||
else
|
|
||||||
Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_WIN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeLibrary(shfolder);
|
FreeLibrary(shfolder);
|
||||||
|
|
Loading…
Reference in a new issue