freeciv: use settings directory.

This commit is contained in:
Jerome Duval
2019-12-15 22:09:55 +01:00
parent abb57971f2
commit 3bd689b105
2 changed files with 217 additions and 94 deletions

View File

@@ -70,7 +70,7 @@ BUILD_REQUIRES="
devel:liblua$secondaryArchSuffix >= 5.3
devel:libintl$secondaryArchSuffix
devel:liblzma$secondaryArchSuffix
devel:libreadline$secondaryArchSuffix
devel:libreadline$secondaryArchSuffix >= 8
devel:libsdl$secondaryArchSuffix
devel:libsdl_gfx$secondaryArchSuffix
devel:libsdl_image$secondaryArchSuffix
@@ -101,6 +101,8 @@ INSTALL()
{
make install
rm -f $libDir/*.a $libDir/*.la
mkdir -p $appsDir
ln -s $commandBinDir/freeciv-sdl $appsDir/Freeciv
@@ -119,6 +121,6 @@ INSTALL()
$appsDir/Freeciv
addAppDeskbarSymlink $appsDir/Freeciv
mv -T $prefix/share $dataRootDir
rm -f $libDir/*.a $libDir/*.la
mv $prefix/share/* $dataRootDir
rmdir $prefix/share
}

View File

@@ -1,11 +1,8 @@
From f7d7df9c246926873333e53eca683d93ff09d8df Mon Sep 17 00:00:00 2001
From 99288b21d4e75ac960e9fe37c05115b705709069 Mon Sep 17 00:00:00 2001
From: Bach Nguyen <bach5000@gmail.com>
Date: Fri, 26 Oct 2018 17:45:41 +0000
Subject: [PATCH] Haiku support #1
Subject: Haiku support #1
---
configure.ac | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 9cb722a..6aa18a8 100644
@@ -49,103 +46,209 @@ index 9cb722a..6aa18a8 100644
CPPFLAGS="$CPPFLAGS -DFC_CONF_PATH=\"\\\"$FC_CONF_PATH\\\"\""
CPPFLAGS="$CPPFLAGS -DDEFAULT_DATA_PATH=\"\\\"$DEFAULT_DATA_PATH\\\"\""
--
2.19.0
2.24.0
From ed55a9b2f0ce7ca20af1c32beb66854235a30418 Mon Sep 17 00:00:00 2001
From: Bach Nguyen <bach5000@gmail.com>
Date: Fri, 26 Oct 2018 18:39:18 +0000
Subject: [PATCH] Reapply patches
From 9855a04556a64cdad9e603953a0756f438db85d2 Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Sun, 15 Dec 2019 20:30:55 +0100
Subject: Use settings directory.
---
client/connectdlg_common.c | 18 +++++++++++++++++-
client/options.c | 19 +++++++++++++++++--
common/mapimg.c | 2 +-
server/gamehand.c | 3 ++-
server/sernet.c | 17 ++++++++++++++++-
5 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/client/connectdlg_common.c b/client/connectdlg_common.c
index 2ec9b13..fa20a8f 100644
index 2ec9b13..7fce908 100644
--- a/client/connectdlg_common.c
+++ b/client/connectdlg_common.c
@@ -293,9 +293,17 @@ bool client_start_server(void)
@@ -26,6 +26,12 @@ Freeciv - Copyright (C) 2004 - The Freeciv Project
#include <windows.h>
#endif
+#ifdef __HAIKU__
+ #include <libgen.h>
+ #include <FindDirectory.h>
+ #include <fs_info.h>
+#endif
+
#ifdef FREECIV_HAVE_SYS_TYPES_H
#include <sys/types.h> /* fchmod */
#endif
@@ -274,6 +280,25 @@ bool client_start_server(void)
#ifdef HAVE_USABLE_FORK
{
+#ifdef __HAIKU__
+ static char fullnamesaves[PATH_MAX];
+ static char fullnamescenarios[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ fullnamesaves, sizeof(fullnamesaves) - 1) != B_OK) {
+ log_error(_("Cannot find your settings directory"));
+ }
+ strlcat(fullnamesaves, DIR_SEPARATOR "freeciv" DIR_SEPARATOR "saves",
+ sizeof(fullnamesaves));
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ fullnamescenarios, sizeof(fullnamescenarios) - 1) != B_OK) {
+ log_error(_("Cannot find your settings directory"));
+ }
+ strlcat(fullnamescenarios, DIR_SEPARATOR "freeciv" DIR_SEPARATOR "scenarios",
+ sizeof(fullnamescenarios));
+#endif
int argc = 0;
const int max_nargs = 23;
char *argv[max_nargs + 1];
@@ -293,9 +318,17 @@ bool client_start_server(void)
argv[argc++] = "1";
argv[argc++] = "-e";
argv[argc++] = "--saves";
+#ifdef __HAIKU__
+ argv[argc++] = "~/config/settings/freeciv/saves";
+ argv[argc++] = fullnamesaves;
+#else
argv[argc++] = "~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR "saves";
+#endif
argv[argc++] = "--scenarios";
+#ifdef __HAIKU__
+ argv[argc++] = "~/config/settings/freeciv/scenarios";
+ argv[argc++] = fullnamescenarios;
+#else
argv[argc++] = "~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR "scenarios";
+#endif
argv[argc++] = "-A";
argv[argc++] = "none";
if (logfile) {
@@ -431,12 +439,19 @@ bool client_start_server(void)
@@ -431,10 +464,27 @@ bool client_start_server(void)
free(savefile_in_local_encoding);
}
+#ifdef __HAIKU__
+ interpret_tilde(savesdir, sizeof(savesdir), "~/config/settings/freeciv/saves");
+#else
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ savesdir, sizeof(savesdir) - 1) == B_OK)
+ sz_strlcat(savesdir, "freeciv" DIR_SEPARATOR "saves");
+ else
+#endif
interpret_tilde(savesdir, sizeof(savesdir),
"~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR "saves");
+#endif
internal_to_local_string_buffer(savesdir, savescmdline, sizeof(savescmdline));
-
+#ifdef __HAIKU__
+ interpret_tilde(scensdir, sizeof(scensdir), "~/config/settings/freeciv/scenarios");
+#else
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ scensdir, sizeof(scensdir) - 1) == B_OK)
+ sz_strlcat(scensdir, "freeciv" DIR_SEPARATOR "scenarios");
+ else
+#endif
interpret_tilde(scensdir, sizeof(scensdir),
"~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR "scenarios");
+#endif
internal_to_local_string_buffer(scensdir, scenscmdline, sizeof(scenscmdline));
if (are_deprecation_warnings_enabled()) {
@@ -599,6 +614,7 @@ void send_client_wants_hack(const char *filename)
@@ -599,8 +649,20 @@ void send_client_wants_hack(const char *filename)
}
/* get the full filename path */
+
+#ifdef __HAIKU__
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ challenge_fullname, sizeof(challenge_fullname) - 1) != B_OK) {
+ log_error(_("Cannot find your settings directory"));
+ }
+ sz_strlcat(challenge_fullname, DIR_SEPARATOR "freeciv" DIR_SEPARATOR);
+#else
interpret_tilde(challenge_fullname, sizeof(challenge_fullname),
"~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR);
+#endif
make_dir(challenge_fullname);
sz_strlcat(challenge_fullname, filename);
diff --git a/client/options.c b/client/options.c
index c8fb482..d5ee371 100644
index c8fb482..223eb83 100644
--- a/client/options.c
+++ b/client/options.c
@@ -19,6 +19,9 @@
@@ -19,6 +19,11 @@
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
+#ifdef __HAIKU__
+ #include <libgen.h>
+ #include <FindDirectory.h>
+ #include <fs_info.h>
+#endif
/* utility */
#include "capability.h"
@@ -5107,7 +5110,13 @@ static void save_cma_presets(struct section_file *file)
/* Old rc file name. */
#define OLD_OPTION_FILE_NAME ".civclientrc"
/* New rc file name. */
-#define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
+#ifdef __HAIKU__
+# define MID_OPTION_FILE_NAME "config/settings/freeciv/freeciv-client-rc-%d.%d"
+# define NEW_OPTION_FILE_NAME "config/settings/freeciv/freeciv-client-rc-%d.%d"
@@ -5148,6 +5153,20 @@ static const char *get_current_option_file_name(void)
} else {
#ifdef OPTION_FILE_NAME
fc_strlcpy(name_buffer, OPTION_FILE_NAME, sizeof(name_buffer));
+#else
+# define MID_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
+# define NEW_OPTION_FILE_NAME ".freeciv-client-rc-%d.%d"
+#ifdef __HAIKU__
+ static char fullname[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ fullname, sizeof(fullname) - 1) != B_OK) {
+ log_error(_("Cannot find your settings directory"));
+ return NULL;
+ }
+ fc_snprintf(name_buffer, sizeof(name_buffer),
+ "%s" DIR_SEPARATOR "freeciv" DIR_SEPARATOR NEW_OPTION_FILE_NAME,
+ fullname, MAJOR_NEW_OPTION_FILE_NAME, MINOR_NEW_OPTION_FILE_NAME);
#else
name = user_home_dir();
if (!name) {
@@ -5157,6 +5176,7 @@ static const char *get_current_option_file_name(void)
fc_snprintf(name_buffer, sizeof(name_buffer),
"%s" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR NEW_OPTION_FILE_NAME,
name, MAJOR_NEW_OPTION_FILE_NAME, MINOR_NEW_OPTION_FILE_NAME);
+#endif
#define NEW_OPTION_FILE_NAME "freeciv-client-rc-%d.%d"
#if MINOR_VERSION >= 90
#define MAJOR_NEW_OPTION_FILE_NAME (MAJOR_VERSION + 1)
@@ -5931,7 +5940,13 @@ void options_save(option_save_log_callback log_cb)
#endif /* OPTION_FILE_NAME */
}
log_verbose("settings file is %s", name_buffer);
@@ -5194,11 +5214,24 @@ static const char *get_last_option_file_name(bool *allow_digital_boolean)
int major, minor;
struct stat buf;
+#ifdef __HAIKU__
+ static char fullname[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ fullname, sizeof(fullname) - 1) != B_OK) {
+ log_error(_("Cannot find your settings directory"));
+ return NULL;
+ }
+ name = fullname;
+#else
name = user_home_dir();
if (!name) {
log_error(_("Cannot find your home directory"));
return NULL;
}
+#endif
for (major = MAJOR_NEW_OPTION_FILE_NAME,
minor = MINOR_NEW_OPTION_FILE_NAME;
major >= FIRST_MAJOR_NEW_OPTION_FILE_NAME; major--) {
@@ -5206,7 +5239,11 @@ static const char *get_last_option_file_name(bool *allow_digital_boolean)
? minor >= FIRST_MINOR_NEW_OPTION_FILE_NAME
: minor >= 0); minor--) {
fc_snprintf(name_buffer, sizeof(name_buffer),
+#ifdef __HAIKU__
+ "%s" DIR_SEPARATOR "freeciv" DIR_SEPARATOR NEW_OPTION_FILE_NAME,
+#else
"%s" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR NEW_OPTION_FILE_NAME,
+#endif
name, major, minor);
if (0 == fc_stat(name_buffer, &buf)) {
if (MAJOR_NEW_OPTION_FILE_NAME != major
@@ -5931,7 +5968,13 @@ void options_save(option_save_log_callback log_cb)
/* insert global worklists */
global_worklists_save(sf);
@@ -160,74 +263,92 @@ index c8fb482..d5ee371 100644
/* Directory name */
sz_strlcpy(dir_name, name);
for (i = strlen(dir_name) - 1 ; dir_name[i] != DIR_SEPARATOR_CHAR && i >= 0; i--) {
diff --git a/common/mapimg.c b/common/mapimg.c
index 4f1c1ad..6f32b4f 100644
--- a/common/mapimg.c
+++ b/common/mapimg.c
@@ -18,7 +18,7 @@
#include <stdarg.h>
#ifdef HAVE_MAPIMG_MAGICKWAND
- #include <wand/MagickWand.h>
+ #include <MagickWand/MagickWand.h>
#endif /* HAVE_MAPIMG_MAGICKWAND */
/* utility */
diff --git a/server/gamehand.c b/server/gamehand.c
index 3b8a03e..f1466cd 100644
index 3b8a03e..0276a50 100644
--- a/server/gamehand.c
+++ b/server/gamehand.c
@@ -1023,7 +1023,8 @@ static const char *get_challenge_fullname(struct connection *pc)
@@ -17,6 +17,12 @@
#include <stdio.h> /* for remove() */
+#ifdef __HAIKU__
+ #include <libgen.h>
+ #include <FindDirectory.h>
+ #include <fs_info.h>
+#endif
+
/* utility */
#include "capability.h"
#include "fcintl.h"
@@ -1023,7 +1029,17 @@ static const char *get_challenge_fullname(struct connection *pc)
{
static char fullname[MAX_LEN_PATH];
- interpret_tilde(fullname, sizeof(fullname), "~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR);
+ //interpret_tilde(fullname, sizeof(fullname), "~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR);
+ interpret_tilde(fullname, sizeof(fullname), "~/config/settings/freeciv/");
+#ifdef __HAIKU__
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ fullname, sizeof(fullname) - 1) != B_OK)
+ return NULL;
+ sz_strlcat(fullname, DIR_SEPARATOR "freeciv" DIR_SEPARATOR);
+#else
interpret_tilde(fullname, sizeof(fullname), "~" DIR_SEPARATOR ".freeciv" DIR_SEPARATOR);
+#endif
sz_strlcat(fullname, get_challenge_filename(pc));
return fullname;
diff --git a/server/sernet.c b/server/sernet.c
index 46ec7d5..5317471 100644
index 46ec7d5..6cb46ba 100644
--- a/server/sernet.c
+++ b/server/sernet.c
@@ -44,6 +44,9 @@
@@ -44,6 +44,11 @@
#ifdef FREECIV_HAVE_LIBREADLINE
#include <readline/history.h>
#include <readline/readline.h>
+#ifdef __HAIKU__
+#include <libgen.h>
+#include <FindDirectory.h>
+#include <fs_info.h>
+#endif
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
@@ -157,7 +160,12 @@ static void handle_stdin_close(void)
@@ -507,6 +512,7 @@ enum server_events server_sniff_all_input(void)
#ifdef FREECIV_HAVE_LIBREADLINE
/****************************************************************************/
{
if (!no_input && !readline_initialized) {
+#ifndef __HAIKU__
char *home_dir = user_home_dir();
-#define HISTORY_FILENAME "freeciv-server_history"
+//#define HISTORY_FILENAME "freeciv-server_history"
+#ifdef __HAIKU__
+# define HISTORY_FILENAME "config/settings/freeciv/server_history"
if (home_dir) {
@@ -530,6 +536,26 @@ enum server_events server_sniff_all_input(void)
FC_FREE(fc_dir);
}
}
+#else
+# define HISTORY_FILENAME ".freeciv-server_history"
+ char path[PATH_MAX];
+ dev_t bootdev = dev_for_path("/boot");
+ if (bootdev < 0)
+ bootdev = 0;
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, bootdev, false,
+ path, sizeof(path) - 1) == B_OK) {
+ if (make_dir(path)) {
+ strlcat(path, "freeciv/", sizeof(path));
+ if (make_dir(path)) {
+ strlcat(path, HISTORY_FILENAME, sizeof(path));
+ history_file = strdup(path);
+ if (history_file) {
+ using_history();
+ read_history(history_file);
+ }
+ }
+ }
+ }
+#endif
#define HISTORY_LENGTH 100
static char *history_file = NULL;
@@ -523,6 +531,13 @@ enum server_events server_sniff_all_input(void)
strcpy(history_file, fc_dir);
strcat(history_file, "/");
strcat(history_file, HISTORY_FILENAME);
+#ifdef __HAIKU__
+ {
+ char path[PATH_MAX];
+ strcpy(path, history_file);
+ make_dir(dirname(path));
+ }
+#endif
using_history();
read_history(history_file);
}
rl_initialize();
rl_callback_handler_install((char *) "> ",
--
2.19.0
2.24.0