[iortcw] 85/152: All: Add build option to use XDG base directory spec (.wolf is default)

Simon McVittie smcv at debian.org
Fri Sep 8 10:40:15 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.5a
in repository iortcw.

commit 96eb4af800ce338a0d28052887a3529a2e2dd2c9
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date:   Tue Jul 19 20:22:11 2016 -0400

    All: Add build option to use XDG base directory spec (.wolf is default)
---
 MP/Makefile                      |  9 +++++++++
 MP/code/qcommon/q_shared.h       |  6 +++++-
 MP/code/splines/q_splineshared.h |  6 +++++-
 MP/code/sys/sys_unix.c           | 41 +++++++++++++++++++++++++++++++++++-----
 SP/Makefile                      |  9 +++++++++
 SP/code/qcommon/q_shared.h       |  6 +++++-
 SP/code/splines/q_splineshared.h |  6 +++++-
 SP/code/sys/sys_unix.c           | 41 +++++++++++++++++++++++++++++++++++-----
 8 files changed, 110 insertions(+), 14 deletions(-)

diff --git a/MP/Makefile b/MP/Makefile
index 54bbc25..d9c737c 100644
--- a/MP/Makefile
+++ b/MP/Makefile
@@ -253,6 +253,10 @@ ifndef USE_RENDERER_DLOPEN
 USE_RENDERER_DLOPEN=1
 endif
 
+ifndef USE_XDG
+USE_XDG=0
+endif
+
 ifndef USE_YACC
 USE_YACC=0
 endif
@@ -1075,6 +1079,11 @@ ifeq ($(USE_RENDERER_DLOPEN),1)
   CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN
 endif
 
+ifeq ($(USE_XDG),1)
+  CLIENT_CFLAGS += -DUSE_XDG
+  SERVER_CFLAGS += -DUSE_XDG
+endif
+
 ifeq ($(USE_MUMBLE),1)
   CLIENT_CFLAGS += -DUSE_MUMBLE
 endif
diff --git a/MP/code/qcommon/q_shared.h b/MP/code/qcommon/q_shared.h
index 1127b81..599192e 100644
--- a/MP/code/qcommon/q_shared.h
+++ b/MP/code/qcommon/q_shared.h
@@ -62,7 +62,11 @@ If you have questions concerning this license or the applicable additional terms
   #define BASEGAME			"main"
   #define CLIENT_WINDOW_TITLE     	"Return To Castle Wolfenstein"
   #define CLIENT_WINDOW_MIN_TITLE 	"iowolfmp"
-  #define HOMEPATH_NAME_UNIX		".iortcw"
+#ifdef USE_XDG
+  #define HOMEPATH_NAME_UNIX		"iortcw"
+#else
+  #define HOMEPATH_NAME_UNIX		".wolf"
+#endif
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
   #define STEAMPATH_APPID		"9010"
diff --git a/MP/code/splines/q_splineshared.h b/MP/code/splines/q_splineshared.h
index 49e0f9c..a57af6e 100644
--- a/MP/code/splines/q_splineshared.h
+++ b/MP/code/splines/q_splineshared.h
@@ -58,7 +58,11 @@ If you have questions concerning this license or the applicable additional terms
   #define BASEGAME			"main"
   #define CLIENT_WINDOW_TITLE     	"Return To Castle Wolfenstein"
   #define CLIENT_WINDOW_MIN_TITLE 	"iowolfmp"
-  #define HOMEPATH_NAME_UNIX		".iortcw"
+#ifdef USE_XDG
+  #define HOMEPATH_NAME_UNIX		"iortcw"
+#else
+  #define HOMEPATH_NAME_UNIX		".wolf"
+#endif
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfmp"
diff --git a/MP/code/sys/sys_unix.c b/MP/code/sys/sys_unix.c
index 9fe98b8..4318eac 100644
--- a/MP/code/sys/sys_unix.c
+++ b/MP/code/sys/sys_unix.c
@@ -43,6 +43,9 @@ qboolean stdinIsATTY;
 
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
+#ifdef USE_XDG
+static const char DEFAULT_XDG_DATA_HOME[] = {'.', 'l', 'o', 'c', 'a', 'l', PATH_SEP, 's', 'h', 'a', 'r', 'e', '\0'};
+#endif
 
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
@@ -56,14 +59,18 @@ Sys_DefaultHomePath
 */
 char *Sys_DefaultHomePath(void)
 {
-	char *p;
+	char *p1;
+#ifdef USE_XDG
+	char *p2;
+#endif
 
 	if( !*homePath && com_homepath != NULL )
 	{
-		if( ( p = getenv( "HOME" ) ) != NULL )
-		{
-			Com_sprintf(homePath, sizeof(homePath), "%s%c", p, PATH_SEP);
 #ifdef __APPLE__
+		if( ( p1 = getenv( "HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
 			Q_strcat(homePath, sizeof(homePath),
 				"Library/Application Support/");
 
@@ -72,12 +79,36 @@ char *Sys_DefaultHomePath(void)
 			else
 				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_MACOSX);
 #else
+#ifdef USE_XDG
+		if( ( p1 = getenv( "XDG_DATA_HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
+		}
+		else if( ( p2 = getenv( "HOME" ) ) != NULL)
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c%s%c", p2, PATH_SEP, DEFAULT_XDG_DATA_HOME, PATH_SEP);
+		}
+
+		if (p1 || p2)
+		{
 			if(com_homepath->string[0])
 				Q_strcat(homePath, sizeof(homePath), com_homepath->string);
 			else
 				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX);
-#endif
 		}
+#else
+		if( ( p1 = getenv( "HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
+			if(com_homepath->string[0])
+				Q_strcat(homePath, sizeof(homePath), com_homepath->string);
+			else
+				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX);
+		}
+#endif // USE_XDG
+#endif
 	}
 
 	return homePath;
diff --git a/SP/Makefile b/SP/Makefile
index 704370c..4316045 100644
--- a/SP/Makefile
+++ b/SP/Makefile
@@ -250,6 +250,10 @@ ifndef USE_RENDERER_DLOPEN
 USE_RENDERER_DLOPEN=1
 endif
 
+ifndef USE_XDG
+USE_XDG=0
+endif
+
 ifndef USE_YACC
 USE_YACC=0
 endif
@@ -1060,6 +1064,11 @@ ifeq ($(USE_RENDERER_DLOPEN),1)
   CLIENT_CFLAGS += -DUSE_RENDERER_DLOPEN
 endif
 
+ifeq ($(USE_XDG),1)
+  CLIENT_CFLAGS += -DUSE_XDG
+  SERVER_CFLAGS += -DUSE_XDG
+endif
+
 ifeq ($(USE_MUMBLE),1)
   CLIENT_CFLAGS += -DUSE_MUMBLE
 endif
diff --git a/SP/code/qcommon/q_shared.h b/SP/code/qcommon/q_shared.h
index f37ca78..65e8b88 100644
--- a/SP/code/qcommon/q_shared.h
+++ b/SP/code/qcommon/q_shared.h
@@ -59,7 +59,11 @@ If you have questions concerning this license or the applicable additional terms
   #define BASEGAME			"main"
   #define CLIENT_WINDOW_TITLE     	"Return To Castle Wolfenstein"
   #define CLIENT_WINDOW_MIN_TITLE 	"iowolfsp"
-  #define HOMEPATH_NAME_UNIX		".iortcw"
+#ifdef USE_XDG
+  #define HOMEPATH_NAME_UNIX		"iortcw"
+#else
+  #define HOMEPATH_NAME_UNIX		".wolf"
+#endif
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define STEAMPATH_NAME		"Return To Castle Wolfenstein"
   #define STEAMPATH_APPID		"9010"
diff --git a/SP/code/splines/q_splineshared.h b/SP/code/splines/q_splineshared.h
index 17addf5..87b17be 100644
--- a/SP/code/splines/q_splineshared.h
+++ b/SP/code/splines/q_splineshared.h
@@ -55,7 +55,11 @@ If you have questions concerning this license or the applicable additional terms
   #define BASEGAME			"main"
   #define CLIENT_WINDOW_TITLE     	"Return To Castle Wolfenstein"
   #define CLIENT_WINDOW_MIN_TITLE 	"iowolfsp"
-  #define HOMEPATH_NAME_UNIX		".iortcw"
+#ifdef USE_XDG
+  #define HOMEPATH_NAME_UNIX		"iortcw"
+#else
+  #define HOMEPATH_NAME_UNIX		".wolf"
+#endif
   #define HOMEPATH_NAME_WIN		"RTCW"
   #define HOMEPATH_NAME_MACOSX		HOMEPATH_NAME_WIN
   #define GAMENAME_FOR_MASTER		"wolfsp"
diff --git a/SP/code/sys/sys_unix.c b/SP/code/sys/sys_unix.c
index f7aa689..16db8af 100644
--- a/SP/code/sys/sys_unix.c
+++ b/SP/code/sys/sys_unix.c
@@ -43,6 +43,9 @@ qboolean stdinIsATTY;
 
 // Used to determine where to store user-specific files
 static char homePath[ MAX_OSPATH ] = { 0 };
+#ifdef USE_XDG
+static const char DEFAULT_XDG_DATA_HOME[] = {'.', 'l', 'o', 'c', 'a', 'l', PATH_SEP, 's', 'h', 'a', 'r', 'e', '\0'};
+#endif
 
 #ifndef STANDALONE
 // Used to store the Steam RTCW installation path
@@ -56,14 +59,18 @@ Sys_DefaultHomePath
 */
 char *Sys_DefaultHomePath(void)
 {
-	char *p;
+	char *p1;
+#ifdef USE_XDG
+	char *p2;
+#endif
 
 	if( !*homePath && com_homepath != NULL )
 	{
-		if( ( p = getenv( "HOME" ) ) != NULL )
-		{
-			Com_sprintf(homePath, sizeof(homePath), "%s%c", p, PATH_SEP);
 #ifdef __APPLE__
+		if( ( p1 = getenv( "HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
 			Q_strcat(homePath, sizeof(homePath),
 				"Library/Application Support/");
 
@@ -72,12 +79,36 @@ char *Sys_DefaultHomePath(void)
 			else
 				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_MACOSX);
 #else
+#ifdef USE_XDG
+		if( ( p1 = getenv( "XDG_DATA_HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
+		}
+		else if( ( p2 = getenv( "HOME" ) ) != NULL)
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c%s%c", p2, PATH_SEP, DEFAULT_XDG_DATA_HOME, PATH_SEP);
+		}
+
+		if (p1 || p2)
+		{
 			if(com_homepath->string[0])
 				Q_strcat(homePath, sizeof(homePath), com_homepath->string);
 			else
 				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX);
-#endif
 		}
+#else
+		if( ( p1 = getenv( "HOME" ) ) != NULL )
+		{
+			Com_sprintf(homePath, sizeof(homePath), "%s%c", p1, PATH_SEP);
+
+			if(com_homepath->string[0])
+				Q_strcat(homePath, sizeof(homePath), com_homepath->string);
+			else
+				Q_strcat(homePath, sizeof(homePath), HOMEPATH_NAME_UNIX);
+		}
+#endif // USE_XDG
+#endif
 	}
 
 	return homePath;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list