diff --git a/code/qcommon/common.c b/code/qcommon/common.c index c72ae376..01a2bd7c 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -2678,7 +2678,10 @@ void Com_Init( char *commandLine ) { com_standalone = Cvar_Get("com_standalone", "0", CVAR_ROM); 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]) Cvar_ForceReset("com_basegame"); diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 9cca1252..1ea403bc 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -31,9 +31,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define BASEGAME "foobar" #define CLIENT_WINDOW_TITLE "changeme" #define CLIENT_WINDOW_MIN_TITLE "changeme2" - #define HOMEPATH_NAME_UNIX ".foo" - #define HOMEPATH_NAME_WIN "FooBar" - #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN + + // GNU/Linux: $HOME/.local/share/homepath-name (lower case and spaces replaced with hyphens) + // 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 LEGACY_PROTOCOL // You probably don't need this for your standalone game #else @@ -41,9 +44,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define BASEGAME "baseq3" #define CLIENT_WINDOW_TITLE "ioquake3" #define CLIENT_WINDOW_MIN_TITLE "ioq3" - #define HOMEPATH_NAME_UNIX ".q3a" - #define HOMEPATH_NAME_WIN "Quake3" - #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN + + // GNU/Linux: $HOME/.local/share/homepath-name (lower case and spaces replaced with hyphens) + // MacOS: $HOME/Library/Application Support/Homepath Name + // Windows: %APPDATA%\Homepath Name + #define HOMEPATH_NAME "Lilium Quake3" + #define GAMENAME_FOR_MASTER "Quake3Arena" #define LEGACY_PROTOCOL #endif diff --git a/code/sys/sys_unix.c b/code/sys/sys_unix.c index 0cffd4f1..e3ec1b5a 100644 --- a/code/sys/sys_unix.c +++ b/code/sys/sys_unix.c @@ -55,23 +55,46 @@ char *Sys_DefaultHomePath(void) 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); -#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); + Com_sprintf(homePath, sizeof(homePath), "%s%cLibrary%cApplication Support%c%s", p, PATH_SEP, PATH_SEP, PATH_SEP, com_homepath->string); + } #else - if(com_homepath->string[0]) - Q_strcat(homePath, sizeof(homePath), com_homepath->string); + char directory[MAX_OSPATH]; + 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 - 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 + + if( !*homePath ) + { + Com_Printf("Unable to detect home path\n"); + return NULL; } } diff --git a/code/sys/sys_win32.c b/code/sys/sys_win32.c index 50d1bb4b..af0b9ff0 100644 --- a/code/sys/sys_win32.c +++ b/code/sys/sys_win32.c @@ -114,12 +114,7 @@ char *Sys_DefaultHomePath( void ) return NULL; } - Com_sprintf(homePath, sizeof(homePath), "%s%c", szPath, PATH_SEP); - - if(com_homepath->string[0]) - Q_strcat(homePath, sizeof(homePath), com_homepath->string); - else - Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_WIN); + Com_sprintf(homePath, sizeof(homePath), "%s%c%s", szPath, PATH_SEP, com_homepath->string); } FreeLibrary(shfolder);