0
0
Fork 0
haikuports/games-action/lugaru/patches/lugaru-1.2.patchset

128 lines
3.6 KiB
Plaintext

From b6803ff333dedffab76d8e426434e059963e6519 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 8 Oct 2018 20:40:18 +1000
Subject: Fixes for Haiku
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3958eeb..dffd375 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -242,6 +242,10 @@ set(LUGARU_LIBS ${OPENAL_LIBRARY} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${ZLIB_LIBRARIE
add_executable(lugaru ${LUGARU_SRCS} ${LUGARU_H} ${LUGARU_OBJS})
target_link_libraries(lugaru ${LUGARU_LIBS})
+if(HAIKU)
+ target_link_libraries(lugaru -lbe)
+endif(HAIKU)
+
if(WIN32)
add_definitions(-DBinIO_STDINT_HEADER=<stdint.h>)
if(MINGW)
diff --git a/Source/Utils/Folders.cpp b/Source/Utils/Folders.cpp
index 2183c51..72454c6 100644
--- a/Source/Utils/Folders.cpp
+++ b/Source/Utils/Folders.cpp
@@ -36,6 +36,11 @@ along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
#include <windows.h>
#endif
+#ifdef __HAIKU__
+#include <Path.h>
+#include <PathFinder.h>
+#endif
+
const std::string Folders::dataDir = DATA_DIR;
std::string Folders::getScreenshotDir()
@@ -56,6 +61,12 @@ std::string Folders::getUserDataPath()
} else {
return dataDir;
}
+#elif defined(__HAIKU__)
+ char path[B_FILE_NAME_LENGTH];
+ if (find_directory(B_USER_SETTINGS_DIRECTORY, 0, false, path, B_FILE_NAME_LENGTH) == B_OK)
+ userDataPath = std::string(path) + "/Lugaru";
+ else
+ userDataPath = "/boot/home/config/settings/Lugaru";
#elif (defined(__APPLE__) && defined(__MACH__))
const char* homePath = getHomeDirectory();
if (homePath == NULL) {
@@ -73,7 +84,7 @@ std::string Folders::getUserDataPath()
std::string Folders::getConfigFilePath()
{
std::string configFolder;
-#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__))
+#if defined(_WIN32) || (defined(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__)
configFolder = getUserDataPath();
#else // Linux
configFolder = getGenericDirectory("XDG_CONFIG_HOME", ".config");
diff --git a/Source/Utils/ImageIO.cpp b/Source/Utils/ImageIO.cpp
index 706c201..c19a63e 100644
--- a/Source/Utils/ImageIO.cpp
+++ b/Source/Utils/ImageIO.cpp
@@ -122,7 +122,7 @@ static bool load_jpg(const char* file_name, ImageRec& tex)
(void)jpeg_read_header(&cinfo, TRUE);
cinfo.out_color_space = JCS_RGB;
- cinfo.quantize_colors = 0;
+ cinfo.quantize_colors = FALSE;
(void)jpeg_calc_output_dimensions(&cinfo);
(void)jpeg_start_decompress(&cinfo);
diff --git a/Source/main.cpp b/Source/main.cpp
index 3593c69..3a70596 100644
--- a/Source/main.cpp
+++ b/Source/main.cpp
@@ -474,6 +474,8 @@ void CleanUp(void)
delete[] commandLineOptionsBuffer;
+ OPENAL_Close();
+
SDL_Quit();
}
--
2.23.0
From aaabcdb146910860d2f7a16f4117504342f0606f Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Mon, 9 Sep 2019 20:54:50 +1000
Subject: Fix working directory
diff --git a/Source/main.cpp b/Source/main.cpp
index 3a70596..2598662 100644
--- a/Source/main.cpp
+++ b/Source/main.cpp
@@ -477,6 +477,8 @@ void CleanUp(void)
OPENAL_Close();
SDL_Quit();
+
+ kill(::getpid(), SIGKILL);
}
// --------------------------------------------------------------------------
@@ -566,7 +568,15 @@ char* calcBaseDir(const char* argv0)
static inline void chdirToAppPath(const char* argv0)
{
+#if defined(__HAIKU__)
+ char *dir = realpath(argv0, NULL);
+ if (dir != NULL) {
+ char *appdir = strrchr(dir, '/');
+ *appdir = '\0';
+ }
+#else
char* dir = calcBaseDir(argv0);
+#endif
if (dir) {
#if (defined(__APPLE__) && defined(__MACH__))
// Chop off /Contents/MacOS if it's at the end of the string, so we
--
2.23.0