(svn r11837) -Feature: [OSX] added "/Library/Application Support/OpenTTD" to the search paths (based on patch by pv2b)
authorbjarni
Sun, 13 Jan 2008 17:45:29 +0000
changeset 8769 ee288fa819f6
parent 8768 a45175c17e5b
child 8770 f152783e12c3
(svn r11837) -Feature: [OSX] added "/Library/Application Support/OpenTTD" to the search paths (based on patch by pv2b)
It is possible to set this to something else setting shared-dir with config
This works on other OSes as well but it's off by default (and not really tested)
config.lib
src/fileio.cpp
--- a/config.lib	Sun Jan 13 17:37:17 2008 +0000
+++ b/config.lib	Sun Jan 13 17:45:29 2008 +0000
@@ -30,6 +30,7 @@
 	data_dir="share/games/openttd"
 	icon_dir="share/pixmaps"
 	personal_dir="1"
+	shared_dir="1"
 	install_dir="/"
 	enable_debug="0"
 	enable_desync_debug="0"
@@ -86,6 +87,7 @@
 		data_dir
 		icon_dir
 		personal_dir
+		shared_dir
 		install_dir
 		enable_debug
 		enable_desync_debug
@@ -193,6 +195,10 @@
 			--personal-dir=*)             personal_dir="$optarg";;
 			--without-personal-dir)       personal_dir="";;
 
+			--shared-dir)                 prevp_p="shared-dir";;
+			--shared-dir=*)               shared_dir="$optarg";;
+			--without-shared-dir)         shared_dir="";;
+
 			--install-dir)                prevp_p="install-dir";;
 			--install-dir=*)              install_dir="$optarg";;
 
@@ -814,6 +820,15 @@
 		fi
 	fi
 
+	if [ "$shared_dir" = "1" ]; then
+		# we are using default values
+		if [ "$os" = "OSX" ]; then
+			shared_dir='/Library/Application\\ Support/OpenTTD'
+		else
+			shared_dir=""
+		fi
+	fi
+
 	if [ -n "$personal_dir" ]
 	then
 		log 1 "personal home directory... $personal_dir"
@@ -821,6 +836,13 @@
 		log 1 "personal home directory... none"
 	fi
 
+	if [ -n "$shared_dir" ]
+	then
+		log 1 "shared data directory... $shared_dir"
+	else
+		log 1 "shared data directory... none"
+	fi
+
 	if [ -n "$install_dir" ]
 	then
 		log 1 "installation directory... $install_dir"
@@ -1181,6 +1203,10 @@
 		CFLAGS="$CFLAGS -DWITH_PERSONAL_DIR -DPERSONAL_DIR=\\\\\"$personal_dir\\\\\""
 	fi
 
+	if [ -n "$shared_dir" ]; then
+		CFLAGS="$CFLAGS -DWITH_SHARED_DIR -DSHARED_DIR=\\\\\"$shared_dir\\\\\""
+	fi
+
 	CFLAGS="$CFLAGS -DGLOBAL_DATA_DIR=\\\\\"$prefix_dir/$data_dir\\\\\""
 
 	log 1 "using CFLAGS... $CFLAGS $CC_CFLAGS"
@@ -2151,6 +2177,7 @@
 		s#!!DATA_DIR!!#$prefix_dir/$data_dir#g;
 		s#!!ICON_DIR!!#$prefix_dir/$icon_dir#g;
 		s#!!PERSONAL_DIR!!#$personal_dir#g;
+		s#!!SHARED_DIR!!#$shared_dir#g;
 		s#!!INSTALL_DIR!!#$install_dir#g;
 		s#!!STRGEN!!#$STRGEN#g;
 		s#!!ENDIAN_CHECK!!#$ENDIAN_CHECK#g;
@@ -2291,7 +2318,10 @@
 	echo "                                 [share/games/openttd]"
 	echo "  --icon-dir=dir                 location of icons. Will be prefixed"
 	echo "                                 with the prefix-dir [share/pixmaps]"
-	echo "  --personal-dir=dir             location of the personal directory [.openttd]"
+	echo "  --personal-dir=dir             location of the personal directory"
+	echo "                                 [os-dependent default]"
+	echo "  --shared-dir=dir               location of shared data files"
+	echo "                                 [os-dependent default]"
 	echo "  --install-dir=dir              specifies the root to install to."
 	echo "                                 Useful to install into jails [/]"
 	echo ""
--- a/src/fileio.cpp	Sun Jan 13 17:37:17 2008 +0000
+++ b/src/fileio.cpp	Sun Jan 13 17:45:29 2008 +0000
@@ -646,7 +646,14 @@
 
 	_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
 #endif
+
+#if defined(WITH_SHARED_DIR)
+	snprintf(tmp, MAX_PATH, "%s", SHARED_DIR);
+	AppendPathSeparator(tmp, MAX_PATH);
+	_searchpaths[SP_SHARED_DIR] = strdup(tmp);
+#else
 	_searchpaths[SP_SHARED_DIR] = NULL;
+#endif
 
 #if defined(__MORPHOS__) || defined(__AMIGA__)
 	_searchpaths[SP_WORKING_DIR] = NULL;