From d5c7d8ff829dcc9953e496e77c695f3e5cfdb3db 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


diff --git a/src/system/load_save.c b/src/system/load_save.c
index 98d2283..4293283 100644
--- a/src/system/load_save.c
+++ b/src/system/load_save.c
@@ -42,6 +42,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;
 
@@ -58,6 +62,7 @@ extern Game game;
 	{
 		char *userHome;
 		char dir[MAX_PATH_LENGTH];
+		char path[MAX_PATH_LENGTH];
 		struct passwd *pass;
 
 		pass = getpwuid(geteuid());
@@ -73,6 +78,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
@@ -86,6 +94,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
@@ -99,6 +110,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.30.2

