From 75a7140e56071a2214ede84ac404013661890b8e Mon Sep 17 00:00:00 2001
From: TURX <turx2003@gmail.com>
Date: Tue, 21 Jan 2020 23:14:22 +0800
Subject: [PATCH] fix Haiku support

---
 src/system/load_save.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/system/load_save.c b/src/system/load_save.c
index 2d55feba5..b2309a4c3 100644
--- a/src/system/load_save.c
+++ b/src/system/load_save.c
@@ -41,6 +41,10 @@ Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
 #include "load_save.h"
 #include "resources.h"
 
+#ifdef __HAIKU__
+#include <FindDirectory.h>
+#endif
+
 static char gameSavePath[MAX_PATH_LENGTH], tempFile[MAX_PATH_LENGTH], saveFileIndex[MAX_PATH_LENGTH], continueFile[MAX_PATH_LENGTH];
 static int temporaryDataExists;
 
@@ -57,6 +61,7 @@ extern Game game;
 	{
 		char *userHome;
 		char dir[MAX_PATH_LENGTH];
+		char path[MAX_PATH_LENGTH];
 		struct passwd *pass;
 
 		pass = getpwuid(geteuid());
@@ -72,6 +77,9 @@ extern Game game;
 
 		#if MACOS == 1
 		snprintf(dir, sizeof(dir), "%s/Library/Application Support", userHome);
+		#elif defined(__HAIKU__)
+		find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, path, sizeof(path));
+		snprintf(dir, sizeof(dir), "%s/parallelrealities", path);
 		#else
 		snprintf(dir, sizeof(dir), "%s/.parallelrealities", userHome);
 		#endif
@@ -85,6 +93,9 @@ extern Game game;
 
 		#if MACOS == 1
 		snprintf(dir, sizeof(dir), "%s/Library/Application Support/Edgar", userHome);
+		#elif defined(__HAIKU__)
+		find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, path, sizeof(path));
+		snprintf(dir, sizeof(dir), "%s/parallelrealities/Edgar", path);
 		#else
 		snprintf(dir, sizeof(dir), "%s/.parallelrealities/edgar", userHome);
 		#endif
@@ -98,6 +109,9 @@ extern Game game;
 
 		#if MACOS == 1
 		snprintf(gameSavePath, sizeof(gameSavePath), "%s/Library/Application Support/Edgar/", userHome);
+		#elif defined(__HAIKU__)
+		find_directory(B_USER_SETTINGS_DIRECTORY, 0, true, path, sizeof(path));
+		snprintf(gameSavePath, sizeof(gameSavePath), "%s/parallelrealities/Edgar", path);
 		#else
 		snprintf(gameSavePath, sizeof(gameSavePath), "%s/.parallelrealities/edgar/", userHome);
 		#endif
-- 
2.20.1

